From 3fd905ea8f702f7dea5b4f0decfd5b37ee045bee Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sat, 29 Aug 2026 14:05:53 +0200 Subject: [PATCH] crypto: add strict mode to --force-fips 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 PR-URL: https://github.com/nodejs/node/pull/65645 Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel --- doc/api/cli.md | 19 ++- doc/api/crypto.md | 4 +- doc/api/diagnostics_channel.md | 9 +- doc/node.1 | 16 +- lib/internal/process/per_thread.js | 3 + src/crypto/crypto_util.cc | 19 ++- src/node.cc | 2 +- src/node_options.cc | 23 ++- src/node_options.h | 1 + .../test-crypto-fips-indicator-strict.js | 153 ++++++++++++++++++ test/parallel/test-crypto-fips.js | 42 ++++- 11 files changed, 278 insertions(+), 13 deletions(-) create mode 100644 test/parallel/test-crypto-fips-indicator-strict.js diff --git a/doc/api/cli.md b/doc/api/cli.md index adb299d095d..19ef5acc18c 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1580,15 +1580,32 @@ added: v12.12.0 Disable loading native addons that are not [context-aware][]. -### `--force-fips` +### `--force-fips[=mode]` Enable [FIPS mode][] at startup and prevent it from being disabled from script code. The same OpenSSL requirements as [`--enable-fips`][] apply. +An optional mode can be specified using `--force-fips=mode`: + +* `provider`: Preserve the OpenSSL FIPS provider's configured handling of + non-approved operations. This is the current default when the mode is + omitted. +* `strict`: Reject non-approved operations reported through the OpenSSL FIPS + indicator callback. This mode requires OpenSSL 3.4 or later. + +The `strict` mode only covers operations reported through the callback for +OpenSSL's default library context. It does not cover native addons that use +another `OSSL_LIB_CTX` or another copy of `libcrypto`, nor operation-specific +indicators that do not invoke the callback. + ### `--force-node-api-uncaught-exceptions-policy`