Fenrir#439
Open
jackctj117 wants to merge 7 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens wolfHSM’s security posture across authentication and key/NVM handling by introducing constant-time credential checks, stricter sensitive-memory scrubbing, and more explicit enforcement/testing of NVM access/usage policies.
Changes:
- Add constant-time credential comparison helper and update authentication checks to enforce exact-length matches.
- Enforce fail-closed behavior for
WH_NVM_ACCESS_NONEobjects and standardize default access for several SHE-related keys/objects. - Expand tests for SHE LOAD KEY integrity, NVM access policy enforcement, and Curve25519 usage-flag enforcement.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/wh_auth_base.c |
Introduces constant-time credential comparison helper and updates credential checks. |
test/wh_test_auth.c |
Adds regression tests ensuring wrong-length credentials are rejected. |
src/wh_nvm.c |
Adds fail-closed policy enforcement for WH_NVM_ACCESS_NONE. |
test/wh_test_nvmflags.c |
Adds tests verifying WH_NVM_ACCESS_NONE denies read/overwrite/destroy. |
src/wh_server_she.c |
Standardizes SHE object metadata defaults (notably meta->access). |
src/wh_client_she.c |
Aligns SHE pre-program key creation with new NVM access policy expectations. |
test/wh_test_she.c |
Adds test ensuring corrupted M3 is rejected without mutating slot state. |
test/wh_test_crypto.c |
Adds Curve25519/X25519 test verifying DERIVE usage enforcement. |
port/posix/posix_transport_shm.c |
Adds explicit scrubbing of temporary DMA buffers before free. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 pull request introduces several important security and correctness improvements across authentication, memory handling, and key usage policy enforcement, along with new and enhanced test coverage. The most significant changes are the implementation of constant-time credential comparison to prevent timing attacks, stricter memory scrubbing for sensitive data, and improved enforcement and testing of key access and usage policies.
Authentication Security Improvements:
wh_Auth_BaseCredsComparefunction for constant-time credential comparison, ensuring both value and length are checked without leaking timing information. Updated all PIN and credential checks to use this function instead of direct comparison, preventing timing attacks and enforcing exact-length credential matching. [1] [2] [3]Sensitive Data Handling:
Key Access and Usage Policy Enforcement:
WH_NVM_ACCESS_NONEdeny read, overwrite, and destroy operations, ensuring a fail-closed security posture for no-access objects.meta->access = WH_NVM_ACCESS_ANYfor SHe keys and PRNG seeds, clarifying and standardizing key access defaults. [1] [2] [3] [4]wh_Client_ShePreProgramKeyto useWH_NVM_ACCESS_ANYwhen adding new objects, aligning with the new access policy.Test Coverage Enhancements:
WH_NVM_ACCESS_NONEcannot be read, overwritten, or destroyed, and that these restrictions are enforced even without additional flags. [1] [2] [3]These changes collectively improve the security, correctness, and testability of authentication, key management, and memory handling in the codebase.