Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new .signedReferences property of signature to help prevent signature wrapping attacks. #489

Open
wants to merge 7 commits into
base: 6.x
Choose a base branch
from

Conversation

ahacker1-securesaml
Copy link

No description provided.

@cjbarth
Copy link
Contributor

cjbarth commented Mar 18, 2025

Since the effort to move to 6.1 or a full, breaking, 7.x would be the same, why not release this as the 7.x and actually make the breaking changes so that there is no doubt that the consumer got it right?

@markstos markstos changed the title V6 minor Introduced new .signedReferences property of signature to help prevent signature wrapping attacks. Mar 24, 2025
@markstos markstos changed the title Introduced new .signedReferences property of signature to help prevent signature wrapping attacks. Introduce new .signedReferences property of signature to help prevent signature wrapping attacks. Mar 24, 2025
Copy link
Contributor

@cjbarth cjbarth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but might need a lint run over it. I can do that just before I land it.

I'm marking this PR as "Request Changes" so you can see the comments on the PR and at least acknowledge them (make resolved if you want). They aren't major.


# Changelog

- Introduced new .signedReferences property of signature to help prevent signature wrapping attacks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog is automatically generated from the title of the PR. Any additional notes should go in the README.

@@ -87,6 +88,8 @@ export class SignedXml {
"http://www.w3.org/2000/09/xmldsig#enveloped-signature": envelopedSignatures.EnvelopedSignature,
};

// TODO: In V7.x we may consider deprecating sha1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for putting in a deprecation warning now and removing it later on. Either way.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only temporary for some SAML libraries to use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I was thinking there is no reason not to throw a deprecation notice now if someone uses sha1, no need to wait for 7.x to throw the notice.

@@ -154,6 +160,9 @@ export class SignedXml {
this.CanonicalizationAlgorithms;
this.HashAlgorithms;
this.SignatureAlgorithms;
// this populates only after verifying the signature
// array of bytes that are cryptographically authenticated
this.signedReferences = []; // TODO: should we rename this to something better.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a descriptive name to me. What other thoughts do you have?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, only problem is that people might confuse it to be a array of Reference objects, when it's an array of bytes.
Something like protectedBytes/protectedData could be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatty suggested options like authenticatedData and signatureVerifiedBytes. I have no problems with log descriptive names. I think, at a minimum, we should make sure the type is correct; right now it is untyped.

const verified = signer.verifySignature(unverifiedSignedInfoCanon, key, this.signatureValue);
// false case
// reset the signedReferences back to empty array
// I would have preferred to start by verifying the signedInfoCanon first, if that's OK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like our tests would catch if this causes breaking changes. Did one of the existing tests fail?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all test cases passed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all tests past when verifying signedInfoCanon first, I'm ok if you wanted to make that change now. If you still think it is too risky, I understand, though I'd be interested in what test might give us reassurance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants