Handle encrypt-then-sign with encrypted Assertions#570
Closed
h-bragg wants to merge 2 commits intotngan:masterfrom
Closed
Handle encrypt-then-sign with encrypted Assertions#570h-bragg wants to merge 2 commits intotngan:masterfrom
encrypt-then-sign with encrypted Assertions#570h-bragg wants to merge 2 commits intotngan:masterfrom
Conversation
Contributor
|
Hey, thanks for looking into this and spotting the edge case: a) Can you try to give a test case for this, so I can ensure my patch works: With regards to the change:
We need to significantly refactor the logic for encrypted signed assertions. b) In the mean time to mitigate the vulnerability apply the patch from old v.2.9.1: diff --git a/src/libsaml.ts b/src/libsaml.ts
index 3ea5231..95ed42d 100644
--- a/src/libsaml.ts
+++ b/src/libsaml.ts
@@ -469,6 +469,27 @@ const libSaml = () => {
if (messageSignatureNode.length === 1) {
const node = select("/*[contains(local-name(), 'Response') or contains(local-name(), 'Request')]/*[local-name(.)='Assertion']", doc);
if (node.length === 1) {
+ const verifiedMessageSignatureRef = extract(messageSignatureNode[0].toString(), [{
+ key: 'refURI',
+ localPath: ['Signature', 'SignedInfo', 'Reference'],
+ attributes: ['URI']
+ }]);
+
+ const desiredResponseInfo = extract(doc.toString(), [{
+ key: 'id',
+ localPath: ['~Response'],
+ attributes: ['ID']
+ }]);
+ const desiredAssertionInfo = extract(doc.toString(), [{
+ key: 'id',
+ localPath: ['~Response', 'Assertion'],
+ attributes: ['ID']
+ }]);
+
+ if (verifiedMessageSignatureRef.refURI !== `#${desiredResponseInfo.id}` && verifiedMessageSignatureRef.refURI !== `#${desiredAssertionInfo.id}`) {
+ throw new Error('ERR_POTENTIAL_WRAPPING_ATTACK');
+ }
+
assertionNode = node[0].toString();
}
} |
Author
|
a proper fix is being applied in #571 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
We had an issue where a Response with a signature and
EncryptedAssertion's was failing in the change to theverifySignaturemethod.The Response did not contain any normal
Assertionnodes and thus would fail withERR_ZERO_SIGNATUREfrom these lines:https://github.com/tngan/samlify/blob/master/src/libsaml.ts#L496-L497
however the
assertionNodein the response fromverifySignatureis only used if thedecryptRequiredflag is not set so it looks like it should be ok to ignore node in this part of the response from:https://github.com/tngan/samlify/blob/master/src/flow.ts#L223-L227
Changes
assertionNode: nullfromverifySignaturewhenentitySetting.isAssertionEncryptedis set.