Skip to main content

Research

XML Signature Wrapping in Session Cookies

Exploiting and preventing XML signature wrapping attacks behind a CDN CI pipeline gate design

Pentrova Research Pentrova Research
5 min read

Reading mode

What is XML Signature Wrapping?#

XML signature wrapping is a type of attack that exploits the XML signature validation process in order to bypass authentication or authorization mechanisms. It involves manipulating the XML signature of a message, such as a session cookie, in order to make it appear as though the message has been signed by a trusted entity, when in fact it has not. As explained in RFC 3653: XML-Signature XPath Filter 2.0, XML signatures are used to ensure the integrity and authenticity of XML documents.

How XML Signature Wrapping Works#

The process of XML signature wrapping involves several steps. First, an attacker must obtain a valid XML signature for a message, such as a session cookie. This can be done by intercepting a legitimate message or by exploiting a vulnerability in the signature generation process. Next, the attacker must manipulate the XML signature to make it appear as though the message has been signed by a trusted entity. This can be done by modifying the signature elements, such as the SignedInfo element, to point to a different location in the message. Finally, the attacker must transmit the modified message to the victim, who will then verify the signature and grant access to the requested resources. The Fragile Lock: Novel Bypasses For SAML Authentication provides more information on how XML signature wrapping attacks can be performed.

XML Signature Wrapping Attacks#

There are several types of attacks that can be performed using XML signature wrapping, including attribute pollution and namespace confusion. Attribute pollution involves adding additional attributes to an XML element in order to manipulate the signature validation process. Namespace confusion involves manipulating the namespace declarations in an XML document in order to make it appear as though the document has been signed by a trusted entity. SAML Security - OWASP Cheat Sheet Series provides more information on how to prevent these types of attacks.

Comparison of XML Signature Wrapping and HTTP Message Signatures#

XML Signature WrappingHTTP Message Signatures
PurposeEnsure integrity and authenticity of XML documentsEnsure integrity and authenticity of HTTP messages
MechanismUses XML signatures to validate messagesUses digital signatures or message authentication codes to validate messages
VulnerabilitiesVulnerable to attribute pollution and namespace confusion attacksVulnerable to replay attacks and tampering
Bottom lineXML signature wrapping is a specific type of attack that exploits the XML signature validation process, while HTTP message signatures are a more general mechanism for ensuring the integrity and authenticity of HTTP messages. As explained in RFC 9421: HTTP Message Signatures, HTTP message signatures provide a more robust and secure way to validate HTTP messages.

Prevention and Mitigation Techniques#

There are several techniques that can be used to prevent and mitigate XML signature wrapping attacks, including input validation and secure coding practices. Input validation involves verifying that the input to an application is valid and expected, in order to prevent attackers from manipulating the input to exploit vulnerabilities. Secure coding practices involve following best practices for coding, such as using secure protocols for communication and validating user input, in order to prevent vulnerabilities from being introduced into an application. draft-ietf-cdni-uri-signing-13 - URI Signing for CDN Interconnection (CDNI) provides more information on how to implement secure coding practices.

How to Implement Secure XML Signature Wrapping#

  1. Validate Input: Verify that the input to the application is valid and expected, in order to prevent attackers from manipulating the input to exploit vulnerabilities.
  2. Use Secure Protocols: Use secure protocols for communication, such as HTTPS, in order to prevent eavesdropping and tampering.
  3. Validate Signatures: Verify that the XML signatures are valid and have not been tampered with, in order to prevent XML signature wrapping attacks.
  4. Implement Secure Coding Practices: Follow best practices for coding, such as using secure protocols for communication and validating user input, in order to prevent vulnerabilities from being introduced into the application.

Verification and Testing of XML Signature Wrapping#

To verify and test the security of XML signature wrapping implementations, several methods can be used, including penetration testing and code review. Penetration testing involves simulating attacks on an application in order to test its defenses, while code review involves reviewing the code of an application in order to identify vulnerabilities and weaknesses. The Fragile Lock: Novel Bypasses For SAML Authentication provides more information on how to perform penetration testing and code review.

FAQ#

What is the difference between XML signature wrapping and HTTP message signatures?#

XML signature wrapping is a specific type of attack that exploits the XML signature validation process, while HTTP message signatures are a more general mechanism for ensuring the integrity and authenticity of HTTP messages.

How can I prevent XML signature wrapping attacks in my CDN CI pipeline gate design?#

To prevent XML signature wrapping attacks, use secure coding practices, such as input validation and secure protocols for communication, and implement secure XML signature wrapping mechanisms, such as verifying the validity of XML signatures.

What are the potential consequences of an XML signature wrapping attack?#

The potential consequences of an XML signature wrapping attack include unauthorized access to sensitive resources, data tampering, and eavesdropping. To learn more about preventing these types of attacks, visit our API Security page.

Written by

Pentrova Research Pentrova Research

Pentrova Research writes about offensive security, LLM-driven pentest chains, and how to ship exploit-grade evidence into engineering pipelines.

CI/CD PR Gating

Block confirmed findings before release

Fail the build only on confirmed findings, and give developers the captured request to copy as cURL, so triage starts from evidence instead of debate.

See CI/CD Gating →

Keep reading

Site search

↑↓ navigateEnter openEsc close