The vulnerability lies in authentik's SAML Source ACS endpoint, which was susceptible to XML Signature Wrapping (XSW). The core of the issue was in the signature verification process for SAML responses. The application would verify that a signature was cryptographically valid but failed to ensure that the signature corresponded to the correct part of the SAML document that was being processed for user authentication. This allowed an attacker to take a legitimately signed SAML assertion, include it in a crafted response alongside a forged assertion, and trick the system. The signature from the legitimate assertion would be validated, but the system would then proceed to use the identity information from the attacker's forged assertion. This could allow an attacker to impersonate any other federated user.
The patch addresses this by modifying the signature verification logic. The key change is in the _verify_signature function within authentik/sources/saml/processors/response.py. It now requires the specific XML element that is expected to be signed (the target) as an argument. It then explicitly checks that the Reference URI inside the XML Signature points directly to the ID of this target element. This ensures that the signature being verified is undeniably linked to the data being consumed, effectively preventing the signature from being wrapped around malicious content. The functions _verify_response_signature and _verify_assertion_signature were updated to call the new, more secure _verify_signature with the correct target element (either the whole response or the specific assertion).