/

CVE-2026-46490

Severity:

HIGH RISK

(8.8)

XML Injection (CWE-91) in samlify SAML Assertion Templates

CVE-2026-46490

Analyzed

Vulnerability type

Category:

XML Injection

CWE:

CWE-91

Impact:

Privilege Escalation via Trusted SAML Attributes

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

samlify's SAML assertion templating previously failed to escape values inserted into XML element text, allowing user-controlled data to inject additional XML markup into signed assertions.

When service providers rely on SAML attributes for authorization, an attacker can abuse this flaw to have an identity provider sign tampered assertions and gain elevated roles or group memberships.

Affected context

This vulnerability appears in applications that use samlify as a Node.js SAML library to build or process assertions where user-supplied attributes (such as email, display name, or custom fields) are interpolated into XML templates.

The issue arises specifically when attribute values are inserted directly into XML element text (for example, inside <saml:AttributeValue>) and not fully escaped before signing.

It is most relevant in deployments where service providers consume signed SAML attributes for authorization decisions, such as assigning roles, groups, or access scopes based on attribute values.

Exploit preconditions

  • Attack surface: SAML SSO flows where samlify constructs or processes SAML assertions based on user-controllable attribute data.
  • Required access: Ability for a user to influence attribute values sent to or stored by the IdP (e.g., self-editable profile fields, registration data, or upstream identity data).
  • Trigger point: Generation or handling of SAML assertions in samlify where unescaped attribute values are substituted into XML element text and subsequently signed by the IdP.
  • Why exploitation is possible: Template substitution only escapes attribute contexts; element text is not escaped, allowing attacker-controlled content to break out of the intended text node and inject new XML elements that become part of the signed assertion.

Why this happens

The core issue is incomplete output encoding in XML templates, aligning with CWE-91: XML Injection.

samlify's templating logic properly escaped values in attribute contexts (e.g., attr="value"), but failed to apply equivalent escaping when inserting values into XML element bodies such as <saml:AttributeValue>user_input</saml:AttributeValue>.

As a result, special XML characters in user-controlled data (such as < and >) could terminate the text node and introduce new elements, including additional <saml:Attribute> blocks.

Because these injected elements are present at the moment the IdP signs the assertion, they are indistinguishable from legitimate attributes to the service provider, which treats them as trusted identity data and may use them for authorization.

Potential impact

  • Attackers may obtain roles, groups, or permissions they were not originally granted by injecting additional SAML attributes.
  • Applications can be tricked into granting access to privileged resources or administrative functions based on forged attribute claims.
  • Downstream services that rely on SAML attributes for fine-grained access control could be bypassed or misconfigured.
  • Trust relationships between identity providers and service providers may be undermined, leading to broader security policy violations.

General mitigation guidance

Effective mitigation centers on robust XML output encoding and strict handling of SAML attributes:

  • Ensure that any user-influenced data inserted into XML element text is safely escaped according to XML rules, not just in attribute contexts.
  • Avoid constructing SAML assertions with manual string templating where values can break out of their intended XML nodes; use well-tested DOM or builder APIs that handle escaping by default.
  • Restrict which attributes are accepted and used for authorization, and prefer attributes sourced from authoritative identity data rather than self-asserted user input.
  • Implement defense-in-depth on the service provider side by validating received attributes against expected schemas, types, and allowed sets of values before enforcing authorization.
  • Apply least-privilege principles in authorization logic so that high-impact roles or groups require multiple independent signals, not just a single attribute claim.

How teams detect issues like this

Organizations can identify and monitor for similar XML injection issues with a mix of preventive and detective controls:

  • Use static analysis or secure code review to flag string-based XML construction where user-controlled data is concatenated into element text without explicit escaping.
  • Review SAML-related code paths to verify that all templating or XML builders correctly encode special characters for both attribute and element contexts.
  • Introduce unit and integration tests that attempt to inject XML metacharacters (e.g., <tag>) into attributes and confirm they are safely encoded and cannot create new elements in the resulting assertion.
  • Employ security-focused linters or automated review tools that understand common XML and SAML libraries in Node.js and warn when low-level string interpolation is used instead of safe APIs.

Sources

SourceLink
github.comgithub.com/tngan/samlify/security/advisories/GHSA-34r5-q4jw-r36m

Frequently asked

questions

Yes. If a user can control attribute values that end up in SAML assertions, they can exploit the issue during normal SSO flows without direct access to the identity provider or service provider infrastructure.

The attacker needs the ability to influence the content of attributes used in the SAML assertion, such as editable profile fields or upstream identity attributes.

They do not need administrative access if those attributes can be modified through standard user interfaces or external identity sources.

The most robust fix is to rely on XML construction mechanisms that automatically escape data in all contexts and to explicitly encode any user-controlled values before inserting them into XML element text.

Additionally, treat assertion attributes as potentially untrusted until they have been validated and normalized.

Adopt a secure templating and encoding strategy for all markup formats (XML, HTML, JSON-based templates), avoid raw string concatenation with user input, and codify these practices into coding standards and automated checks.

For SAML specifically, combine safe XML handling with strict attribute whitelists and conservative authorization logic that does not blindly trust incoming attribute claims.

Find out what's already
exploitable in your codebase.