Skip to content

crypto: fix Argon2 FIPS bypass and KDF error loss - #64776

Closed
panva wants to merge 2 commits into
nodejs:mainfrom
panva:kdf-errors
Closed

crypto: fix Argon2 FIPS bypass and KDF error loss#64776
panva wants to merge 2 commits into
nodejs:mainfrom
panva:kdf-errors

Conversation

@panva

@panva panva commented Jul 27, 2026

Copy link
Copy Markdown
Member

Argon2 ran its KDF in a private OSSL_LIB_CTX, which inherits no configuration, so it
worked in FIPS mode while every other non-approved algorithm was refused. Availability is
now checked against the default context.

The KDF helpers also cleared the OpenSSL error queue on return, leaving Argon2, HKDF,
PBKDF2 and scrypt failures as bare Errors with no code or opensslErrorStack.

panva added 2 commits July 27, 2026 11:54
The private OSSL_LIB_CTX used for OSSL_set_max_threads() inherits no
configuration, so Argon2 escaped FIPS mode and --openssl-config.

Check availability against the default context, and create the private
one only when lanes > 1.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
The ncrypto KDF helpers cleared the OpenSSL error queue on return, and
the traits insert their own message, which makes DeriveBitsJob skip
errors->Capture(). Argon2, HKDF, PBKDF2 and scrypt failures were
therefore bare Errors with no code and no opensslErrorStack.

Drop the guard, which DeriveBitsJob already provides, and capture
before inserting since Capture() clears the store.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva
panva requested review from anonrig and jasnell July 27, 2026 09:59
@panva panva added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label Jul 27, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jul 27, 2026
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.15%. Comparing base (54a5095) to head (a075357).
⚠️ Report is 99 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_scrypt.cc 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #64776   +/-   ##
=======================================
  Coverage   90.14%   90.15%           
=======================================
  Files         744      744           
  Lines      242518   242522    +4     
  Branches    45685    45698   +13     
=======================================
+ Hits       218611   218634   +23     
- Misses      15396    15402    +6     
+ Partials     8511     8486   -25     
Files with missing lines Coverage Δ
src/crypto/crypto_argon2.cc 65.38% <100.00%> (+0.33%) ⬆️
src/crypto/crypto_hkdf.cc 66.66% <100.00%> (+0.40%) ⬆️
src/crypto/crypto_pbkdf2.cc 67.10% <100.00%> (+0.43%) ⬆️
src/crypto/crypto_scrypt.cc 72.83% <0.00%> (-0.92%) ⬇️

... and 37 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.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 29, 2026
@bricss

bricss commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Any ETA when this PR might land? 🙂

@panva

panva commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Any ETA when this PR might land? 🙂

When the time gate for the given number of collaborator approvals passes.

@panva panva added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 3, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in e0e37fe...a937758

nodejs-github-bot pushed a commit that referenced this pull request Aug 3, 2026
The private OSSL_LIB_CTX used for OSSL_set_max_threads() inherits no
configuration, so Argon2 escaped FIPS mode and --openssl-config.

Check availability against the default context, and create the private
one only when lanes > 1.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
nodejs-github-bot pushed a commit that referenced this pull request Aug 3, 2026
The ncrypto KDF helpers cleared the OpenSSL error queue on return, and
the traits insert their own message, which makes DeriveBitsJob skip
errors->Capture(). Argon2, HKDF, PBKDF2 and scrypt failures were
therefore bare Errors with no code and no opensslErrorStack.

Drop the guard, which DeriveBitsJob already provides, and capture
before inserting since Capture() clears the store.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
@panva
panva deleted the kdf-errors branch August 3, 2026 11:47
aduh95 pushed a commit that referenced this pull request Aug 3, 2026
The private OSSL_LIB_CTX used for OSSL_set_max_threads() inherits no
configuration, so Argon2 escaped FIPS mode and --openssl-config.

Check availability against the default context, and create the private
one only when lanes > 1.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 3, 2026
The ncrypto KDF helpers cleared the OpenSSL error queue on return, and
the traits insert their own message, which makes DeriveBitsJob skip
errors->Capture(). Argon2, HKDF, PBKDF2 and scrypt failures were
therefore bare Errors with no code and no opensslErrorStack.

Drop the guard, which DeriveBitsJob already provides, and capture
before inserting since Capture() clears the store.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
The private OSSL_LIB_CTX used for OSSL_set_max_threads() inherits no
configuration, so Argon2 escaped FIPS mode and --openssl-config.

Check availability against the default context, and create the private
one only when lanes > 1.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
The ncrypto KDF helpers cleared the OpenSSL error queue on return, and
the traits insert their own message, which makes DeriveBitsJob skip
errors->Capture(). Argon2, HKDF, PBKDF2 and scrypt failures were
therefore bare Errors with no code and no opensslErrorStack.

Drop the guard, which DeriveBitsJob already provides, and capture
before inserting since Capture() clears the store.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
The private OSSL_LIB_CTX used for OSSL_set_max_threads() inherits no
configuration, so Argon2 escaped FIPS mode and --openssl-config.

Check availability against the default context, and create the private
one only when lanes > 1.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
The ncrypto KDF helpers cleared the OpenSSL error queue on return, and
the traits insert their own message, which makes DeriveBitsJob skip
errors->Capture(). Argon2, HKDF, PBKDF2 and scrypt failures were
therefore bare Errors with no code and no opensslErrorStack.

Drop the guard, which DeriveBitsJob already provides, and capture
before inserting since Capture() clears the store.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #64776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
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++. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants