defense in depth hardening for x509 extension create by OBJ and EVP decode update#10706
Open
JacobBarthelmeh wants to merge 2 commits into
Open
defense in depth hardening for x509 extension create by OBJ and EVP decode update#10706JacobBarthelmeh wants to merge 2 commits into
JacobBarthelmeh wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds defensive hardening to OpenSSL-compat APIs by preventing negative-length input in base64 decode and by eliminating a use-after-free hazard when reusing an X509 extension’s own ASN1 object during extension recreation.
Changes:
- Reject negative
inlinwolfSSL_EVP_DecodeUpdate()to avoid length underflow/casts. - In
wolfSSL_X509_EXTENSION_create_by_OBJ(), duplicate the source ASN1 object before freeing any existing object to prevent alias-driven UAF. - Add API tests covering both the negative-length decode case and the self-object reuse case for X509 extension creation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
wolfcrypt/src/evp.c |
Adds inl < 0 validation to harden EVP base64 decode update. |
src/x509.c |
Duplicates extension object earlier to prevent freed-memory reads when caller passes ex’s own object. |
tests/api/test_ossl_x509_ext.c |
Adds regression test for extension recreation using its own object pointer. |
tests/api/test_evp.c |
Adds regression test ensuring negative inl is rejected and outl is cleared. |
💡 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.
ZD21992