Repository navigation
fix: harden OCSP/CRL revocation checks against SSRF and DoS - #517
Conversation
The inspect secret command dereferences OCSP and CRL URLs taken verbatim from the untrusted certificate under inspection. Use a shared HTTP client with a request timeout and redirects disabled (closing the CRL scheme allow-list bypass via redirect), cap response bodies with io.LimitReader, and restrict OCSP URLs to http(s). Correct the misleading #nosec rationales accordingly. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: felix.phipps <[email protected]>
|
Hi @FelixPhipps. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
There was a problem hiding this comment.
Pull request overview
Hardens inspect secret certificate revocation checks by reducing SSRF/redirect exposure and bounding resource usage when contacting OCSP responders and CRL distribution points derived from untrusted certificates.
Changes:
- Introduces a shared HTTP client for OCSP/CRL checks with a 10s timeout and redirects disabled.
- Restricts OCSP URLs to
http/httpsschemes before performing network requests. - Caps OCSP/CRL response reads to 1 MiB and adds targeted tests for redirect handling and scheme rejection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/inspect/secret/util.go | Adds shared hardened HTTP client, scheme restriction for OCSP, and response/time bounds for OCSP/CRL fetching. |
| pkg/inspect/secret/util_test.go | Adds tests to ensure CRL checks do not follow redirects and OCSP checks reject non-HTTP(S) schemes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
net/http cannot dereference ldap:// URLs, so listing "(ldap/https only)" in the CRL request #nosec G704 rationale is misleading. Only http(s) is actually fetched by revocationHTTPClient. Remove the scheme list to keep the security rationale accurate. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: felix.phipps <[email protected]>
wallrj-cyberark
left a comment
There was a problem hiding this comment.
The fix correctly addresses all four defects identified in the security audit (CWE-918 / CWE-400):
- DoS via zero timeout — shared
revocationHTTPClientwithTimeout: 10s - OCSP SSRF (no scheme check) — scheme restricted to
http/httpsbefore making the request - CRL redirect bypass —
CheckRedirectreturnshttp.ErrUseLastResponse, preventing scheme downgrade via 307 - Unbounded
io.ReadAll—io.LimitReaderwith 1 MiB cap on both OCSP and CRL paths
Verified locally:
- Both new tests pass with
-race(Test_checkCRLValidCert_doesNotFollowRedirects,Test_checkOCSPValidCert_rejectsNonHTTPScheme) - Full
pkg/inspect/secrettest suite passes go vetclean- CI green (test, verify, integration, dco)
The Copilot suggestions around explicit LimitReader truncation detection are valid enhancements but not required for the security fix — the current behaviour (truncate then fail at ASN.1 parse) is safe. The #nosec ldap wording has been addressed in the second commit.
/label tide/merge-method-squash
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wallrj, wallrj-cyberark The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Problem
The inspect secret command reads a kubernetes.io/tls Secret and, to report revocation status, makes network requests to the OCSP and CRL URLs listed inside the certificate. Those URLs are taken at face value — and a certificate can come from an untrusted source (e.g. a Secret created by a low-privilege tenant), so the URLs should be treated as potentially attacker-influenced. The current code contacts them with no safeguards:
Solution
Route all OCSP/CRL requests through a shared client with a 10s timeout and redirects disabled, cap responds with io.LimitReader (1 MiB), and restricts OCSP URLs to http(s). The misleading #nosec rationales are corrected. Legitimate certs behave unchanged.
Test plan