Skip to content

crypto: add FIPS indicator diagnostics and strict mode - #65645

Open
panva wants to merge 5 commits into
nodejs:mainfrom
panva:crypto-fips-indicator-callback
Open

crypto: add FIPS indicator diagnostics and strict mode#65645
panva wants to merge 5 commits into
nodejs:mainfrom
panva:crypto-fips-indicator-callback

Conversation

@panva

@panva panva commented Aug 29, 2026

Copy link
Copy Markdown
Member

OpenSSL FIPS providers can be configured to permit operations that are not FIPS approved, but Node.js currently gives users neither visibility into when this occurs nor a way to reject those operations when they cannot control the provider configuration.

FIPS indicator callback makes both possible, giving us opt-in diagnostics for observability and a strict --force-fips mode for runtime enforcement without changing existing defaults or adding callback overhead unless requested.

This adds --enable-fips-indicator-events, which installs the callback during startup and publishes best-effort events on the crypto.fips.indicator diagnostics channel.

This also extends --force-fips with optional provider and strict modes (suggest better names if you want?). provider preserves the FIPS provider's configured handling of non-approved operations and remains the default, including for the bare --force-fips form. strict rejects non-approved operations reported through the indicator callback, independently of whether diagnostics are enabled.

OpenSSL 3.4 added an indicator callback for operations that its FIPS
provider allows after an approved-mode check has been relaxed.

Publish these indicators on the crypto.fips.indicator diagnostics
channel when Node.js is started with --enable-fips-indicator-events.
Leave the OpenSSL callback unset otherwise so ordinary cryptographic
operations have no indicator callback overhead.

Keep the channel observation-only so enforcement remains the
responsibility of the provider configuration, and independent diagnostic
subscribers can coexist.

Install the native callback during process initialization so it is not
changed while Workers or thread-pool jobs can be using OpenSSL. Preserve
callbacks installed by embedders, and queue bounded, coalesced messages
for asynchronous delivery on the main environment.

Document the channel as best-effort telemetry that cannot identify the
originating call or establish FIPS validation.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva added the commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. label Aug 29, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/crypto
  • @nodejs/startup

@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 involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Aug 29, 2026
Allow --force-fips to take an optional provider or strict mode. Keep
provider as the current default and explicit compatibility mode.

In strict mode, return failure from the OpenSSL 3.4+ FIPS indicator
callback when it reports a non-approved operation. Install the callback
for enforcement without implicitly enabling diagnostics;
--enable-fips-indicator-events remains the independent observation
opt-in.

Keep the bare form mapped to provider for compatibility, allowing the
default to change to strict in a future major release. Preserve the mode
when forwarding flags to child test processes, and keep the parser's
internal mode storage out of process.allowedNodeEnvironmentFlags.

Document the callback scope limitations and cover provider
compatibility, validation, synchronous crypto, WebCrypto, Workers, and
opt-in event publication.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva
panva force-pushed the crypto-fips-indicator-callback branch from e261a5c to 3826393 Compare August 29, 2026 12:21
@panva
panva requested a review from jasnell August 29, 2026 12:27
@panva
panva requested a review from richardlau August 29, 2026 13:02
@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.90674% with 143 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.00%. Comparing base (2f469df) to head (e3ba181).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_util.cc 17.26% 136 Missing and 3 partials ⚠️
src/node_options.cc 75.00% 2 Missing and 1 partial ⚠️
lib/internal/process/pre_execution.js 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65645      +/-   ##
==========================================
- Coverage   90.04%   90.00%   -0.05%     
==========================================
  Files         754      754              
  Lines      255722   255913     +191     
  Branches    48312    48357      +45     
==========================================
+ Hits       230274   230335      +61     
- Misses      16553    16693     +140     
+ Partials     8895     8885      -10     
Files with missing lines Coverage Δ
lib/internal/process/per_thread.js 99.46% <100.00%> (-0.36%) ⬇️
src/crypto/crypto_util.h 66.47% <ø> (ø)
src/node.cc 76.58% <100.00%> (+0.03%) ⬆️
src/node_options.h 95.41% <100.00%> (+0.04%) ⬆️
lib/internal/process/pre_execution.js 97.03% <85.71%> (-0.70%) ⬇️
src/node_options.cc 79.57% <75.00%> (+0.03%) ⬆️
src/crypto/crypto_util.cc 54.16% <17.26%> (-11.24%) ⬇️

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

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

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants