CVE-2025-24895 - Critical SAML Signature Validation Bypass in CIE.AspNetCore.Authentication
Published: June 2024
Affected package: cie-aspnetcore (CIE.AspNetCore.Authentication)
Fixed in: v2.1.
Impact: Remote user impersonation (Critical)
CVSS Score: 9.8 (Critical)
Introduction
Remote authentication is a cornerstone of modern digital identity. The CIE.AspNetCore.Authentication library lets .NET developers use the CIE 3. and SPID digital identity systems through SAML2. For everyone using this library until version 2.1., a new vulnerability tracked as CVE-2025-24895 allows attackers to potentially impersonate any Italian digital identity (CIE/SPID) user on your web application.
Let’s break down what went wrong, what the exploit looks like, and how you can protect your apps.
It trusts the IdP through SAML responses.
3. Assertion: The IdP sends a SAML response (XML) with a signed assertion: _“Yes, this user is Maria Rossi.”_
The Service Provider validates the XML signature: If it verifies, access is granted.
The cie-aspnetcore package makes your app the Service Provider (SP). It validates these SAML responses.
What’s the Vulnerability?
In vulnerable versions, CIE.AspNetCore.Authentication assumes that the _first_ signature in a SAML Response is always the one tied to the root response object.
But...
If an attacker puts a validly signed element (from the IdP) as the first child in the response, the actual SAML assertion (containing user identity) could be unsigned or malicious. The validation logic only checks the _first signature_ and skips the rest — meaning fake assertions fly past undetected.
The attacker just needs any signed XML chunk from the IdP (easy to get from public metadata). With this, they craft a valid SAML reply and trick the SP into thinking a user is legitimately authenticated.
Visual Representation
<SAMLResponse>
  <SomeSignedElement ID="legitimate" ...>
    ...
  </SomeSignedElement>
  <Assertion>
    <!-- Unlike the first element, this could be manipulated or completely fake. -->
    <NameID>eviluser@example.com</NameID>
    ...
  </Assertion>
</SAMLResponse>
Puts the legitimately signed element first.
- Follows with a fake or unsigned Assertion containing attacker’s name/e-mail.
Pseudocode Exploit Example
import xml.etree.ElementTree as ET
# Step 1: Fetch legitimate signed IdP snippet (from metadata or a real session)
with open("idp_signature_fragment.xml", "r") as f:
    signed_element = f.read()
# Step 2: Prepare fake assertion
fake_assertion = '''
<Assertion>
  <Subject>
    <NameID>admin@yourapp.com</NameID>
  </Subject>
  <AuthnStatement ...>
    <!-- whatever fields needed -->
  </AuthnStatement>
</Assertion>
'''
# Step 3: Compose SAML response
saml_response = f'''
<SAMLResponse>
  {signed_element}
  {fake_assertion}
</SAMLResponse>
'''
print(saml_response)
# Step 4: Send this crafted response to the vulnerable app's SAML endpoint.
Note: This script is for educational purposes only to illustrate the flaw.
Links & References
- Official Advisory (placeholder)
- cie-aspnetcore package
- SAML Signature Validation Attacks
- SAML XML signature wrapping (XSW) attacks explained (Lektorado)
- SAML2 Spec for reference
dotnet add package CIE.AspNetCore.Authentication --version 2.1.
`
- Publish an advisory and revoke any SAML session tokens issued before the fix.
---
## Conclusion
CVE-2025-24895 is a textbook example of why signature validation _order_ and _scope_ are crucial in SAML2 implementations. If you use CIE.AspNetCore.Authentication for SPID or CIE, your authentication may be trivially bypassed by anyone with access to public IdP metadata, until you upgrade.
Mitigation steps:
1. Update now to version 2.1.+
2. Check your logs for unusual SAML logins.
3. Spread the word among Italian digital identity integration teams.
Stay safe, and keep SAML secure!
Timeline
Published on: 02/18/2025 19:15:28 UTC