Skip to content

defense in depth hardening for x509 extension create by OBJ and EVP decode update#10706

Open
JacobBarthelmeh wants to merge 2 commits into
wolfSSL:masterfrom
JacobBarthelmeh:dev
Open

defense in depth hardening for x509 extension create by OBJ and EVP decode update#10706
JacobBarthelmeh wants to merge 2 commits into
wolfSSL:masterfrom
JacobBarthelmeh:dev

Conversation

@JacobBarthelmeh

Copy link
Copy Markdown
Contributor

ZD21992

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 inl in wolfSSL_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.

Comment thread tests/api/test_ossl_x509_ext.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants