asn.c: check the OCSP responder certificate's signature - #11195
Open
holtrop-wolfssl wants to merge 1 commit into
Open
asn.c: check the OCSP responder certificate's signature#11195holtrop-wolfssl wants to merge 1 commit into
holtrop-wolfssl wants to merge 1 commit into
Conversation
The VERIFY_OCSP_CERT -> VERIFY/VERIFY_OCSP mapping lived only in the non-template ASN.1 path, so in the default WOLFSSL_ASN_TEMPLATE build the mode reached the ConfirmSignature() gate unmatched and the responder certificate embedded in an OCSP response was accepted without its signature ever being checked against the issuing CA. Hoist the mapping to where both implementations converge, after decoding and before the signer lookup, so one copy serves both. This also covers responder certificates with no extensions, which skipped the mapping in the non-template path as well. Add VERIFY_OCSP_CERT to the gate as a safety net for re-entry, where the parse block is skipped. Adds test_ocsp_forged_responder_cert_rejected, which fails without this change.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes OCSP responder-certificate verification by ensuring VERIFY_OCSP_CERT is mapped to a mode understood by both ASN.1 decoding implementations before signer lookup and signature confirmation, preventing embedded OCSP responder certs from being accepted without their signature being verified against the issuing CA.
Changes:
- Hoists the
VERIFY_OCSP_CERT→VERIFY/VERIFY_OCSPmapping inParseCertRelative()so both ASN.1 implementations apply it consistently. - Adds
VERIFY_OCSP_CERTto theConfirmSignature()gating list to avoid silently skipping signature checks on re-entry/resume paths. - Adds a regression test (with generated OCSP response blob) that embeds a forged responder certificate and asserts it is rejected.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
wolfcrypt/src/asn.c |
Ensures OCSP responder cert signatures are always checked by fixing verify-mode mapping and gating. |
tests/api/test_ocsp.h |
Declares the new OCSP regression test. |
tests/api/test_ocsp.c |
Adds test_ocsp_forged_responder_cert_rejected() verifying forged responder certs are rejected. |
tests/api/test_ocsp_test_blobs.h |
Adds the forged-responder OCSP response blob used by the new test. |
tests/api/create_ocsp_test_blobs.py |
Extends the blob generator to build and embed a forged responder certificate in an OCSP response. |
tests/api.c |
Registers the new OCSP test in the test case table. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Contributor
Author
|
retest this please (Timeout has been exceeded) |
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
asn.c: check the OCSP responder certificate's signature
The VERIFY_OCSP_CERT -> VERIFY/VERIFY_OCSP mapping lived only in the non-template ASN.1 path, so in the default WOLFSSL_ASN_TEMPLATE build the mode reached the ConfirmSignature() gate unmatched and the responder certificate embedded in an OCSP response was accepted without its signature ever being checked against the issuing CA.
Hoist the mapping to where both implementations converge, after decoding and before the signer lookup, so one copy serves both. This also covers responder certificates with no extensions, which skipped the mapping in the non-template path as well. Add VERIFY_OCSP_CERT to the gate as a safety net for re-entry, where the parse block is skipped.
Adds test_ocsp_forged_responder_cert_rejected, which fails without this change.
Fixes ZD#22329
Testing
How did you test?
Checklist