Skip to content

Commit 37987d6

Browse files
committed
We will not validate IP addresses as part of assertion validation
Fixes spring-projectsgh-7514 spring-projects#7514
1 parent badb0a0 commit 37987d6

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProvider.java

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.opensaml.saml.saml2.core.NameID;
4646
import org.opensaml.saml.saml2.core.Response;
4747
import org.opensaml.saml.saml2.core.Subject;
48+
import org.opensaml.saml.saml2.core.SubjectConfirmation;
4849
import org.opensaml.saml.saml2.encryption.Decrypter;
4950
import org.opensaml.saml.security.impl.SAMLSignatureProfileValidator;
5051
import org.opensaml.security.credential.Credential;
@@ -327,6 +328,15 @@ private void validateAssertion(String recipient, Assertion a, Saml2Authenticatio
327328
//ensure that OpenSAML doesn't attempt signature validation, already performed
328329
a.setSignature(null);
329330

331+
//ensure that we don't validate IP addresses as part of our validation gh-7514
332+
if (a.getSubject() != null) {
333+
for (SubjectConfirmation sc : a.getSubject().getSubjectConfirmations()) {
334+
if (sc.getSubjectConfirmationData() != null) {
335+
sc.getSubjectConfirmationData().setAddress(null);
336+
}
337+
}
338+
}
339+
330340
//remainder of assertion validation
331341
ValidationContext vctx = new ValidationContext(validationParams);
332342
try {

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProviderTests.java

+17
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,23 @@ public void authenticateWhenUsernameMissingThenThrowAuthenticationException() th
215215
provider.authenticate(token);
216216
}
217217

218+
@Test
219+
public void authenticateWhenAssertionContainsValidationAddressThenItSucceeds() throws Exception {
220+
Response response = response(recipientUri, idpEntityId);
221+
Assertion assertion = defaultAssertion();
222+
assertion.getSubject().getSubjectConfirmations().forEach(
223+
sc -> sc.getSubjectConfirmationData().setAddress("10.10.10.10")
224+
);
225+
signXmlObject(
226+
assertion,
227+
assertingPartyCredentials(),
228+
recipientEntityId
229+
);
230+
response.getAssertions().add(assertion);
231+
token = responseXml(response, idpEntityId);
232+
provider.authenticate(token);
233+
}
234+
218235
@Test
219236
public void authenticateWhenEncryptedAssertionWithoutSignatureThenItFails() throws Exception {
220237
Response response = response(recipientUri, idpEntityId);

0 commit comments

Comments
 (0)