Repository navigation
fix(acme): don't reflect HTTP-01 self-check response body in Challenge - #9035
cert-manager-prow[bot] merged 2 commits into
Conversation
|
/kind bug |
414b148 to
5518eaf
Compare
SgtCoDFish
left a comment
There was a problem hiding this comment.
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!
c705426 to
a4c9bf3
Compare
|
@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. |
| if strings.Contains(err.Error(), responseBody) { | ||
| t.Errorf("expected error not to contain the response body %q, but it did: %v", responseBody, err) | ||
| } |
There was a problem hiding this comment.
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]>
a4c9bf3 to
e2591d9
Compare
SgtCoDFish
left a comment
There was a problem hiding this comment.
/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" |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Cheers, applied in recent commit!
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]>
|
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 Looking at the back and forth with @SgtCoDFish, it seems like this PR is ready to go. /lgtm |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/unhold |
|
/cherry-pick release-1.21 with claude fable-5 |
|
@wallrj: new pull request created: #9232 DetailsIn response to this:
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. |
|
@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. |
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