|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace SimpleSAML\Test\SAML2\Response; |
| 6 | + |
| 7 | +use PHPUnit\Framework\Attributes\CoversClass; |
| 8 | +use PHPUnit\Framework\Attributes\Group; |
| 9 | +use PHPUnit\Framework\TestCase; |
| 10 | +use SimpleSAML\SAML2\XML\samlp\Response; |
| 11 | +use SimpleSAML\XML\DOMDocumentFactory; |
| 12 | +use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory; |
| 13 | +use SimpleSAML\XMLSecurity\CryptoEncoding\PEM; |
| 14 | +use SimpleSAML\XMLSecurity\Exception\CanonicalizationFailedException; |
| 15 | +use SimpleSAML\XMLSecurity\Key\PublicKey; |
| 16 | +use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock; |
| 17 | + |
| 18 | +use function dirname; |
| 19 | + |
| 20 | +/** |
| 21 | + * CVE-2025-66475 |
| 22 | + * |
| 23 | + * @package simplesamlphp/saml2 |
| 24 | + */ |
| 25 | +#[Group('vulnerabilities')] |
| 26 | +#[CoversClass(ResponseProcessor::class)] |
| 27 | +final class GoldenSAMLResponseTest extends TestCase |
| 28 | +{ |
| 29 | + /** |
| 30 | + */ |
| 31 | + public function testSignedResponseWithStrayXmlnsThrowsAnException(): void |
| 32 | + { |
| 33 | + $doc = DOMDocumentFactory::fromFile( |
| 34 | + dirname(__DIR__, 1) . '/resources/xml/vulnerabilities/CVE-2025-66475.xml', |
| 35 | + ); |
| 36 | + |
| 37 | + $response = Response::fromXML($doc->documentElement); |
| 38 | + $assertion = $response->getAssertions()[0]; |
| 39 | + |
| 40 | + $verifier = (new SignatureAlgorithmFactory())->getAlgorithm( |
| 41 | + $assertion->getSignature()->getSignedInfo()->getSignatureMethod()->getAlgorithm()->getValue(), |
| 42 | + new PublicKey( |
| 43 | + new PEM(PEM::TYPE_PUBLIC_KEY, $assertion->getSignature()->getKeyInfo()->getInfo()[0]->getData()[0]->getContent()->getValue()), |
| 44 | + ), |
| 45 | + ); |
| 46 | + |
| 47 | + $this->expectException(CanonicalizationFailedException::class); |
| 48 | + @$assertion->verify($verifier); |
| 49 | + } |
| 50 | +} |
0 commit comments