CWE-347
### Summary LightSaml 5.0.0 (latest release; also confirmed on 4.6.1) validates an inbound `samlp:Response` by collecting its direct-child `saml:Assertion` elements and validating each one's `ds:Signature` via robrichards/xmlseclibs. The two layers disagree on which element a signature actually covers: LightSaml reads claims from the assertion node it collected, while xmlseclibs resolves the signed `Reference URI="#id"` with a document-wide `//*[@Id]` XPath that returns the first ID-bearing element anywhere in the document. An attacker who has captured one genuine signed assertion can exploit this to surface attacker-authored, unsigned claims. ### Details `Response::deserialize` collects assertions with `manyElementsFromXml`, whose relative XPath `saml:Assertion` matches only direct children of the `Response`. Each collected assertion is validated independently by `AssertionSignatureValidatorAction` against the out-of-band trusted IdP credential (resolved by Issuer entityId, never from the document): https://github.com/litesaml/lightsaml/blob/5.0.0/src/Model/Protocol/Response.php#L122 https://github.com/litesaml/lightsaml/blob/5.0.0/src/Model/AbstractSamlModel.php#L93 https://github.com/litesaml/lightsaml/blob/5.0.0/src/Action/Assertion/Inbound/AssertionSignatureValidatorAction.php#L28 The check delegates to xmlseclibs `XMLSecurityDSig::validateReference()`, which first removes the signature node being validated from the shared document (enveloped-signature removal): `