certrevoker GitHub
Proof of concept · kubernetes/kubernetes#18982

Revoke the certificate, not the CA.

Kubernetes can't revoke an x509 client certificate. Lose a laptop holding a kubeconfig and the credential stays valid until it expires, unless you rotate the whole cluster CA. certrevoker blocks one specific certificate within seconds, using only extension points Kubernetes already has.

View on GitHub
Revoke to deny10smeasured at kube-apiserver, set by the webhook cache TTL
CA rotations0and no changes to Kubernetes itself

The problem

kube-apiserver accepts any client certificate that chains to its CA and hasn't expired. It has no revocation list and no OCSP check, and nothing else stops a certificate.

Open since2015kubernetes/kubernetes#18982, “Support for managing revoked certs”

No revocation check

kube-apiserver checks the chain and the expiry date, nothing more. There is no CRL or OCSP support, and no denylist.

Deleting the CSR does nothing

Certificates issued through the CSR API keep working after the CSR is gone, and Kubernetes deletes approved CSRs within an hour anyway.

RBAC isn't enough

Remove the bindings and the user still gets everything granted to system:authenticated. system:masters skips authorization altogether.

How it works

Since v1.32, kube-apiserver tags every certificate-authenticated request with the certificate's SHA-256, as authentication.kubernetes.io/credential-id. certrevoker puts an authorization webhook in front of Node and RBAC that denies any request carrying a revoked ID.

  1. 1 · requestClient certificate
  2. 2 · authenticationX509SHA256=…
  3. 3 · always firstsystem:masters
  4. 4 · webhookcertrevoker: deny if revoked
  5. 5 · authorizerNode
  6. 6 · authorizerRBAC
Webhook

An explicit deny, before RBAC

The webhook returns Deny for a revoked credential ID and no opinion otherwise. An explicit deny stops the chain, so no RBAC grant applies to the revoked certificate. Kubelets and aggregated API servers authorize through SubjectAccessReviews, which reach the same webhook.

Inventory

A record Kubernetes doesn't keep

Every client certificate issued through the CSR API is copied into an IssuedCertificate object before the CSR disappears. Credential IDs the webhook sees in use are recorded too, which catches certificates kubeadm signed directly, such as admin.conf.

Portal

Revoke with a reason

Log in with a Kubernetes token. The portal uses that token for every call, so RBAC decides who can revoke and the audit log records them. Paste a certificate or kubeconfig to find its ID. Revocations are ordinary objects, so kubectl works as well.

Tested end to end

Run with scripts/e2e.sh on a kubeadm 1.37.2 cluster with one control-plane node and one worker. Every scenario was checked against the live cluster.

ScenarioWhat happenedTimeCheck
Revoke in the portal, then call kube-apiserverDenied: client certificate X509SHA256=… has been revoked: laptop stolen10spass
Revoked certificate, straight to a kubeletDenied through the kubelet's SubjectAccessReview290skubelet cache, 5m defaultpass
cluster-admin through an RBAC groupDenied; RBAC grants don't apply after an explicit deny0spass
Other usersUnaffected–pass
kubeadm admin.conf, controller-manager, schedulerFound in use and added to the inventory, though never issued through a CSR<15spass
Credential ID vs kubectl auth whoamiIdentical–pass
Webhook scaled to zeroRevoked certificate works again (fails open by design), and is denied again once the webhook is back0spass
kubeadm super-admin.confsystem:masters is allowed before any webhook runs, so revoking it has no effect. Expected.–limit
Foot · 8 shownof 26 checks; all are in the README7 pass + 1 known limitcounted down this column290s maxslowest path: the kubelet cache26 / 26checks passed

The portal

Every certificate the cluster has issued or used, with its validity, when it was last seen, and one action. The portal and this site share one design: flat cells, cyan for what's selected, copper only for revocations.

The inventory: view cells for active, revoked, expired and all certificates above a ledger of certificates with Revoke actions
Inventory: CSR-issued and observed certificates
A revoked certificate's page showing the reason, who revoked it, the denied-request count and when the revocation will be removed
A revoked certificate, with its denied-request count
The Inspect page computing the credential ID of kubeadm's super-admin certificate and flagging system:masters as not enforceable
Inspect: super-admin.conf flagged as not enforceable

Decisions before you deploy

certrevoker is a proof of concept. These trade-offs are yours to accept or change.

Fails open

The kubelets, controller-manager and scheduler authenticate with client certificates, so the webhook uses failurePolicy: NoOpinion. A certrevoker outage then can't break the cluster, but revoked certificates work until it's back.

system:masters is out of reach

No authorizer can deny that group. Keep certificates like kubeadm's super-admin.conf offline. If one leaks, rotating the CA is still the only fix.

Caches set the delay

About 10s at kube-apiserver (unauthorizedTTL), but up to 5 minutes for requests sent directly to a kubelet, unless kubelets lower cacheAuthorizedTTL. Requests already in progress continue.

VisibilityCertificates signed outside the CSR API appear only once they're used, without validity dates unless you paste them in.
CA key compromiseAnyone holding the CA key can mint new certificates. Revocation lists can't fix that; only CA rotation can.
HardeningSingle replica, script-generated TLS, in-memory portal sessions, and no login rate limit.
RequirementsKubernetes 1.32 or later, with root on the control-plane nodes to change kube-apiserver's flags. Managed services don't allow that.

Deploy

Four steps on a kubeadm-style cluster. The README has the details and how to roll back.

1 · Build

Build the binary and image, then import the image into containerd on the control-plane node.

go build -o bin/certrevoker \
  ./cmd/certrevoker
docker build -t certrevoker:dev .
2 · TLS

A private CA for the webhook and portal, and the client certificate kube-apiserver uses to call the webhook.

./scripts/gen-certs.sh tls \
  <control-plane-ip>
3 · Install

CRDs, RBAC and the Deployment, installed before kube-apiserver starts calling the webhook.

kubectl apply -f deploy/
kubectl apply -f tls/secret.yaml
4 · Authorize

Swap --authorization-mode for the structured config, which keeps Node and RBAC after the webhook.

--authorization-config=
/etc/kubernetes/certrevoker/
authz-config.yaml

Upstream

The likely long-term fix is SIG Auth's KEP-6285, structured x509 authentication configuration. It adds CEL validation rules that can reject specific credential IDs during authentication, which would also cover system:masters. It is still provisional. certrevoker shows what is possible now, and the gaps a built-in mechanism has to close: kubelets, caches, and knowing which certificates exist.

Source

Written in Go on the Kubernetes client libraries. Unit tests run in CI, and an end-to-end script drives a real cluster.

github.com/raesene/certrevoker