Skip to content

Commit 6f02eac

Browse files
committed
feat: configure audit policy to redact MachineAccountKey private keys from audit logs
1 parent 7bf5774 commit 6f02eac

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

config/components/apiserver-audit-logging/audit-policy-configmap.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ data:
142142
- group: "" # core API group
143143
resources: ["secrets", "configmaps"]
144144
145+
# Log MachineAccountKey at Metadata level to redact private key from audit logs
146+
# The privateKey is only returned in the response body on creation, so we omit
147+
# the response to prevent credential leakage in audit logs
148+
- level: Metadata
149+
resources:
150+
- group: "identity.miloapis.com"
151+
resources: ["machineaccountkeys"]
152+
145153
# Log Milo API resources at RequestResponse level to capture full context
146154
- level: RequestResponse
147155
resources:

pkg/apis/identity/v1alpha1/machineaccountkey_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ type MachineAccountKeyStatus struct {
5353
// persisted to etcd. Any value present on a GET or LIST response indicates a
5454
// bug in the server implementation.
5555
//
56-
// Note: private key material will appear in API server audit logs for creation
57-
// events. This matches the behavior of similar systems (GCP service account keys).
56+
// Note: The private key is NOT logged in API server audit logs. The audit policy
57+
// is configured to log MachineAccountKey resources at the Metadata level only,
58+
// which redacts the response body containing the private key.
5859
//
5960
// +kubebuilder:validation:Optional
6061
PrivateKey string `json:"privateKey,omitempty"`

0 commit comments

Comments
 (0)