cert-manager
Next-private-key Secret ownership
Additional upstream fix · no assigned CVE/GHSA · Public source snapshot: November 12, 2026
Original portfolio report · Source reference
Shared credits and the scope of my investigation are documented below.
Mallory has a custom Kubernetes role that lets her manage a Certificate and write its status, but does not let her read Alice's TLS Secret in the same namespace. In the affected controller path, Mallory can name that Secret in status.nextPrivateKeySecretName. cert-manager then uses its own Secret access to consume the private key and, if issuance completes, writes that key into the Certificate's output Secret. If Mallory can read that output, she crosses the intended Secret-read boundary.
I reviewed cert-manager 1.21.0, the public correction, the 1.21.2 / 1.21.3 release boundary, representative older source, and the related controller tests. I did not deploy a cluster, execute the reported attack, or independently reproduce the PR author's test results. This is a conditional authorization failure in a custom permission arrangement: the default aggregated Kubernetes edit role already grants Secret access, so that role does not gain a new Secret-reading privilege through this path.
| Public record | Detail |
|---|---|
| Upstream fix | cert-manager PR #9224 |
| Public reporter credit | Charles Vosburgh / the-vibe-dev |
| Fix author | Richard Wall / wallrj |
| Merge | September 16, 2026, 10:22 p.m. EDT; September 17 UTC |
| Main affected release inspected | 1.21.0 |
| Latest affected 1.21 release inspected | 1.21.2 |
| First fixed release confirmed on the 1.21 branch | 1.21.3, released October 23, 2026 |
| Identifiers | No separate CVE or GHSA established for this contribution |
This accepted upstream fix is additional portfolio work outside my CVE/GHSA-identified case totals.
A Certificate's spec.secretName identifies its output Secret. During issuance, cert-manager creates a temporary Secret holding the next private key and records its name in status.nextPrivateKeySecretName. The keymanager, requestmanager, and issuing controllers cooperate through that state.
The temporary Secret should belong to the Certificate using it. In the normal keymanager workflow it carries the cert-manager.io/next-private-key label and a controller owner reference to that Certificate. A mutable status field is a reference to this resource, not authority to use any private key a user can name.
The scenario requires all of the following: a principal able to create or control the relevant Certificate and update its status; a victim Secret in the same namespace containing a usable private key; a readable output Secret; and controller processing that reaches the affected issuance path. Key compatibility, issuer policy, request approval, issuance state, and controller reconciliation affect whether the key reaches that output. The report does not establish cross-namespace Secret access or cluster-wide compromise.
The 1.21.0 Helm chart's edit role includes certificates/status: update. The public PR and Kubernetes RBAC documentation explain that ordinary edit permissions also include namespace Secret access. The security boundary of interest is therefore a custom role that separates those permissions, rather than a universal escalation from the default edit role.
The requestmanager trusts the status-selected Secret
In 1.21.0, pkg/controller/certificates/requestmanager/requestmanager_controller.go, ProcessItem(), first requires a live Certificate with Issuing=True. It then reads the named Secret:
nextPrivateKeySecret, err := c.secretLister.Secrets(crt.Namespace).Get(*crt.Status.NextPrivateKeySecretName)
The lookup is namespace-scoped, but it does not establish that the returned Secret is owned by this Certificate. The following guards reject missing data and an undecodable private key; they do not repair ownership. The decoded key is passed to createNewCertificateRequest(), whose CSR encoding uses that same key:
csrDER, err := pki.EncodeCSR(x509CSR, pk)
This explains why later key-consistency checks need not stop the sequence: the controller can create a request using the substituted key from the beginning. Those checks verify consistency between cryptographic objects, not Mallory's entitlement to select Alice's Secret.
The issuing controller carries that key to the output
In the same release, pkg/controller/certificates/issuing/issuing_controller.go, ProcessItem(), independently fetches the status-selected Secret without checking its ownership. It checks that the key parses and matches the Certificate specification, locates the owned CertificateRequest for the next revision, verifies request options, and handles denied, invalid, failed, or incomplete requests. It also checks that the key matches the CSR and that the returned certificate matches the CSR.
These are meaningful constraints. A successful issuance route must satisfy them; a status update alone does not guarantee that an issuer will return a certificate or that every reconciliation order will complete the sequence. They still do not authorize the source Secret.
When issuance reaches issueCertificate(), the selected key is encoded and included in the Secret data passed to the output writer:
secretData := internal.SecretData{
PrivateKey: pkData,
Certificate: req.Status.Certificate,
CA: req.Status.CA,
CertificateName: crt.Name,
IssuerName: req.Spec.IssuerRef.Name,
IssuerKind: req.Spec.IssuerRef.Kind,
IssuerGroup: req.Spec.IssuerRef.Group,
}
The function calls c.secretsUpdateData(ctx, crt, secretData). In pkg/controller/certificates/issuing/internal/secret.go, SecretsManager selects the destination using crt.Spec.SecretName, places data.PrivateKey in tls.key, and applies the output Secret. A caller allowed to read that destination can consequently receive key material from a source Secret that its own role could not read directly.
Release history
The requestmanager's unchecked lookup traces back to its introduction under pkg/controller/expcertificates in April 2020. I confirmed the lookup in the 0.15.0 predecessor source, 0.15.2, and 0.16.0. The July 2020 change referenced by the PR moved the controllers into the certificates package; it did not originally introduce this lookup. These inspections establish earlier code history, not a complete affected-version or default-exposure assessment of the old experimental controller implementation.
The named-Secret lookup remains in the inspected 1.19.6, 1.20.5, 1.21.0, and 1.21.2 consumer snapshots. The mainline correction was backported through PR #9368. 1.21.3 contains that backport and the ownership helper; its release notes explicitly describe this correction. I did not establish a fixed release for the older 1.19 or 1.20 branches or check every intermediate historical patch release.
The relevant primitive is use of a controller's Secret-reading authority on behalf of a user who can write Certificate status. The selected Secret is in the Certificate's namespace, and the key must pass the consumers' parsing and compatibility checks. To obtain it through the completed-issuance path described here, Mallory also needs a destination she can read and an issuance workflow that completes with that key.
The public PR's impact explanation and the inspected source agree on the permission distinction. A default namespace editor who already reads Alice's Secret does not obtain a new read capability. A custom role that permits status updates while withholding source-Secret reads can create the boundary that this missing ownership check crosses. The prevalence of such roles was not measured.
The keymanager also reconciles the temporary key and status field, so controller ordering is part of a runtime assessment. The source and public tests support the ownership failure; this report does not claim a measured success rate, a guaranteed timing window, arbitrary Secret-data extraction, or a working attack against a particular production installation.
No executable payload, cluster manifest, or captured key is included. The public PR contains the upstream explanation and test discussion. I inspected the source and test cases without running them.
The fix's public tests cover an unrelated Secret, a correctly labeled Secret owned by a different Certificate, a non-controller owner reference, a missing label, and the served output Secret masquerading as a temporary key Secret. Controller tests also exercise recovery from a status field naming an unowned Secret. The PR author describes removing the owner check and observing failures in these tests; those are the author's reported results, not executions performed for this write-up.
Useful local regression controls would compare a legitimate owned-key issuance, rejection of a foreign same-namespace key despite its label, continued rejection of a caller lacking the required API permissions, and recovery to an owned key without deleting the served certificate. End-to-end issuer and controller-ordering controls remain unperformed in this review.
Use cert-manager 1.21.3 or a later release containing the correction, following the project's release and upgrade guidance. For other release branches or distribution packages, verify that the equivalent fix is included rather than inferring it from an unrelated version number.
The shared predicate in 1.21.3, pkg/controller/certificates/secrets.go, binds the temporary Secret to the Certificate:
func IsNextPrivateKeySecret(secret *corev1.Secret, crt *cmapi.Certificate) bool {
return secret.Name != crt.Spec.SecretName &&
secret.Labels[cmapi.IsNextPrivateKeySecretLabelKey] == "true" &&
metav1.IsControlledBy(secret, crt)
}
Both consumers now use GetNextPrivateKeySecret(), which returns a not-found result for an unset name or a Secret that fails these checks. Its label-selected lookup also avoids fetching unrelated unlabeled Secret contents through the filtered informer cache. The exclusion of spec.secretName prevents the served certificate Secret from being mistaken for a disposable next-key Secret even if it has the label and owner reference.
The correction also changes the producer. The keymanager generates a fresh Secret name instead of creating or adopting a Secret under an untrusted status name. It reuses an existing named Secret only when ownership checks accept it, records a NotOwned event otherwise, and repoints status to its owned Secret rather than deleting that Secret when the names disagree. A rotation-policy path that cannot create the next key clears stale status. These changes preserve recovery while removing the status field's authority over resource selection.
cert-manager PR #9224 restores the ownership boundary between a Certificate and its temporary private-key Secret. In the inspected affected path, Certificate status can select an unrelated same-namespace private key, and a compatible completed issuance can copy that key into the Certificate's readable output Secret. The privilege boundary matters for custom roles that separate Certificate-status writes from source-Secret reads.
Richard Wall authored the accepted fix, and the public PR credits my report as @the-vibe-dev. The correction is confirmed in 1.21.3. This contribution has no separately established CVE or GHSA and is recorded as additional accepted upstream work.
Public references:
- Merged PR #9224 and reporter credit
- Mainline correction
- Release-1.21 backport PR #9368
- cert-manager 1.21.3 release notes
- Affected 1.21.0 requestmanager
- Affected 1.21.0 issuing controller
- Fixed 1.21.3 ownership helper
- Historical requestmanager introduction
Public-source report checked November 12, 2026.