Skip to content

Commit 5361235

Browse files
Update apache.santuario.xmlsec dep from 2.1.4 to 2.2.6 (#112022)
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)!
1 parent cba614a commit 5361235

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

gradle/verification-metadata.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,9 +3137,9 @@
31373137
<sha256 value="71f61f34db5e6d926cb8050709fed0ef32788d3f4e9dc06e884c6f3b911b21eb" origin="Generated by Gradle"/>
31383138
</artifact>
31393139
</component>
3140-
<component group="org.apache.santuario" name="xmlsec" version="2.1.4">
3141-
<artifact name="xmlsec-2.1.4.jar">
3142-
<sha256 value="2e2ec8fe0cf873979f630ae4d35e7ede3390321279b7a15de9deed3f3430990c" origin="Generated by Gradle"/>
3140+
<component group="org.apache.santuario" name="xmlsec" version="2.2.6">
3141+
<artifact name="xmlsec-2.2.6.jar">
3142+
<sha256 value="9325edf9e2449a31315b7f0c49204840d465b38f7e83ecc9471da125ea3d5b75" origin="Generated by Gradle"/>
31433143
</artifact>
31443144
</component>
31453145
<component group="org.apache.servicemix.bundles" name="org.apache.servicemix.bundles.antlr" version="2.7.7_5">

x-pack/plugin/identity-provider/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies {
3333
api "org.opensaml:opensaml-storage-api:3.4.5"
3434
api "org.opensaml:opensaml-storage-impl:3.4.5"
3535
api "net.shibboleth.utilities:java-support:7.5.1"
36-
api "org.apache.santuario:xmlsec:2.1.4"
36+
api "org.apache.santuario:xmlsec:2.2.6"
3737
api "io.dropwizard.metrics:metrics-core:3.2.2"
3838
api ("org.cryptacular:cryptacular:1.2.4") {
3939
exclude group: 'org.bouncycastle'

x-pack/plugin/security/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies {
5353
api "org.opensaml:opensaml-storage-api:3.4.5"
5454
api "org.opensaml:opensaml-storage-impl:3.4.5"
5555
api "net.shibboleth.utilities:java-support:7.5.1"
56-
api "org.apache.santuario:xmlsec:2.1.4"
56+
api "org.apache.santuario:xmlsec:2.2.6"
5757
api "io.dropwizard.metrics:metrics-core:3.2.2"
5858
api ("org.cryptacular:cryptacular:1.2.4") {
5959
exclude group: 'org.bouncycastle'

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/saml/SamlObjectHandler.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.apache.logging.log4j.message.ParameterizedMessage;
1212
import org.elasticsearch.ElasticsearchSecurityException;
1313
import org.elasticsearch.common.Strings;
14+
import org.elasticsearch.common.hash.MessageDigests;
1415
import org.elasticsearch.core.CheckedFunction;
1516
import org.elasticsearch.core.Nullable;
1617
import org.elasticsearch.core.TimeValue;
@@ -27,6 +28,7 @@
2728
import org.opensaml.saml.security.impl.SAMLSignatureProfileValidator;
2829
import org.opensaml.security.credential.Credential;
2930
import org.opensaml.security.x509.X509Credential;
31+
import org.opensaml.xmlsec.algorithm.AlgorithmSupport;
3032
import org.opensaml.xmlsec.crypto.XMLSigningUtil;
3133
import org.opensaml.xmlsec.encryption.support.ChainingEncryptedKeyResolver;
3234
import org.opensaml.xmlsec.encryption.support.EncryptedKeyResolver;
@@ -167,6 +169,21 @@ void validateSignature(Signature signature) {
167169

168170
checkIdpSignature(credential -> {
169171
try {
172+
final String signatureAlg = AlgorithmSupport.getKeyAlgorithm(signature.getSignatureAlgorithm());
173+
final String keyAlg = credential.getPublicKey().getAlgorithm();
174+
if (signatureAlg != null && signatureAlg.equals(keyAlg) == false) {
175+
if (logger.isDebugEnabled()) {
176+
String keyFingerprint = "SHA265:"
177+
+ MessageDigests.toHexString(MessageDigests.sha256().digest(credential.getPublicKey().getEncoded()));
178+
logger.debug(
179+
"Skipping [{}] key [{}] because it is not compatible with signature algorithm [{}]",
180+
keyAlg,
181+
keyFingerprint,
182+
signatureAlg
183+
);
184+
}
185+
return false;
186+
}
170187
return AccessController.doPrivileged((PrivilegedExceptionAction<Boolean>) () -> {
171188
try (RestorableContextClassLoader ignore = new RestorableContextClassLoader(SignatureValidator.class)) {
172189
SignatureValidator.validate(signature, credential);

0 commit comments

Comments
 (0)