Skip to content

Validate OCSP HTTP request inputs - #3639

Merged
prasden merged 1 commit into
aws:mainfrom
prasden:fix-ocsp-http-crlf
Oct 13, 2026
Merged

prasden merged 1 commit into
aws:mainfrom
prasden:fix-ocsp-http-crlf

Conversation

@prasden

@prasden prasden commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Related issues

P498748746

Note

518/599 added lines is the regenerated generated-src/err_data.c.

Context and motivation

OCSP_REQ_CTX_http and OCSP_REQ_CTX_add1_header copy caller strings into the HTTP request without checking for line break characters (\r or \n).

A path from a certificate's AIA extension, such as /ocsp\r\nX-Evil: 1, can then end a line early and add headers or a second request.

Description of changes

Both functions now reject any method, path, header name, or header value that holds \r or \n. They do this before they write anything, and they raise the new OCSP_R_INVALID_HTTP_HEADER error.

OCSP_REQ_CTX_http also rejects a NULL method, which it used to pass to BIO_printf as a NULL %s.

Testing

The new OCSPRequestHeaderTest puts \r\n, \r, and \n into each of the method, path, header name, and header value. Each case must fail with the expected error and write nothing to the BIO.

Regenerated generated-src/err_data.c for the new error.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

OCSP_REQ_CTX_http and OCSP_REQ_CTX_add1_header copied caller strings straight into the HTTP request. A path, method, header name, or header value that held CR or LF could end the line early and add headers or a second request. The path often comes from a certificate's AIA extension, so an attacker can control it.

Both functions now reject any such input before they write to the request buffer, and raise the new OCSP_R_INVALID_HTTP_HEADER error. OCSP_REQ_CTX_http also rejects a NULL method. This matches OpenSSL, which rejects CR and LF in the same places.
@prasden
prasden requested a review from a team as a code owner October 9, 2026 18:59
@prasden
prasden force-pushed the fix-ocsp-http-crlf branch from 289cb41 to 5f75b08 Compare October 9, 2026 19:00
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🔒 Security Review — View Report

Please review before merging.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.47%. Comparing base (b5c4a2b) to head (5f75b08).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3639      +/-   ##
==========================================
- Coverage   78.69%   78.47%   -0.23%     
==========================================
  Files         705      705              
  Lines      130689   130710      +21     
  Branches    17919    17921       +2     
==========================================
- Hits       102850   102574     -276     
- Misses      26860    27160     +300     
+ Partials      979      976       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@prasden
prasden enabled auto-merge (squash) October 12, 2026 20:49
@prasden
prasden requested a review from spwalgren October 13, 2026 21:57
@prasden
prasden merged commit 7e4ba3f into aws:main Oct 13, 2026
475 checks passed
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.

4 participants