Repository navigation
Harden ACME Challenge and Order validation (GHSA-8rvj-mm4h-c258) - #8948
cert-manager-prow[bot] merged 1 commit into
Conversation
0bddaa0 to
4c4523c
Compare
| Kind: "Order", | ||
| Name: order.Name, | ||
| UID: order.UID, | ||
| Controller: new(true), |
There was a problem hiding this comment.
The new webhook validation in this PR requires every Challenge to have an Order controller owner reference. This test was creating a bare Challenge (for metrics testing, not ACME flow testing), so it failed with:
admission webhook "webhook.cert-manager.io" denied the request: metadata.ownerReferences: Forbidden: challenge resources must be owned by an Order resource
Fixed by creating an Order first and setting a controller owner reference on the Challenge. The Order doesn't need any particular content — the webhook only checks the shape of the owner reference, not whether the Order is valid.
| // mismatch on Group when comparing the in-memory expected spec | ||
| // against the stored spec. | ||
| group := gwapi.Group(gwapi.GroupVersion.Group) | ||
| filtered = append(filtered, gwapi.ParentReference{ |
There was a problem hiding this comment.
@hjoshi123 @maelvls — the ParentReference constructed here previously omitted the Group field, relying on the CRD OpenAPI default (gateway.networking.k8s.io) to fill it in at storage time. That's normally fine, but it creates a problem for the new challengeMatchesExpectedForOrder comparison: the in-memory expected spec has Group nil while the stored (post-defaulting) spec has it populated, so apiequality.Semantic.DeepEqual never matches.
There's no programmatic mechanism to apply CRD OpenAPI defaults in a controller, so the workaround is to set Group explicitly here to match what the API server would default.
This was introduced in #8518 (#8518) and carried forward through #8619 (#8619). See also #7890 for the broader feature discussion.
4c4523c to
6de94b2
Compare
erikgb
left a comment
There was a problem hiding this comment.
This generally looks good! Thanks!
But I am not completely assured that we cannot do even more to protect in dept. But this is huge step forward. I wonder if we can check the issuer solver before processing the challenge? You mentioned something about actually processing mismatching solver configuration, but I cannot determine if I agree 100%. Why process an outdated solver configuration at all? Can't we just skip it?
Added a couple of minor nits/suggestions.
|
@erikgb Thanks — I pushed 9e58195 to address the inline comments. On the broader solver point: I do think there is probably more hardening we could do there, but I have kept this PR scoped to preventing adoption of attacker-placed same-name Challenges and to locking down Challenge / Order mutation paths. After this change, the order controller recomputes the expected Challenge from the current issuer config and refuses to use any same-name Challenge whose owner or spec does not match that expectation. The extra hardening I had in mind is roughly: should we also treat an already-created, order-owned Challenge as stale if the current Issuer / ClusterIssuer solver config would no longer produce that Challenge now? A few concrete ways we could do that:
I think that is worth discussing, but it feels like a separate behavioural decision rather than something I want to bundle into this defence-in-depth patch. In particular, we would need to decide what the intended semantics are when users legitimately change solver config while Orders are already in flight: whether to continue with the old solver, restart with the new one, and how to avoid stranding any already-presented HTTP01/DNS01 resources while making that transition. |
4a52370 to
9e58195
Compare
erikgb
left a comment
There was a problem hiding this comment.
/lgtm
/approve
/hold
Adding a hold as I found a few minor nits on my last review pass. Sorry! 🙈
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: erikgb 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 |
Defence in depth for GHSA-8rvj-mm4h-c258, complementing the RBAC fix in cert-manager#8958. Webhook validation: - ValidateChallenge: reject Challenges lacking a controller owner reference to an Order. - ValidateOrderSpecUpdate: reject any Order spec mutation after creation. Controller hardening: - Order controller verifies both ownership AND exact spec equivalence for same-name Challenges. Mismatched Challenges are deleted and recreated. - Set gateway parentRef Group explicitly to match the CRD OpenAPI default, preventing a nil-vs-populated mismatch in spec comparison (cert-manager#7890, cert-manager#8518, cert-manager#8619). Signed-off-by: Richard Wall <[email protected]>
9e58195 to
485ccc8
Compare
erikgb
left a comment
There was a problem hiding this comment.
/lgtm
/unhold
Thanks a lot @wallrj-cyberark! 🚀
|
@erikgb — apologies, I should have placed a I would like to propose reverting this PR. Here is the reasoning. The RBAC change alone is sufficientThe RBAC restriction (now in #8958) closes the attack surface for GHSA-8rvj-mm4h-c258 simply and completely: if users cannot create Challenges or Orders directly, the smuggling vector does not exist. The code-level hardening in this PR — the webhook owner-ref validation and the Order controller's Full code-level mitigation is more complex than this PR achievesYour question "why process an outdated solver configuration at all?" led us to examine whether GHSA-8rvj-mm4h-c258 could be fully mitigated through code changes alone, making RBAC optional. The answer is: in principle yes, but it would require substantially more work than what this PR contains:
None of these are addressed by this PR. So the code-level changes it introduces provide a partial defence that does not stand on its own — they only add value when combined with the RBAC restriction. The complexity is not justified for a partial measureThe webhook validation and I think it would be cleaner to revert this, merge #8958 (the RBAC change), and then revisit individual hardening layers — particularly solver re-verification in the Challenge controller — as separate, focused PRs with their own discussion, if we decide the defence in depth is worth the cost. |
Motivation
Defence in depth for GHSA-8rvj-mm4h-c258. The RBAC fix (the primary mitigation) has been split into #8958. This PR adds the webhook validation and controller hardening changes.
Changes
Webhook validation:
ValidateChallenge: reject Challenges lacking a controller owner reference to an Order.ValidateOrderSpecUpdate: reject any Order spec mutation after creation.Controller hardening:
Groupexplicitly to match the CRD OpenAPI default, preventing a nil-vs-populated mismatch in spec comparison (see Cluster issuer for HTTP-01 gatewayHTTPRoute should not require a gateway parentRef #7890, feat(acme/http01): adding overrides for parentRef #8518, fix(certificate-shim): removing duplicate parentRefs #8619).Test plan
challenge_test.go) and false-positive suppressions (order_test.go,sync_test.go)/kind bug