Skip to content

Update apache.santuario.xmlsec dep from 2.1.4 to 2.2.6#112022

Merged
albertzaharovits merged 7 commits intoelastic:7.17from
albertzaharovits:update-apache-santuario-2.2.6
Aug 23, 2024
Merged

Update apache.santuario.xmlsec dep from 2.1.4 to 2.2.6#112022
albertzaharovits merged 7 commits intoelastic:7.17from
albertzaharovits:update-apache-santuario-2.2.6

Conversation

@albertzaharovits
Copy link
Copy Markdown
Contributor

@albertzaharovits albertzaharovits commented Aug 20, 2024

apache.santuario.xmlsec version 2.1.4 is documented vulnerable. We should update to mitigate the vulnerabilities.
But apache.santuario.xmlsec is a dependency of opensaml version 3.*.

However, in a patch release of elasticsearch (i.e. 7.17.*) it's best we avoid updating dependencies across major versions (i.e. opensaml from version 3.* to version 4.*), particularly for such a complex dependency as opensaml (we did update the opensaml dep in this way, but in a minor elasticsearch 8.* release, i.e. #98199). The latest opensaml 3.* release (i.e. 3.4.6) still requires a vulnerable apache.santuario.xmlsec dep: https://mvnrepository.com/artifact/org.opensaml/opensaml-xmlsec-impl/3.4.6).

In this case, our best hope is to find a non-vulnerable version of apache.santuario.xmlsec that is still on the same major version as the version listed in the deps of opensaml (i.e. 2.*). That's version 2.2.6: https://mvnrepository.com/artifact/org.apache.santuario/xmlsec/2.2.6 , which is not vulnerable

This PR updates apache.santuario.xmlsec from the existing 2.1.4 version to the 2.2.6 version. The release notes of the 2.2.0 version from https://santuario.apache.org/javareleasenotes.html look simple, and the dependencies differences (from https://mvnrepository.com/artifact/org.apache.santuario/xmlsec/2.1.4) are minimal as well (hopefully optional dependencies, which we don't pull in, stay optional in the same way in the new version).
So, it looks to me that the dep update is relatively safe (and it also passes CI)!

2 last points that I've considered:

  • We could update apache.santuario.xmlsec to the 2.1.8 https://mvnrepository.com/artifact/org.apache.santuario/xmlsec/2.1.8 version instead. This has the advantage that there's a smaller chance of problems, since in this case the update only covers the patch version (2.1.4 -> 2.1.8). However 2.1.8 is still vulnerable.
  • We could also try to update opensaml from 3.4.5 to 3.4.6. The benefit of this is that 3.4.6 is a later release, closer by calendar date to the apache.santuario.xmlsec2.2.6 or 2.1.8 releases, which also decreases incompatibilities risks (just at a hope level).

@albertzaharovits albertzaharovits changed the title just update to 2.2.6 Update apache.santuario.xmlsec dep from 2.1.4 to 2.2.6 Aug 22, 2024
Comment on lines +172 to +186
final String signatureAlg = AlgorithmSupport.getKeyAlgorithm(signature.getSignatureAlgorithm());
final String keyAlg = credential.getPublicKey().getAlgorithm();
if (signatureAlg != null && signatureAlg.equals(keyAlg) == false) {
if (logger.isDebugEnabled()) {
String keyFingerprint = "SHA265:"
+ MessageDigests.toHexString(MessageDigests.sha256().digest(credential.getPublicKey().getEncoded()));
logger.debug(
"Skipping [{}] key [{}] because it is not compatible with signature algorithm [{}]",
keyAlg,
keyFingerprint,
signatureAlg
);
}
return false;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit is from #98119 . Without it there are test failures such as https://gradle-enterprise.elastic.co/s/6hj4qm6ntsbpc/tests/task/:x-pack:plugin:security:test/details/org.elasticsearch.xpack.security.authc.saml.SamlAuthenticatorTests/testSigningWhenIdpHasMultipleKeys?top-execution=1 .
This shows that the internals of the lib changed in between the version updates, so there is a certain risk in the update.

@albertzaharovits albertzaharovits added :Security/Security Security issues without another label >non-issue labels Aug 22, 2024
@albertzaharovits albertzaharovits marked this pull request as ready for review August 22, 2024 11:35
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-security (Team:Security)

@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Aug 22, 2024
@albertzaharovits albertzaharovits added the :Security/FIPS Running ES in FIPS 140-2 mode label Aug 22, 2024
@slobodanadamovic slobodanadamovic self-requested a review August 22, 2024 15:13
@albertzaharovits
Copy link
Copy Markdown
Contributor Author

@elasticsearchmachine test this please

Copy link
Copy Markdown
Contributor

@slobodanadamovic slobodanadamovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for updating this!

@albertzaharovits albertzaharovits merged commit 5361235 into elastic:7.17 Aug 23, 2024
@albertzaharovits albertzaharovits deleted the update-apache-santuario-2.2.6 branch August 23, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Security/FIPS Running ES in FIPS 140-2 mode :Security/Security Security issues without another label Team:Security Meta label for security team v7.17.24

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants