Skip to content

fix(acme): don't reflect HTTP-01 self-check response body in Challenge - #9035

Merged
cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
FelixPhipps:selfcheck-redirect-ssrf
Jul 23, 2026
Merged

cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
FelixPhipps:selfcheck-redirect-ssrf

Conversation

@FelixPhipps

@FelixPhipps FelixPhipps commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Description

Problem

The HTTP-01 self-check (testReachability) fetches http:///.well-known/acme-challenge/ to confirm the challenge token is served. Because the ACME spec requires following redirects, the response may come from a host other than the one being validated.

On a token mismatch, the first 24 bytes of that response body were embedded verbatim in the returned error, which is persisted to Challenge.Status.Reason — a field readable by any tenant with access to the Challenge in its namespace. This disclosed fragments of internal responses.

Solution

Keep the response body out of the returned error, replacing it with a static message that points operators to the controller logs. The body is still logged at debug level for legitimate propagation debugging. Redirect-following and InsecureSkipVerify are intentionally left unchanged — both are spec-required behaviour that matches Let's Encrypt/Boulder. Legitimate certs behave unchanged.

Test plan

  • Existing pkg/issuer/acme/http tests (TestReachabilityCustomDnsServers, TestCheck) pass unchanged — the error still contains the expected key, just not the response body.
  • go build ./... and go vet ./... clean.
The ACME HTTP-01 self-check no longer reflects the fetched response body in `Challenge.status.reason`, preventing disclosure of internal response contents reachable via redirects. The response is still available in the controller's debug logs.

@cert-manager-prow cert-manager-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. area/acme Indicates a PR directly modifies the ACME Issuer code needs-kind Indicates a PR lacks a `kind/foo` label and requires one. area/acme/http01 Indicates a PR modifies ACME HTTP01 provider code size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 16, 2026
@FelixPhipps

Copy link
Copy Markdown
Member Author

/kind bug

@cert-manager-prow cert-manager-prow Bot added kind/bug Categorizes issue or PR as related to a bug. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Jul 16, 2026
@FelixPhipps
FelixPhipps force-pushed the selfcheck-redirect-ssrf branch from 414b148 to 5518eaf Compare July 20, 2026 11:39

@SgtCoDFish SgtCoDFish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couple of small things. I think it's probably worth sharing this one more widely in #cert-manager-dev on slack (since this is user facing and could conceivably make debugging ACME issues trickier in the name of security).

This is also definitely in need of a release note!

Comment thread pkg/issuer/acme/http/http.go Resolved
Comment thread pkg/issuer/acme/http/http.go Resolved
@FelixPhipps
FelixPhipps force-pushed the selfcheck-redirect-ssrf branch 2 times, most recently from c705426 to a4c9bf3 Compare July 20, 2026 14:59
@cert-manager-prow cert-manager-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels Jul 20, 2026
@FelixPhipps

Copy link
Copy Markdown
Member Author

@SgtCoDFish Sorry, I think I underestimated the impact on this one!

Made the error message more concise and added some testing to go with it, as well as a release note.

Comment thread pkg/issuer/acme/http/http_test.go Outdated
Comment on lines +232 to +234
if strings.Contains(err.Error(), responseBody) {
t.Errorf("expected error not to contain the response body %q, but it did: %v", responseBody, err)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: the previous implementation which we're removing truncated the body at 24 chars, and this test's responseBody ("this-response-body-must-not-be-reflected-in-the-error") is 53 chars.

As such I don't think this test would have failed before we made the change because the response body would have been truncated and strings.Contains(err.Error(), responseBody) is always going to be false - so it doesn't really test what we're changing.

This test would be more valuable if it failed on the previous implementation and passed on the new impl. Maybe if we set responseBody to SENTINEL or something. We can also be more defensive still and check case insensitively.

The test is usually more important than the fix IMO!

…e status

The HTTP-01 self-check follows redirects, so the response body may originate
from a host other than the one being validated (e.g. an internal service or a
cloud metadata endpoint reached via a redirect). The mismatch error was
embedded verbatim in Challenge.Status.Reason, which is readable by tenants with
access to the Challenge, disclosing fragments of internal responses (CWE-209 /
CWE-918).

Keep the response body out of the returned error; it is still logged at debug
level for operators.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Felix Phipps <[email protected]>
@FelixPhipps
FelixPhipps force-pushed the selfcheck-redirect-ssrf branch from a4c9bf3 to e2591d9 Compare July 21, 2026 14:00

@SgtCoDFish SgtCoDFish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold

Added a non-blocking comment - no action needed unless you want to really go above and beyond

I'm happy to merge this - I think the user-facing change is worthwhile in this instance for the security benefit. Leaving a hold for a bit just in case anyone else chimes in - there's no rush here, so we can wait a day or two and then just unhold if nobody else has strong feelings on this!

Thank you for this!

// returns a body that does not match the expected key, the contents of that
// body are not included in the returned error.
func TestReachabilityDoesNotReflectResponseBody(t *testing.T) {
const responseBody = "SENTINEL-BODY"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion (non-blocking): This value could benefit from a comment explaining why we chose this string as the response body (i.e. it had to be a string shorter than 24 chars for this to be an effective regression test for the future).

Not blocking because we're already very deep into hardening this test (probably deeper than we needed to be!) but I figure it's worth writing this comment out for future reference!

For extra double bonus points - have the sentinel value by tested itself to assert it's short enough so we don't have to rely on the comment!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Cheers, applied in recent commit!

@cert-manager-prow cert-manager-prow Bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 21, 2026
Address review feedback: the sentinel response bodies must be shorter than
the 24-character limit at which the old (removed) code truncated the reflected
body, otherwise the "does not reflect body" tests would pass against the buggy
implementation too. Add a maxUntruncatedBodyLen constant with an explanatory
comment and an assertEffectiveSentinel helper so this is enforced by the tests
rather than relying on the comment alone.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Felix Phipps <[email protected]>
@cert-manager-prow cert-manager-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2026
@maelvls

maelvls commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Not blocking: I wish the PR description clearly explained the "why", or at least told us that the "why" isn't shown here but will be disclosed once the vuln is fixed.

I guess we should also take a look at all of the other ways an attacker could use the ability to make requests (vault's url, etc etc). I imagine none of the other methods (e.g. vault url) allow you to capture the response's payload.

Looking at the back and forth with @SgtCoDFish, it seems like this PR is ready to go.

/lgtm
/approve

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maelvls, SgtCoDFish

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@FelixPhipps

Copy link
Copy Markdown
Member Author

/unhold

@cert-manager-prow cert-manager-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 23, 2026
@cert-manager-prow
cert-manager-prow Bot merged commit 6f4f271 into cert-manager:master Jul 23, 2026
6 checks passed
@wallrj wallrj mentioned this pull request Jul 29, 2026
13 tasks done
@wallrj

wallrj commented Sep 1, 2026

Copy link
Copy Markdown
Member

/cherry-pick release-1.21

with claude fable-5

@cert-manager-bot

Copy link
Copy Markdown
Contributor

@wallrj: new pull request created: #9232

Details

In response to this:

/cherry-pick release-1.21

with claude fable-5

Instructions 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.

@wallrj

wallrj commented Sep 11, 2026

Copy link
Copy Markdown
Member

@FelixPhipps This change has been included in v1.21.2, which is now published.

If you are able to install the release and verify that the change works as expected in your environment, that would be much appreciated. Thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/acme/http01 Indicates a PR modifies ACME HTTP01 provider code area/acme Indicates a PR directly modifies the ACME Issuer code dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants