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

Remove cryptiles dependency #102

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

Conversation

david-nossebro
Copy link

Since Cryptiles contains a security issue mentioned here hapijs/cryptiles#34 I have removed the dependency.

This solves the issue #101 I reported.

}
catch (err) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a good idea to propagate this error?

Copy link

@MarcinHoppe MarcinHoppe left a comment

Choose a reason for hiding this comment

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

LGTM with a minor comment.

return cryptiles.fixedTimeComparison(audience[0].textContent, realm);

try {
return crypto.timingSafeEqual(Buffer.from(audience[0].textContent), Buffer.from(realm));

Choose a reason for hiding this comment

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

While this change is benign (cryptiles code is inlined here), the calling code should check if compared buffers have the same length. Lack of this validation by the caller results in an exception being thrown.

While use of timingSafeEqual is admirable, I don't see how this might be used as an oracle, and I think a simple string comparison would be just as good.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, so first you want a length check on ´audience[0].textContent´ and ´realm´ and then you want to replace the ´timingSafeEqual´ with a simple ´===´ comparison. Is this correct?

@david-nossebro
Copy link
Author

@CalRobert, @MarcinHoppe: I saw that the only thing 'Cryptiles' was doing was to wrap the 'timingSafeEqual' method, so what I did was just to move the wrapped method into our library. While I agree with you I did not want to complicate this more than necessary.

The functionality should be the exact same as before.

@gkwang
Copy link
Contributor

gkwang commented Oct 18, 2018

@david-nossebro While I'm with Marcin on this one where timingSafeEqual is overkill, I'm ok with this change going out as it seems to be backwards compatible with the current implementation and getting the ball rolling.

My reasoning behind this being overkill is that we're not encapsulating all checks into a single timing-safe timeframe so this single check being timingsafe does not provide any useful purpose.

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.

None yet

4 participants