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

Fixes #180: Signature validation will error if empty signature is pro… #182

Closed
wants to merge 2 commits into from

Conversation

andrsnn
Copy link
Contributor

@andrsnn andrsnn commented Dec 30, 2016

…vided

@andrsnn
Copy link
Contributor Author

andrsnn commented Dec 30, 2016

There might be some discussion as to whether or not the cert property should be required. This pull request seems to address the main concern, without enforcing a breaking api change.

@markstos
Copy link
Contributor

I agree about the problem, but not about the solution.

It could be helpful to validate that cert is not an empty string.

However this issue is a programmer error that could be caught earlier. So:

  1. The error handling should be in SAML.prototype.intialize, where cert is set. It could throw immediately if cert is an empty string.
  2. It's wrong to declare this an "Invalid Signature", because that's not the issue. A more helpful error message would be "cert: private key must not be empty".

@andrsnn
Copy link
Contributor Author

andrsnn commented Sep 27, 2018

Definitely makes sense, and thank you for the feedback. As error handling in the initialize / constructor function would be a first, I would argue throwing an error would be a breaking API change and would likely merit a major version increase. The above PR should be backwards compatible, which is why the validation occurs in the validatePostResponse and validatePostRequest.

I would also prefer an error message along the lines of "cert: private key must not be empty". For the above PR, I was assuming that some may be incorrectly passing this error directly back to the client passport.authenticate('saml', next), which might result in a security issue. Missing certificate might be better messaging without revealing too much.

Any thoughts to the above? I'd be glad to make the suggested changes if you do think they merit a major version bump.

@markstos
Copy link
Contributor

I would argue throwing an error would be a breaking API change

In this case, it seems more like we would be fixing a "Garbage-In Garbage Out" bug. In what context would setting cert to an empty string even make sense? However, I was thinking of bumping the version to 1.0 very soon anyway.

Your refinements to the error message seem fine. For context, until recently we had 4 to 6 places in the code that returned the same "Invalid Signature" error, which was maddening to debug. Now all those places return unique error messages instead.

I don't want to optimize for developers are passing programmer-errors back to users. In my view, code that sets "cert" to empty string without validating it should not making to production.

Even if a developer is getting the 'cert' value dynamically, they have a responsibility to validate it and not blindly assuming it's OK.

@markstos markstos added breaking-change Not backwards compatible. Requires major version bump. 1.0 labels Oct 2, 2018
@andrsnn
Copy link
Contributor Author

andrsnn commented Oct 3, 2018

Got it. Sounds good I will move the validation to the initialize method. 👍

@cjbarth
Copy link
Collaborator

cjbarth commented Oct 15, 2018

@andrsnn I see this is the last outstanding PR that is tagged for our 1.0 release. Do you think you'll be able to clean it up so it can make that release?

@andrsnn
Copy link
Contributor Author

andrsnn commented Oct 19, 2018

@cjbarth Thank you for the reminder! I will look at wrapping up these changes this coming weekend.

@andrsnn
Copy link
Contributor Author

andrsnn commented Oct 23, 2018

@markstos @cjbarth Just pushed the above changes here. The above should also support an unsigned SAML Response with an unsigned Assertion, no signatures so no public key necessary. Any issues or comments let me know and I will address thanks!

@markstos
Copy link
Contributor

This has been merged locally: https://github.com/bergie/passport-saml/commits/master So, closing this issue. Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Not backwards compatible. Requires major version bump.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants