Skip to content

Conversation

@joyeecheung
Copy link
Member

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

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.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Nov 1, 2025
@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.54%. Comparing base (bdf03bf) to head (d23a10c).
⚠️ Report is 37 commits behind head on main.

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     
Files with missing lines Coverage Δ
src/crypto/crypto_timing.cc 100.00% <100.00%> (ø)

... and 114 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@ChALkeR ChALkeR left a 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

@ChALkeR
Copy link
Member

ChALkeR commented Nov 2, 2025

Does the fast path for timingSafeEqual give any measurable perf benefits over the slow/regular path though?

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 2, 2025
@joyeecheung
Copy link
Member Author

Does the fast path for timingSafeEqual give any measurable perf benefits over the slow/regular path though?

My guess is no, because of the handle scope overhead.

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 2, 2025
@nodejs-github-bot
Copy link
Collaborator

@RafaelGSS RafaelGSS added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 3, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 3, 2025
@nodejs-github-bot nodejs-github-bot merged commit c9578dc into nodejs:main Nov 3, 2025
83 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in c9578dc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

timingSafeEqual crashes the process when input is non-Buffer

5 participants