Skip to content

Harden ACME Challenge and Order validation (GHSA-8rvj-mm4h-c258) - #8948

Merged
cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
wallrj-cyberark:GHSA-8rvj-mm4h-c258
Jun 29, 2026
Merged

cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
wallrj-cyberark:GHSA-8rvj-mm4h-c258

Conversation

@wallrj-cyberark

@wallrj-cyberark wallrj-cyberark commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

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:

Test plan

  • Unit tests for all new webhook validations (challenge owner ref, order spec immutability)
  • Unit tests for same-name Challenge spec mismatch detection
  • Unit test expectations updated for gateway parentRef Group field
  • Lint fixes for import grouping (challenge_test.go) and false-positive suppressions (order_test.go, sync_test.go)
  • Full E2E suite run locally against Kind cluster

/kind bug

Harden ACME Challenge and Order resources: reject user-created Challenges
without Order ownership, enforce Order spec immutability, and detect
pre-placed same-name Challenges with mismatched specs.

@cert-manager-prow cert-manager-prow Bot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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 area/deploy Indicates a PR modifies deployment configuration size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 25, 2026
@cert-manager-prow cert-manager-prow Bot added the area/testing Issues relating to testing label Jun 25, 2026
Kind: "Order",
Name: order.Name,
UID: order.UID,
Controller: new(true),

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.

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{

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.

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

@erikgb erikgb 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.

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.

Comment thread pkg/controller/acmeorders/sync.go Resolved
@cert-manager-prow cert-manager-prow Bot added dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. and removed dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. labels Jun 28, 2026
@wallrj

wallrj commented Jun 28, 2026 •

Copy link
Copy Markdown
Member

@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:

  • re-check the current expected Challenge vs the existing owned Challenge on every Order sync, and recreate it if the solver-selected spec no longer matches
  • record some kind of solver fingerprint when creating the Challenge (for example Issuer UID, generation/resourceVersion, or a hash of the selected solver config) and verify it before processing
  • have the Challenge controller fetch the current Issuer state and refuse to process a Challenge whose solver config is now out of date
  • fail or recreate stale Challenges rather than continuing to process them with solver configuration that no longer matches current intent

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.

@wallrj
wallrj force-pushed the GHSA-8rvj-mm4h-c258 branch from 4a52370 to 9e58195 Compare June 28, 2026 11:39
@cert-manager-prow cert-manager-prow Bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. and removed dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. labels Jun 28, 2026
@wallrj

wallrj commented Jun 28, 2026

Copy link
Copy Markdown
Member

Force-pushed 9e58195 to add the missing DCO sign-off; no code changes from 4a52370.

@erikgb erikgb 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

Adding a hold as I found a few minor nits on my last review pass. Sorry! 🙈

@cert-manager-prow cert-manager-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 28, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[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

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

@cert-manager-prow cert-manager-prow Bot added 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 Jun 28, 2026
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]>
@cert-manager-prow cert-manager-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 29, 2026
@wallrj-cyberark wallrj-cyberark changed the title Harden ACME Challenge and Order RBAC and validation (GHSA-8rvj-mm4h-c258) Harden ACME Challenge and Order validation (GHSA-8rvj-mm4h-c258) Jun 29, 2026

@erikgb erikgb 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
/unhold

Thanks a lot @wallrj-cyberark! 🚀

@cert-manager-prow cert-manager-prow Bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 29, 2026
@cert-manager-prow
cert-manager-prow Bot merged commit 292b2c9 into cert-manager:master Jun 29, 2026
@wallrj-cyberark
wallrj-cyberark deleted the GHSA-8rvj-mm4h-c258 branch June 29, 2026 13:10
@wallrj-cyberark

Copy link
Copy Markdown
Member Author

@erikgb — apologies, I should have placed a /hold on this immediately after addressing your nits rather than letting it merge. Your review question about whether we could do more to protect in depth prompted a deeper analysis that I should have shared before this landed.

I would like to propose reverting this PR. Here is the reasoning.

The RBAC change alone is sufficient

The 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 challengeMatchesExpectedForOrder check — adds defence in depth, but only against an attack path that the RBAC change already eliminates.

Full code-level mitigation is more complex than this PR achieves

Your 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:

  1. Challenge controller solver re-verification. Currently the Challenge controller trusts spec.solver directly — it calls solver.Present() using whatever config the Challenge carries, without comparing it to what the Issuer currently says. This PR does not change that. Adding an OrderLister to the Challenge controller and re-deriving the expected solver config via solverpicker.Pick before processing would catch smuggled Challenges, but it is a new cross-resource dependency on every sync.

  2. Order webhook owner-ref check. This PR validates Challenge owner refs but not Order owner refs. An attacker who can create Orders could bypass the Challenge validation by creating a legitimate-looking Order that references an arbitrary ClusterIssuer.

  3. Order controller IssuerRef consistency check. Even with an Order owner-ref check, the Order controller would need to verify that its IssuerRef matches the owning CertificateRequest's IssuerRef — otherwise an attacker could create an Order owned by a legitimate CertificateRequest but targeting a different ClusterIssuer.

  4. Race window. Even with all of the above, there is a race between Challenge creation and the next controller sync. The Challenge controller could process solver.Present() before the Order controller detects the spec mismatch.

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 measure

The webhook validation and challengeMatchesExpectedForOrder logic add code paths that need to be understood, tested, and maintained. For a measure that is neither necessary (the RBAC change is sufficient) nor sufficient (the gaps above remain open), the additional complexity does not seem justified.

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.

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 Indicates a PR directly modifies the ACME Issuer code area/deploy Indicates a PR modifies deployment configuration area/testing Issues relating to testing 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants