Skip to content

Disallow matching URI type in CheckForAltNames. NULL *response on error in wolfSSL_d2i_OCSP_RESPONSE.#10509

Open
kareem-wolfssl wants to merge 4 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd21863_5
Open

Disallow matching URI type in CheckForAltNames. NULL *response on error in wolfSSL_d2i_OCSP_RESPONSE.#10509
kareem-wolfssl wants to merge 4 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd21863_5

Conversation

@kareem-wolfssl
Copy link
Copy Markdown
Contributor

Description

Fixes zd#21863, zd#21865

Testing

Built in tests, provided reproducers

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@kareem-wolfssl kareem-wolfssl self-assigned this May 20, 2026
Copilot AI review requested due to automatic review settings May 20, 2026 23:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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 skip uniformResourceIdentifier SANs when performing DNS hostname checks.
  • Update wolfSSL_d2i_OCSP_RESPONSE() error paths to clear *response when 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 thread src/ocsp.c Outdated
Comment on lines 1276 to 1292
if (response != NULL && *response == resp)
*response = NULL;
return NULL;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kareem-wolfssl this might be right. Using a unified exit could help clean this up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This should have been fixed in c54e0f3 with the calls to wolfSSL_OCSP_RESPONSE_free.
Unified exit added in the most recent commit.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

MemBrowse Memory Report

No memory changes detected for:

@haruki0409
Copy link
Copy Markdown

The changes look good. Thank you for the prompt response.

Comment thread src/internal.c Outdated
continue;
}

/* RFC 6125 Sec. 6.4 / RFC 9525 Sec. 6.3: a DNS-ID reference
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

RFC 6125 is obsoleted by RFC 9525. No point referencing out of date specs.

Comment thread src/ocsp.c Outdated
Comment on lines 1286 to 1329
@@ -1315,6 +1324,8 @@ OcspResponse* wolfSSL_d2i_OCSP_RESPONSE(OcspResponse** response,
/* for just converting from a DER to an internal structure the CA may
* not yet be known to this function for signature verification */
wolfSSL_OCSP_RESPONSE_free(resp);
if (response != NULL && *response == resp)
*response = NULL;
return NULL;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is getting really messy. Please refactor it into a single section and goto on error.

Comment thread wolfcrypt/src/asn.c Outdated
Comment on lines +18673 to +18676
* - CheckForAltNames (TLS hostname matching): skips ASN_URI_TYPE
* for DNS hostname checks (RFC 6125 Sec. 6.4 / RFC 9525 Sec. 6.3)
* but URI SAN presence still suppresses CN fallback (RFC 6125
* Sec. 6.4.4) because URI-ID is a distinct presented identifier.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

outdated rfc refs

Thanks to Haruki Oyama (Waseda University) for the report.
Thanks to Zou Dikai for the report.
Remove outdated RFC, refactor into single error case, guard against negative/0 len and NULL *data pointer, don't set ownStatus until status is confirmed non-NULL.
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.

5 participants