Skip to content

fix(vault): gate AWS IAM auth ambient credentials for namespaced Issuers - #8977

Merged
cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
FelixPhipps:AWS-gate-unreachable
Jul 16, 2026
Merged

cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
FelixPhipps:AWS-gate-unreachable

Conversation

@FelixPhipps

@FelixPhipps FelixPhipps commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

Description

Problem

The Vault issuer can authenticate to a HashiCorp Vault server using AWS IAM: it signs a sts:GetCallerIdentity request with AWS credentials and sends that signature to Vault, which returns a Vault token. cert-manager has a deliberate safety rule for this — a tenant-created namespaced Issuer must never borrow the controller's own cloud identity unless the operator opts in via --issuer-ambient-credentials (defaulted false for Issuers, true for ClusterIssuers). Every other ambient-credential path honours this gate (e.g. the Route53 DNS-01 solver), however the Vault AWS IAM auth path did not.

This raised three issues:

  • Missing ambient-credentials gate: the path selected the controller's ambient AWS credential chain (IRSA / IMDS / EKS Pod Identity) whenever awsAuth.ServiceAccountRef == nil, without ever consulting IssuerOptions.CanUseAmbientCredentials(issuer). The gate was also unreachable, as IssuerOptions was never plumbed into the Vault client.
  • Identity disclosure: because the tenant also controls spec.vault.server, a low-privilege tenant could point a namespaced Vault Issuer at a server they control and receive a SigV4-signed GetCallerIdentity assertion of the controller's IAM identity (AccessKeyID + session token in the headers).
  • Privilege escalation: that signed assertion can be replayed within the SigV4 window against a real Vault AWS-IAM backend that trusts the controller's IAM role, minting a Vault token at controller privilege.

Solution

  • Thread the ambient-credentials decision from the issuer and CSR controllers (where the issuer type and IssuerOptions are known) through New / ClientBuilder into the Vault client, and refuse the ambient fallback when the issuer is not permitted to use ambient credentials. The explicit IRSA path (serviceAccountRef set) and ClusterIssuer behaviour are unchanged. Legitimate configurations behave identically.

Test plan

  • TestRequestTokenWithAWSAuthAmbientCredentialsGate — an AWS-auth Issuer with no serviceAccountRef and ambient credentials not permitted errors out before
    any login request is sent (fake client would error on Write), confirming the gate fires ahead of the sink.
  • TestSetToken/"if aws auth omits serviceAccountRef and ambient credentials are not permitted…" — table case asserting the same denial surfaces through setToken.
  • Verified the gate is load-bearing: with the check removed, TestRequestTokenWithAWSAuthAmbientCredentialsGate fails (falls through to ambient/IMDS retrieval); restored, it passes.
  • Existing internal/vault, pkg/issuer/vault, pkg/controller/certificaterequests/vault, and pkg/controller/certificatesigningrequests/vault tests pass
    unchanged (signature updates only).
  • go build ./..., go vet ./..., and gofmt clean.

release-note

  The `vault` issuer no longer authenticates to Vault using the cert-manager controller's ambient AWS credentials
  for AWS IAM auth on a namespaced `Issuer`, unless ambient credentials are explicitly enabled via
  `--issuer-ambient-credentials`. `ClusterIssuer` and explicit `serviceAccountRef` (IRSA) configurations are
  unaffected.```

@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/vault Indicates a PR directly modifies the Vault Issuer code needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 7, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

Hi @FelixPhipps. Thanks for your PR.

I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@cert-manager-prow cert-manager-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 7, 2026
@FelixPhipps

Copy link
Copy Markdown
Member Author

/ok-to-test

@cert-manager-prow cert-manager-prow Bot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 10, 2026
@maelvls
maelvls requested a review from Copilot July 16, 2026 09:13

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 fixes a security-sensitive gap in the Vault AWS IAM auth flow by threading the ambient-credentials permission decision into the Vault client and refusing to fall back to the controller’s ambient AWS credential chain when the issuer is not permitted to use it.

Changes:

  • Plumbs CanUseAmbientCredentials(issuer) from issuer/CSR controllers into the Vault client builder and internal/vault.New.
  • Adds an explicit gate in requestTokenWithAWSAuth to deny ambient AWS credentials when not permitted.
  • Extends Vault unit tests to cover the new denial behavior and updates controller tests for the new builder signature.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/issuer/vault/setup.go Passes ambient-credentials permission into the Vault client constructor.
pkg/controller/certificatesigningrequests/vault/vault.go Threads ambient-credentials permission into the Vault client builder call.
pkg/controller/certificatesigningrequests/vault/vault_test.go Updates test clientBuilder signatures to accept the new boolean parameter.
pkg/controller/certificaterequests/vault/vault.go Threads ambient-credentials permission into the Vault client builder call.
pkg/controller/certificaterequests/vault/vault_test.go Updates test clientBuilder signatures to accept the new boolean parameter.
pkg/controller/certificaterequests/vault/fuzz_test.go Updates fuzz harness clientBuilder signature to accept the new boolean parameter.
internal/vault/vault.go Adds canUseAmbientCredentials to Vault client and enforces it in AWS auth ambient fallback.
internal/vault/vault_test.go Adds tests for the ambient-credentials gate and adjusts New calls for the new signature.

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

Comment thread internal/vault/vault.go Resolved
Comment thread internal/vault/vault_test.go Resolved
@maelvls

maelvls commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

I've looked at the changes, seems good to me. I also asked a review from Claude, nothing was spotted.

Regarding testing, I imagine we don't have any live end-to-end tests for these code paths, we never bothered trying to maintain an e2e test with AWS, so I'm OK with this PR not adding any end-to-end test.

I haven't tested the change with Vault on EKS.

Before approving, can you look at the two Copilot comments? Also, could you add a release note block? Thanks.

@cert-manager-prow cert-manager-prow Bot added lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels Jul 16, 2026
The Vault AWS IAM auth path (requestTokenWithAWSAuth) fell back to the
controller's ambient AWS credential chain whenever awsAuth.ServiceAccountRef
was nil, without consulting IssuerOptions.CanUseAmbientCredentials(issuer) -
the gate every other ambient-credential code path honours and which defaults
to false for namespaced Issuers.

Because the tenant also controls spec.vault.server, a namespaced Issuer could
point a Vault Issuer at a server it controls and receive a SigV4-signed
GetCallerIdentity assertion of the controller's IAM identity, disclosing the
controller's AWS account/role and enabling replay against a trusting Vault
AWS-IAM backend to escalate to controller privilege.

Thread the ambient-credentials decision from the issuer and CSR controllers
(where the issuer type and IssuerOptions are known) through New/ClientBuilder
into the Vault client, and refuse the ambient fallback when the issuer is not
permitted to use ambient credentials. The explicit IRSA path
(serviceAccountRef set) and ClusterIssuer behaviour are unchanged.

```release-note
The `vault` issuer no longer authenticates to Vault using the cert-manager
controller's ambient AWS credentials for AWS IAM auth on a namespaced `Issuer`,
unless ambient credentials are explicitly enabled via
`--issuer-ambient-credentials`. This aligns the Vault AWS auth path with every
other ambient-credential code path. `ClusterIssuer` and explicit
`serviceAccountRef` (IRSA) configurations are unaffected.
```

Signed-off-by: Felix Phipps <[email protected]>
@FelixPhipps
FelixPhipps force-pushed the AWS-gate-unreachable branch from c9afdaf to 36caf89 Compare July 16, 2026 10:36
@cert-manager-prow

Copy link
Copy Markdown
Contributor

@FelixPhipps: you cannot LGTM your own PR.

Details

In response to this:

/lgtm

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.

@maelvls

maelvls commented Jul 16, 2026

Copy link
Copy Markdown
Member

/lgtm
/approve

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

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maelvls

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 Denotes a PR that will be considered when it comes time to generate release notes. 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 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
@cert-manager-prow
cert-manager-prow Bot merged commit b906bd2 into cert-manager:master Jul 16, 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: #9231

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/vault Indicates a PR directly modifies the Vault 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. ok-to-test 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.

5 participants