-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
src: fix FIPS init error handling #58379
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
Open
tniessen
wants to merge
1
commit into
nodejs:main
Choose a base branch
from
tniessen:cli-fix-fips-exit-code
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If `--enable-fips` or `--force-fips` fails to be applied during `ProcessFipsOptions()`, the node process might exit with `ExitCode::kNoFailure` because `ERR_GET_REASON(ERR_peek_error())` can return `0` since `ncrypto::testFipsEnabled()` does not populate the OpenSSL error queue. You can likely test this locally by running node --enable-fips && echo $? with the current `node` binary from the main branch if compiled without support for FIPS. As confirmed by the `XXX` comment here, which was added three years ago in commit b697160, even if the error queue was populated properly, the OpenSSL reason codes are not really related to the Node.js `ExitCode` enumeration.
Review requested:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #58379 +/- ##
==========================================
+ Coverage 90.23% 90.25% +0.01%
==========================================
Files 633 633
Lines 186871 186880 +9
Branches 36687 36687
==========================================
+ Hits 168626 168661 +35
+ Misses 11046 11025 -21
+ Partials 7199 7194 -5
🚀 New features to boost your workflow:
|
addaleax
approved these changes
May 18, 2025
anonrig
approved these changes
May 19, 2025
jasnell
approved these changes
May 19, 2025
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Only CI faiure is due to #58353. |
richardlau
approved these changes
May 19, 2025
This comment was marked as outdated.
This comment was marked as outdated.
lpinca
approved these changes
May 19, 2025
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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++.
needs-ci
PRs that need a full CI run.
openssl
Issues and PRs related to the OpenSSL dependency.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If
--enable-fips
or--force-fips
fails to be applied duringProcessFipsOptions()
, the node process might exit withExitCode::kNoFailure
becauseERR_GET_REASON(ERR_peek_error())
can return0
sincencrypto::testFipsEnabled()
does not populate the OpenSSL error queue.This is problematic because an exit code of
0
(i.e.,kNoFailure
) indicates successful execution of thenode
command, even though it already failed during initialization. (Error messages also appear to be broken, but fixing that is not as urgent as not pretending that the command succeeded.)For example, if a user invokes
node
from within a bash script andNODE_OPTIONS
includes--force-fips
, the execution of the command will appear to have succeeded even if the actual user script was never executed due to a configuration error.You can likely test this locally by running
with the current
node
binary from the main branch if compiled without support for FIPS.As confirmed by the
XXX
comment here, which was added three years ago in commit b697160, even if the error queue was populated properly, the OpenSSL reason codes are not really related to the Node.jsExitCode
enumeration.This commit changes the initialization logic to exit with
kGenericUserError
in this case, since such errors are most likely due to incorrect configuration. It also modifies the existing test case to actually check the exit code of the process, which would have prevented this recent regression.Considering that the current behavior is incorrect, I'd prefer to merge this as a bugfix rather than a semver-major change.