Skip to content

Fix: ocsp - validate response timestamps in wolfSSL_OCSP_check_validity - #11297

Open
jackctj117 wants to merge 2 commits into
wolfSSL:masterfrom
jackctj117:10718
Open

jackctj117 wants to merge 2 commits into
wolfSSL:masterfrom
jackctj117:10718

Conversation

@jackctj117

Copy link
Copy Markdown
Contributor

This pull request implements comprehensive validation for OCSP response timestamps in the wolfSSL_OCSP_check_validity function and adds a thorough suite of tests to ensure correct behavior, especially regarding clock skew, staleness, and absent fields. The changes also integrate the new test into the test suite.

OCSP response timestamp validation improvements:

  • src/ocsp.c: Rewrote wolfSSL_OCSP_check_validity to properly validate the thisUpdate and nextUpdate timestamps, enforcing clock skew (sec), maximum staleness (maxsec), and handling absent or malformed times as failures, except for absent nextUpdate which is now correctly accepted when represented as a zero-length structure.

Expanded OCSP validation testing:

  • tests/api/test_ocsp.c: Added a comprehensive test function test_ocsp_check_validity covering all relevant edge cases, including future, stale, missing, and malformed thisUpdate, expired or inconsistent nextUpdate, and correct handling of absent nextUpdate as a zero-length structure. Also tests integration with the OCSP status getter.
  • tests/api/test_ocsp.h: Declared the new test function for use in the test suite.
  • tests/api.c: Registered the new test case in the OCSP test group, ensuring it runs as part of the standard test suite.

Copilot AI lite review requested due to automatic review settings August 26, 2026 23:25
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

@jackctj117 jackctj117 changed the title 10718 Fix: ocsp - validate response timestamps in wolfSSL_OCSP_check_validity Aug 26, 2026

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 tightens OpenSSL-compat OCSP response validation by making wolfSSL_OCSP_check_validity actually enforce thisUpdate/nextUpdate timestamp rules (clock skew and staleness), and adds API tests to guard the behavior.

Changes:

  • Reworked wolfSSL_OCSP_check_validity in src/ocsp.c to validate thisUpdate presence/format and enforce skew/staleness, while treating a zero-length nextUpdate as “absent”.
  • Added a focused test suite for wolfSSL_OCSP_check_validity edge cases and integrated it into the API test runner.
  • Exposed the new test via tests/api/test_ocsp.h and registered it in tests/api.c.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/ocsp.c Implements timestamp validation logic for OCSP responses (thisUpdate/nextUpdate).
tests/api/test_ocsp.c Adds coverage for validity checks across future/stale/missing/malformed timestamp scenarios.
tests/api/test_ocsp.h Declares the new OCSP validity test entry point.
tests/api.c Registers the new OCSP validity test in the OCSP test group.
Suppressed comments (1)

src/ocsp.c:819

  • The nextUpdate expiration check is also strict (nextUpdate must be after now - sec). With the current wolfSSL_X509_cmp_time semantics (-1 for <=), this rejects a nextUpdate exactly at the edge of the allowed clock skew (nextUpdate == now - sec). Allow the boundary case by comparing against now - sec - 1.
        cmp = now - sec;
        if (wolfSSL_X509_cmp_time(nextupd, &cmp) != 1) {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/ocsp.c
Comment thread src/ocsp.c
Comment thread src/ocsp.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11297

Scan targets checked: wolfcrypt-rs-bugs, wolfssl-bugs, wolfssl-src

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/ocsp.c
Comment thread src/ocsp.c
@philljj

philljj commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Retest this please.

tlslite.errors.TLSAbruptCloseError: TLSAbruptCloseError

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