Fenrir fixes - WolfSSLKeyStore, WolfCryptPKIXCertPathValidator#238
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the WKS KeyStore load path against malformed inputs (allocation bounding + integrity-ordering) to address Fenrir findings, and fixes a correctness issue in the FIPS signature-provider check in WolfCryptPKIXCertPathValidator, without introducing public API changes (aside from one new optional Security property).
Changes:
- Add
wolfjce.wks.maxEntrySizeand enforce encoded-entry/inner-field length bounds during WKS load/decoding. - Parse WKS entries into a temporary map and only commit them after the HMAC integrity check succeeds.
- Add regression tests for malformed WKS streams and update docs/JNI constants accordingly; fix String value-equality in FIPS signature provider check.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/wolfssl/provider/jce/test/WolfSSLKeyStoreTest.java | Adds regression tests for malformed WKS streams and integrity-ordering behavior. |
| src/main/java/com/wolfssl/provider/jce/WolfSSLKeyStore.java | Implements entry-size bounds, integrity-ordering (commit-after-HMAC), and per-entry decoder allocation limits. |
| src/main/java/com/wolfssl/provider/jce/WolfCryptPKIXCertPathValidator.java | Fixes FIPS signature-provider check to use value equality. |
| README_JCE.md | Documents the new wolfjce.wks.maxEntrySize Security property. |
| jni/include/com_wolfssl_provider_jce_WolfSSLKeyStore.h | Updates generated constant for default max entry size. |
| docs/design/WolfSSLKeyStore.md | Documents the new wolfjce.wks.maxEntrySize Security property in design notes. |
Files not reviewed (1)
- jni/include/com_wolfssl_provider_jce_WolfSSLKeyStore.h: Generated file
Comments suppressed due to low confidence (2)
src/main/java/com/wolfssl/provider/jce/WolfSSLKeyStore.java:2435
DataInputStream.read(byte[])is not guaranteed to fill the buffer in one call, so this can spuriously fail (or behave inconsistently across InputStream types). UsereadFully()to reliably read the entire encoded entry or throw EOFException.
encodedEntry = new byte[encodedLen];
bytesRead = dis.read(encodedEntry);
if (bytesRead != encodedLen) {
throw new IOException(
"Unable to read total encoded entry byte array");
}
src/main/java/com/wolfssl/provider/jce/WolfSSLKeyStore.java:2499
- Same issue as above:
DataInputStream.read(byte[])is not guaranteed to read the full HMAC in one call. UsereadFully()to avoid short-read false failures on non-buffered streams.
hmac = new byte[hmacLen];
hmacLen = dis.read(hmac);
if (hmacLen != hmac.length) {
throw new IOException(
"Failed to read entire HMAC from WKS stream");
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
300066c to
76d6c89
Compare
76d6c89 to
b1496e6
Compare
rlm2002
approved these changes
Jul 9, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR resolves a batch of 8 findings from Fenrir. Changes are DoS hardening, input validation, integrity ordering, and a correctness fix. No public API changes. One new optional Security property,
wolfjce.wks.maxEntrySize, is added to bound WKS KeyStore load allocations.Changes
KeyStore load input validation and allocation bounds
engineLoad()engineLoad()KeyStore integrity ordering
engineLoad()FIPS provider check consistency
WolfCryptPKIXCertPathValidator.engineValidate()