-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
crypto: fix argument validation in crypto.timingSafeEqual fast path #60538
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
Conversation
A regression introduced by nodejs@0136bb0 made it possible for the fast path to be hit with non-array-buffer arguments despite that the fast paths could only deal with array buffer arguments, so that it can crash with invalid arguments once crypto.timingSafeEqual is optimized instead of throwing validation errors as usual. This adds validation to the fast path so that it throws correctly.
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60538 +/- ##
==========================================
+ Coverage 88.05% 88.54% +0.49%
==========================================
Files 704 704
Lines 207857 207847 -10
Branches 39964 40039 +75
==========================================
+ Hits 183030 184045 +1015
+ Misses 16806 15837 -969
+ Partials 8021 7965 -56
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but don't trust me on this, collect more reviews
Test also looks good and consistently reproduces the issue on the released versions
|
Does the fast path for |
My guess is no, because of the handle scope overhead. |
|
Landed in c9578dc |
A regression introduced by
0136bb0 made it possible for the fast path to be hit with non-array-buffer arguments despite that the fast paths could only deal with array buffer arguments, so that it can crash with invalid arguments once crypto.timingSafeEqual is optimized instead of throwing validation errors as usual. This adds validation to the fast path so that it throws correctly.
Originally opened in the private repo to stay on the safe side, moving it to public since there's consensus that this is a regular bug, not a vulnerability.
Refs: https://github.com/nodejs-private/node-private/pull/749
Fixes: #60537