| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
getCiphers() and getHashes() used cachedResult() which memoizes once and never clears. setFips() changes which algorithms OpenSSL exposes (FIPS-approved only vs. all), and setEngine() can register additional ciphers/hashes from a loaded engine, but neither invalidated the cache. Replace the two cachedResult() calls with manual cache variables (_ciphersCache, _hashesCache) that mirror the existing _hashCache pattern. Add evictCipherHashCache() and call it from both setFips() and setEngine() after they mutate OpenSSL state. getCurves is intentionally left using cachedResult — curves are not affected by FIPS mode or engine loading. Fixes: nodejs#62982
|
Review requested:
|
Sorry, something went wrong.
|
@srikanth-karthi thank you, this looks good on first a cursory look but can you add a test? we do have fips enabled runners in CI that could use one. |
Sorry, something went wrong.
|
As #62982 details mention: under BoringSSL, internal code in conditionalAlgorithms calls getHashes and getCiphers at load. node/lib/internal/crypto/util.js Lines 405 to 410 in bb85d23 Those results are also stale |
Sorry, something went wrong.
|
BoringSSL has no fips mode. And when it's not boringssl and the ciphers "become unavailable" due to a toggle switch they'll start failing with OperationError and the only inconsistency will be SubtleCrypto.supports reporting true when it should be false. The "fips to non-fips" case 🤷 Imho not worth the churn. |
Sorry, something went wrong.
|
Thanks for the context. Agreed — under BoringSSL there's no FIPS mode so conditionalAlgorithms is stable for the process lifetime, and for OpenSSL the SubtleCrypto.supports() inconsistency after a FIPS toggle is an accepted limitation given the churn required to fix it. I'll leave conditionalAlgorithms out of scope for this PR. |
Sorry, something went wrong.
|
@ChALkeR what do you think about keeping the identity of the cached result the same? that way consumer can actually rely on their returned value and not get tripped up by someone elses' concern flipping fips mode. |
Sorry, something went wrong.
Add a FIPS-only regression test for nodejs#62982 that confirms getCiphers() and getHashes() reflect the restricted FIPS algorithm set after setFips(true) and restore the full list after setFips(false). Signed-off-by: srikanth-karthi <srikanthkarthi2003@gmail.com>
Capture initialFips state and explicitly disable FIPS before recording the baseline algorithm lists, so the test works correctly on systems where FIPS is enabled by default. Restore the original state on exit. Signed-off-by: srikanth-karthi <srikanthkarthi2003@gmail.com>
Each test runs in its own process so restoring the initial FIPS state is unnecessary. Signed-off-by: srikanth-karthi <srikanthkarthi2003@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #62985 +/- ##
=======================================
Coverage 89.66% 89.66%
=======================================
Files 707 707
Lines 219501 219523 +22
Branches 42087 42092 +5
=======================================
+ Hits 196807 196832 +25
Misses 14588 14588
+ Partials 8106 8103 -3
... and 28 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
|
This pull request has been marked as stale due to 90 days of inactivity. |
Sorry, something went wrong.
|
setFips() invalidation is superseded by #65484, I don't believe dealing with setEngine()-triggered invalidation is worth the churn since engines are on the way out of the codebase (#63966, #64777 (comment)). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes: #62982
Summary
getCiphers() and getHashes() used cachedResult() which memoizes on first call and never clears. Two operations mutate the OpenSSL algorithm set but did not invalidate the cache:
This meant that after calling either function, getCiphers() and getHashes() would continue returning the stale pre-call snapshot.
Changes