-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
base: main
Are you sure you want to change the base?
Conversation
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:
|
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. |
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.
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.
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.