Executive brief
samlify is a Node.js library used to implement SAML single sign-on (SSO) authentication in web applications. The library fails to properly escape user-supplied data when constructing SAML assertions, allowing an attacker to inject arbitrary XML markup into signed authentication tokens. By exploiting this flaw, an unprivileged user can add forged attributes (such as admin roles) to their own SAML assertion, which the system then trusts and uses for authorization, granting them elevated privileges without proper authentication.
Technical details
This is an XML injection vulnerability (CWE-91) in samlify's replaceTagsByValue() function in src/libsaml.ts. The root cause is that the function only escapes XML special characters when a placeholder is preceded by a quote (indicating attribute context), but leaves values inserted into element text content unescaped. Because attribute values are placed within <saml:AttributeValue> element text rather than XML attributes, an attacker can inject closing tags and new SAML:Attribute elements. A normal, authenticated user can craft user profile data (e.g., email field) containing XML payload that closes the current attribute, creates new SAML attributes with elevated privileges, and reopens an attribute to maintain XML validity. The identity provider then signs the tampered assertion without validating the internal structure, and the service provider accepts the forged attributes as cryptographically valid. No user interaction is required beyond initial authentication. The vulnerability affects samlify versions prior to 2.13.0; patched versions properly escape all user input regardless of context.
Affected products
- tngan samlify prior to 2.13.0
Timeline
- 2026-05-21: disclosed: Advisory published on GitHub and OSV database
- 2026-05-21: patched: Patched version 2.13.0 released