-
Notifications
You must be signed in to change notification settings - Fork 475
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
Limit transforms for signed nodes #595
Conversation
Can you please reference where in the SAML spec this is recommended? Or, if you have a security paper reference that would be good too. |
I think this one might be good: I have not looked much at how other implementations have dealt with this specific concern, but I've found that Spring Security SAML is using OpenSAML, which in turn is putting a limit of two: |
I agree with the concept. I have not looked closely at the Xpath to confirm it's correct. @pp-ps Thanks for helping to improve the project security. |
@markstos I'm not knowledgeable enough on query optimization, but I feel it kinda works for my local test cases. |
@pp-ps, is this what you are trying to defend against: https://www.w3.org/TR/2013/NOTE-xmldsig-bestpractices-20130411/#xslt-denial ? |
@cjbarth Look at section "2.1.7 Example: Denial of service caused by too many transforms" (but skip the XPath part). I'm a bit shy about pushing a test as a PoC but I've been successful in triggering timeouts (> 2000ms in tests) with a specific Transform repeated hundreds of times. We can move to email for that though. |
I've pushed to another branch on my repo not to pollute the PR:
https://github.com/pp-ps/passport-saml/commits/timeout
After all, we have disclosed pretty much everything already in this
conversation.
|
@cjbarth @markstos |
@pp-ps If we are limiting the number of transforms to 2, why not write a test with 3 or 5 transforms, since it would run faster and produce the same result? |
@pp-ps I see you reverted the changes on your branch. Have you found something out about them that causes you to change your mind? |
@markstos that's doable, I'm OOO but when back I'll push a faster test (3/5 transforms) to this PR branch. I created the test on the "timeout" branch with thousands of Transforms to show the potential for DOS abuse (CPU is busy doing pointless work). |
There is one little spelling change, otherwise, I think this might be something to land and then to release. We will also need this duplicated against node-saml so they don't get out-of-sync during the transition. |
As far as I know a WebSSO profile shouldn't have more than 2 Transform, at most an "enveloped-signature" and an exclusive canonicalization transform. A SAMLResponse can force xml-crypto to needlessly spend time, bound only by POST size constraints.
All tests pass.