Skip to content

Different approach on fixing issue of pull request #69 #74

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SamDecrock
Copy link
Contributor

Hi,

This is my take at fixing the issue of pull request #69
I'm solving this by doing a signature verification of the complete response (a so called enveloped signature) at the very beginning (before decrypting anything). If that succeeds, it means that the complete document (except for the signature itself off course) is verified.

I then continue with the rest but without checking for signatures anymore.

@allenelks
Copy link

+1

@cozmo
Copy link
Contributor

cozmo commented Aug 30, 2016

Hey @SamDecrock thanks for the PR. This is an interesting approach and seems valid to me, but I'd love to get another pair of eyes on it tomorrow before calling it good to go. Meanwhile - would be great to add a test for this behavior.

Look forward to getting this merged.

if !ignore_signature
for cert in idp_certificates or []
signed_data_from_complete_saml_response = check_saml_signature(saml_response.toString(), cert)
if signed_data_from_complete_saml_response.length is 1 and signed_data_from_complete_saml_response[0] == saml_response.toString()
Copy link
Contributor

Choose a reason for hiding this comment

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

When there are multiple Signature nodes in the response, this throws

TypeError: Cannot read property 'length' of null
    at parse_authn_response (/Users/mdolan/Repos/saml-test/node_modules/saml2-js/lib-js/saml2.js:603:50)

(because check_saml_signature returns null https://github.com/Clever/saml2/blob/master/lib/saml2.coffee#L178)

Maybe just need this to be signed_data_from_complete_saml_response?.length is 1?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link

Choose a reason for hiding this comment

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

Also, is there a reason for the string comparison? There are slight differences in ordering of the fields for me

@sylido
Copy link

sylido commented Aug 2, 2017

Any plans on merging this solution ? I think I am affected by this bug as well, will be happy to make a new PR with the fix @mgduk commented about.

sylido added a commit to sylido/saml2 that referenced this pull request Aug 2, 2017
Clever#74

Also added an extra ? before checking the length of the signed_data_from_complete_saml_response, as per @mgduk's comment.
@mohit mohit requested a review from cozmo August 7, 2017 08:06
@cozmo
Copy link
Contributor

cozmo commented Aug 7, 2017

@sylido @SamDecrock I think the comments thus far

  1. Handling the case where check_saml_signature returns null
  2. Adding a test (or several) for this behavior

are (still) blockers on this PR. Not sure what @SamDecrock's plans are but if @sylido wants to take the reins on this - sounds good to me.

In general would be happy to merge this, but not if there are bugs (which it seems like there currently are). Feel like tests would be the best way to catch bugs like that.

Let me know how this sounds.

@cozmo cozmo assigned SamDecrock and unassigned cozmo Aug 7, 2017
@jrdoane
Copy link

jrdoane commented Jun 5, 2018

Is there any reason why this PR is still open and awaiting review? This should solve an issue I'm having trying to use this library since it appears that the enveloped XML signature is being ignored and is only checking signatures contained within each assertion.

@nkumarcc
Copy link

nkumarcc commented Jun 8, 2019

Has this been updated at all? I'm facing a similar issue now and this seems to be the best provided fix

@sylido
Copy link

sylido commented Jun 11, 2019

@nkumarcc I think @cozmo outlined the issues surrounding this, I tried making some tests to see if we can solidify the behavior but I falied at it - if any of you is willing to give it a try, they might merge it. I've been using this PR in my fork for quite a while now and haven't encountered a problem yet, but that's not necessarily true for all SAML cases.

@nkumarcc
Copy link

Hmmm @sylido I'd be down to figure it out, but I actually face an issue with the code as is.

However, for this line:
if signed_data_from_complete_saml_response.length is 1 and signed_data_from_complete_saml_response[0] == saml_response.toString()

The signed_data_from_complete_saml_response[0] == saml_response.toString() doesn't come exactly correct, I think the fields are just reordered

@sylido
Copy link

sylido commented Jun 13, 2019

@nkumarcc I made a change that @mgduk mentioned in one of his comments here. I have some other fixes on my fork that might make it work for you, try it if you can and maybe fork it yourself until we can add tests that actually work this might be the best option for now.

@nkumarcc
Copy link

nkumarcc commented Jul 2, 2019

@sylido honestly, that's what I did and it works properly (and I think it makes sense)

@SamDecrock
Copy link
Contributor Author

Hi,

It's been 3 years since I posted this fix. I'm not working on my saml related project anymore, so I cannot help you guys with the merge. If someone wants to take it up, feel free.

Sam

@nkumarcc
Copy link

nkumarcc commented Jul 6, 2019

@SamDecrock can you add me as contributor? Unsure if I can contribute right away, but some of these PR's have come in handy in my private branch. Would love to help merge them in at some point down the line

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.

7 participants