You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Earlier this week, Google rolled out a change to their GSuite SAML Apps IdP where the SAMLResponse contains XML-encoded carriage returns inside the SignatureValue and X509Certificate blocks.
For example, they started sending this (notice the at the end of each line):
At first, I thought this must be a bug introduced on their end, but I saw that both samltool.com and SimpleSAMLphp considered that to be a valid SAMLResponse. I also noticed that other Java-based (Apache Santuario) IdPs will provide a SAMLResponse like that when a certain system property is unset (link). I could not find anywhere in the SAML or XML spec that mentions this, but I did notice that DOMParser correctly replaces those with actual carriage returns. We can confirm it like this:
const{ DOMParser }=require('xmldom')newDOMParser().parseFromString('<abc>123 456</abc>').toString().replace(/\r/g,'\\r')// just for display purposes here// -> `123\r456`
I believe the root of the problem is that validateSignatureForCert passes raw XML (that has never been passed through a DOMParser) to sig.checkSignature(fullXml).
To Reproduce
Add a inside the SignatureValue in test/static/signatures/valid/response.root-unsigned.assertion-signed.xml, and run tests. Tests will fail.
Expected behavior
Tests should pass.
Environment
Node.js version: 14.15.1
passport-saml version: 2.0.6
The text was updated successfully, but these errors were encountered:
mhassan1
changed the title
[BUG] XML-encoded carriage returns are not normalized correctly
[BUG] XML-encoded carriage returns are not resolved correctly
Mar 25, 2021
Background
Earlier this week, Google rolled out a change to their GSuite SAML Apps IdP where the SAMLResponse contains XML-encoded carriage returns inside the
SignatureValue
andX509Certificate
blocks.For example, they started sending this (notice the
at the end of each line):At first, I thought this must be a bug introduced on their end, but I saw that both samltool.com and SimpleSAMLphp considered that to be a valid SAMLResponse. I also noticed that other Java-based (Apache Santuario) IdPs will provide a SAMLResponse like that when a certain system property is unset (link). I could not find anywhere in the SAML or XML spec that mentions this, but I did notice that
DOMParser
correctly replaces those
with actual carriage returns. We can confirm it like this:I believe the root of the problem is that
validateSignatureForCert
passes raw XML (that has never been passed through aDOMParser
) tosig.checkSignature(fullXml)
.To Reproduce
Add a
inside theSignatureValue
intest/static/signatures/valid/response.root-unsigned.assertion-signed.xml
, and run tests. Tests will fail.Expected behavior
Tests should pass.
Environment
The text was updated successfully, but these errors were encountered: