Repository navigation
fix(vault): gate AWS IAM auth ambient credentials for namespaced Issuers - #8977
Conversation
|
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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
There was a problem hiding this comment.
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 andinternal/vault.New. - Adds an explicit gate in
requestTokenWithAWSAuthto 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.
|
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. |
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]>
c9afdaf to
36caf89
Compare
|
@FelixPhipps: you cannot LGTM your own PR. 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. |
|
/lgtm |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/kind bug |
|
/cherry-pick release-1.21 with claude fable-5 |
|
@wallrj: new pull request created: #9231 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 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:
Solution
Test plan
any login request is sent (fake client would error on Write), confirming the gate fires ahead of the sink.
unchanged (signature updates only).
release-note