Skip to content

asn.c: check the OCSP responder certificate's signature - #11195

Open
holtrop-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:zd22329
Open

asn.c: check the OCSP responder certificate's signature#11195
holtrop-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:zd22329

Conversation

@holtrop-wolfssl

Copy link
Copy Markdown
Contributor

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

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

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.
@holtrop-wolfssl holtrop-wolfssl self-assigned this Aug 18, 2026
Copilot AI lite review requested due to automatic review settings August 18, 2026 15:24

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 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_CERTVERIFY/VERIFY_OCSP mapping in ParseCertRelative() so both ASN.1 implementations apply it consistently.
  • Adds VERIFY_OCSP_CERT to the ConfirmSignature() 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.

@holtrop-wolfssl

Copy link
Copy Markdown
Contributor Author

retest this please (Timeout has been exceeded)

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.

3 participants