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

Add nonce callback function to options. #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hugeice
Copy link

@hugeice hugeice commented Jan 22, 2016

Add a callback function to the options, so that the user can control the nonce field in challenge and perform additional validation for the nonce, thereby preventing replay attacks.

@jaredhanson
Copy link
Owner

The nonce is passed to the validate callback. Is that not sufficient for detecting replay attacks?

@hugeice
Copy link
Author

hugeice commented Jan 23, 2016

Sorry, I did not express clearly.

1,
The Digest scheme is based on a simple challenge-response paradigm. The Digest scheme challenges using a nonce value.
However, in current implementation of passport-http, the nonce value in challenge has not been saved.
Therefore, we can not know whether the authentication request corresponds to the challenge we sent before, which may not conform to the challenge-response paradigm.
Of course, if the digest values match the nonce, it indicates that the client knowns user password or HA1 value, which may not cause any security issues.

2,
Although you can check the nonce in validate callback.
However, to prevent replay attacks, the server must save all used nonce values to detect any repeated/reused nonce value.
This is more complex, and with time gose by there will be more and more nonce values which may take too many resources in server side.
As an alternative, if we allow the user to generate nonce value, users will have more choices to achieve additional checks, even without relying on the saved nonce values.
For example: user can generate a nonce with server timestamp using some algorithm, and retrieve the server timestamp from the nonce value received from client. Then user can further checks whether the timestamp is within the allowable range.
Similarly, the client IP address can be also added to the nonce generation algorithm.
Reference: RFC2617 "4.5 Replay Attacks"

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.

2 participants