Skip to content

chore(acme): forbid direct construction of the forked ACME client - #9019

Merged
cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
FelixPhipps:forbidigo-acme-client
Jul 21, 2026
Merged

cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
FelixPhipps:forbidigo-acme-client

Conversation

@FelixPhipps

@FelixPhipps FelixPhipps commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Description

Problem

The forked golang.org/x/crypto/acme client is only safe to use when built through pkg/acme/accounts.NewClient — that constructor is what wires in the hardened HTTP client (custom TLS config, Prometheus instrumentation, and the response-body size cap added in #9010).

Nothing currently stops a developer from constructing a raw acme.Client{} elsewhere, which bypasses all of those protections and could reintroduce issues like the unbounded-body DoS. This was out-of-scope for that fix, so it's split out here.

Solution

Add a forbidigo rule that bans naming the forked acme.Client type. With analyze-types: true the rule matches by import path, so it catches any import alias (acme, acmeapi, …) and ignores unrelated types such as net/http.Client. The two legitimate sites — the NewClient constructor and the compile-time var _ Interface = &acme.Client{} assertion — are exempted with an inline //nolint:forbidigo. No runtime behaviour changes; this is a lint-only guardrail.

Test plan

  • forbidigo flags direct acme.Client construction — verified by temporarily adding a rogue &acmeapi.Client{} in pkg/controller/acmeorders, running the linter (reported as an error, exit non-zero), then removing the file.
  • The two sanctioned sites carry //nolint:forbidigo, and nolintlint confirms both directives are valid and in use.
  • verify-generate-golangci-lint-config passes; golangci-lint config verify is clean.
  • Existing pkg/acme tests pass unchanged; go build ./..., go vet ./..., gofmt clean, and full golangci-lint reports 0 issues.

Release Note

​release-note NONE ​

The forked golang.org/x/crypto/acme client should only be built via
pkg/acme/accounts.NewClient, which is the one constructor that wires in the
hardened HTTP client (custom TLS config, Prometheus instrumentation and the
response-body size cap). Constructing an acme.Client literal anywhere else
silently bypasses those protections.

Add a forbidigo rule that bans naming the forked acme.Client type, matched
by import path via analyze-types so it catches any import alias and ignores
unrelated types such as net/http.Client. The two legitimate sites - the
NewClient constructor and the compile-time interface assertion - are
exempted with an inline //nolint:forbidigo.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Felix Phipps <[email protected]>
@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. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. area/acme Indicates a PR directly modifies the ACME Issuer code needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 13, 2026
@wallrj-cyberark
wallrj-cyberark requested a review from Copilot July 17, 2026 14:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a lint-only guardrail to ensure the forked ACME client (third_party/forked/acme.Client) is only ever instantiated via pkg/acme/accounts.NewClient, which wires in the hardened/instrumented HTTP client and response-body size cap.

Changes:

  • Add a forbidigo rule (with analyze-types: true) that forbids naming the forked acme.Client type by import path, regardless of local import aliasing.
  • Add explicit //nolint:forbidigo exemptions for the two sanctioned usages: the single constructor site and the compile-time interface assertion.
  • Keep the existing “no debug prints” forbidigo rule by re-declaring it in the custom forbid list.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
.golangci.yaml Adds a forbidigo rule targeting third_party/forked/acme.Client (by package path) and preserves the existing print-statement ban.
pkg/acme/accounts/client.go Marks the single allowed acmeapi.Client construction site with //nolint:forbidigo and clarifying comments.
pkg/acme/client/interfaces.go Marks the compile-time var _ Interface = &acme.Client{...} assertion with //nolint:forbidigo and adds a short comment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wallrj-cyberark

Copy link
Copy Markdown
Member

Thank you for splitting this out from #9010 — a focused, lint-only guardrail is exactly the right follow-up.

Verification performed locally (branch forbidigo-acme-client, _bin/tools/golangci-lint via make verify-golangci-lint):

  • Introduced a temporary rogue &acmeapi.Client{} construction in pkg/controller/acmeorders/sync.go and confirmed the linter fails with exactly the message described in the PR body:
    pkg/controller/acmeorders/sync.go:64:7: use of `acmeapi.Client` forbidden because "Do not construct the forked ACME client directly; obtain one via pkg/acme/accounts.NewClient." (forbidigo)
    
  • Reverted the change and confirmed make verify-golangci-lint reports 0 issues across all modules, and make verify-generate-golangci-lint-config is clean.
  • go build ./... and go vet ./pkg/acme/... are clean.
  • Searched the whole tree for any other construction of the forked client (grep -rn "\.Client{" filtered to ACME): the only hits outside the two sanctioned/exempted sites are in third_party/forked/acme/internal/acmeprobe/prober.go and third_party/forked/acme/pebble_test.go, both of which are vendored/forked code already excluded from all linters by the pre-existing top-level linters.exclusions.paths: [third_party, ...] — so the new rule doesn't need to (and shouldn't) touch them. No gaps found; the rule closes exactly the hole left open by fix(acme): bound ACME response body size to prevent unbounded-body DoS #9010.

CI is green and the Copilot review completed with no comments, so nothing further to action there.

One small housekeeping item, per the bot's own labels (needs-kind, do-not-merge/release-note-label-needed): could you add a /kind cleanup command and a release-note block? The precedent PR for lint-only changes (#6973) used:

### Kind
/kind cleanup

### Release Note
​```release-note
NONE
​```

That should clear both automated labels.

@cert-manager-prow cert-manager-prow Bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Jul 21, 2026
@wallrj-cyberark
wallrj-cyberark requested a review from wallrj July 21, 2026 15:32
@wallrj

wallrj commented Jul 21, 2026

Copy link
Copy Markdown
Member

/approve
/lgtm

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

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wallrj

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 21, 2026
@FelixPhipps

Copy link
Copy Markdown
Member Author

/kind cleanup

@cert-manager-prow
cert-manager-prow Bot merged commit 1dfe1dd into cert-manager:master Jul 21, 2026
5 checks passed
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 dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants