2222use SimpleSAML \SAML2 \XML \samlp \Response ;
2323use SimpleSAML \Test \SAML2 \Constants as C ;
2424use SimpleSAML \XML \DOMDocumentFactory ;
25+ use SimpleSAML \XMLSecurity \Alg \Signature \SignatureAlgorithmFactory ;
26+ use SimpleSAML \XMLSecurity \CryptoEncoding \PEM ;
27+ use SimpleSAML \XMLSecurity \Exception \CanonicalizationFailedException ;
28+ use SimpleSAML \XMLSecurity \Key \PublicKey ;
2529use SimpleSAML \XMLSecurity \TestUtils \PEMCertificatesMock ;
2630use SimpleSAML \XMLSecurity \Utils \Certificate ;
2731
@@ -46,12 +50,12 @@ final class SignatureValidationTest extends MockeryTestCase
4650 private ServiceProvider $ serviceProviderConfiguration ;
4751
4852 /**
49- * @var \Mockery\MockInterface Mock of \SAML2\Assertion\ProcessorBuilder
53+ * @var \Mockery\MockInterface Mock of \SimpleSAML\ SAML2\Assertion\ProcessorBuilder
5054 */
5155 private MockInterface $ assertionProcessorBuilder ;
5256
5357 /**
54- * @var \Mockery\MockInterface Mock of \SAML2\Assertion\Processor
58+ * @var \Mockery\MockInterface Mock of \SimpleSAML\ SAML2\Assertion\Processor
5559 */
5660 private MockInterface $ assertionProcessor ;
5761
@@ -180,6 +184,32 @@ public function testThatAnUnsignedResponseWithNoSignedAssertionsThrowsAnExceptio
180184 }
181185
182186
187+ /**
188+ * CVE-2025-66475
189+ */
190+ #[PreserveGlobalState(false )]
191+ #[RunInSeparateProcess]
192+ public function testSignedResponseWithStrayXmlnsThrowsAnException (): void
193+ {
194+ $ doc = DOMDocumentFactory::fromFile (
195+ dirname (__DIR__ , 2 ) . '/resources/xml/vulnerabilities/CVE-2025-66475.xml ' ,
196+ );
197+
198+ $ response = Response::fromXML ($ doc ->documentElement );
199+ $ assertion = $ response ->getAssertions ()[0 ];
200+
201+ $ verifier = (new SignatureAlgorithmFactory ())->getAlgorithm (
202+ $ assertion ->getSignature ()->getSignedInfo ()->getSignatureMethod ()->getAlgorithm ()->getValue (),
203+ new PublicKey (
204+ new PEM (PEM ::TYPE_PUBLIC_KEY , $ assertion ->getSignature ()->getKeyInfo ()->getInfo ()[0 ]->getData ()[0 ]->getContent ()->getValue ()),
205+ ),
206+ );
207+
208+ $ this ->expectException (CanonicalizationFailedException::class);
209+ $ assertion ->verify ($ verifier );
210+ }
211+
212+
183213 /**
184214 * @return \SimpleSAML\SAML2\XML\samlp\Response
185215 */
0 commit comments