Disallow matching URI type in CheckForAltNames. NULL *response on error in wolfSSL_d2i_OCSP_RESPONSE.#10509
Open
kareem-wolfssl wants to merge 3 commits into
Open
Disallow matching URI type in CheckForAltNames. NULL *response on error in wolfSSL_d2i_OCSP_RESPONSE.#10509kareem-wolfssl wants to merge 3 commits into
kareem-wolfssl wants to merge 3 commits into
Conversation
Thanks to Haruki Oyama (Waseda University) for the report.
Thanks to Zou Dikai for the report.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses two certificate/OCSP edge cases: (1) TLS hostname matching should not treat URI SANs as DNSName SANs, and (2) wolfSSL_d2i_OCSP_RESPONSE() should NULL out a caller-supplied *response on failure to avoid leaving a dangling pointer.
Changes:
- Update
CheckForAltNames()to skipuniformResourceIdentifierSANs when performing DNS hostname checks. - Update
wolfSSL_d2i_OCSP_RESPONSE()error paths to clear*responsewhen the caller passed a reusable response pointer. - Add regression tests covering URI SAN hostname-matching behavior and OCSP response reuse failure semantics.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
wolfcrypt/src/asn.c |
Updates in-code documentation clarifying URI SAN handling vs CN fallback behavior. |
src/internal.c |
Skips URI SAN entries during DNS hostname matching in CheckForAltNames(). |
src/ocsp.c |
Clears caller’s *response on allocation/decode failures in wolfSSL_d2i_OCSP_RESPONSE(). |
tests/api/test_ocsp.c |
Adds a test to ensure *response is NULLed on reuse + decode failure. |
tests/api/test_certman.h |
Registers a new certman API test. |
tests/api/test_certman.c |
Adds a test ensuring URI SANs don’t satisfy DNS hostname checks (and validates behavior when DNS SAN is also present). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
1276
to
1292
| if (response != NULL) | ||
| resp = *response; | ||
| if (resp == NULL) { | ||
| resp = (OcspResponse*)XMALLOC(sizeof(OcspResponse), NULL, | ||
| DYNAMIC_TYPE_OCSP_REQUEST); | ||
| if (resp == NULL) | ||
| return NULL; | ||
| XMEMSET(resp, 0, sizeof(OcspResponse)); | ||
| } | ||
|
|
||
| resp->source = (byte*)XMALLOC((size_t)len, NULL, DYNAMIC_TYPE_TMP_BUFFER); | ||
| if (resp->source == NULL) { | ||
| XFREE(resp, NULL, DYNAMIC_TYPE_OCSP_REQUEST); | ||
| if (response != NULL && *response == resp) | ||
| *response = NULL; | ||
| return NULL; | ||
| } |
|
The changes look good. Thank you for the prompt response. |
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.
Description
Fixes zd#21863, zd#21865
Testing
Built in tests, provided reproducers
Checklist