Skip to content

safekeys/audit-logging [built] ​

Every resolution is recorded — who, what scope, which jti, which host — without ever logging the secret. The audit log is append-only, captures denials as well as successes, and is the evidence trail that makes a security review and an incident response possible.

Status: built

Why this exists ​

A system that promises "the model never sees secrets" must be able to prove what happened without becoming a new place where secrets leak. An append-only record of identifiers and outcomes gives operators the accountability they need — including visibility of denials, which is often the first signal of an attack — while remaining worthless to anyone who steals it.

Design decisions ​

metadata-only-logging [accepted] ​

Decision: Log identifiers and outcomes, never values or key material.

Rationale: The audit log is a high-value target precisely because it is central and long-lived. Keeping it metadata-only means a breach of the log is an accountability problem, not a secret-disclosure one.

record-denials [accepted] ​

Decision: Record denied attempts as first-class events.

Rationale: Denials are frequently the earliest evidence of misuse or a probing attack, and an audit log that only shows successes hides the signal an incident responder most needs.

append-only-by-construction [accepted] ​

Decision: Provide no mutation path for audit records rather than relying on access control alone.

Rationale: A capability that does not exist cannot be misconfigured. Immutability by construction is stronger than immutability by policy.

How it works ​

Record a resolution attempt (record-resolve) ​

The sidecar reports each attempt to the audit log, successful or denied.

  1. Observe — Sidecar completes a resolve attempt with an outcome.
  2. Send — Sidecar sends the record to the control plane — requester, scope, jti, object id, host, outcome, timestamp.
  3. Record — Control plane appends the record; no plaintext is present in the payload.
  4. Observe — The record is queryable but not modifiable.

Query the audit log (query-audit) ​

An operator or auditor reviews resolution history.

  1. Authenticate — Caller authenticates with auditor or operator credentials.
  2. Send — Query by object, jti, principal, host, outcome, or time range.
  3. Receive — Matching records are returned; values are absent by construction.

Flow Diagrams ​

mermaid
sequenceDiagram
    participant User
    participant Browser
    participant IdP
    participant IdP as Identity Provider

    Browser->>IdP: OIDC flow — Caller authenticates with auditor or operator credentials.
    User->>Browser: send Query by object, jti, principal, host, outcome, or time range.
    User->>Browser: receive Matching records are returned; values are absent by construction.

Guarantees ​

zero-plaintext-in-audit ​

Audit records must never contain plaintext or key material.

Acceptance criteria:

  • [ ] Records carry identifiers and outcomes only
  • [ ] No record contains a secret value, DEK, or KEK
  • [ ] Stealing the entire audit log yields no secret

append-only ​

Audit records cannot be altered or deleted through the application.

Acceptance criteria:

  • [ ] No update or delete endpoint exists for audit records
  • [ ] Records are immutable once written
  • [ ] Storage is retained according to policy

denials-recorded ​

Failed attempts are recorded alongside successful ones.

Acceptance criteria:

  • [ ] Denied resolves are written with a denial outcome
  • [ ] Denial records name the requester and target
  • [ ] Denial-rate analysis is possible from the log alone

complete-attribution ​

A record is sufficient to answer who used what, where, and when.

Acceptance criteria:

  • [ ] Requester identity, scope, jti, object id, host, outcome, and timestamp present
  • [ ] Records join to the issuance event for the token
  • [ ] No record is ambiguous about which object was involved

Test specifications ​

audit-contains-no-plaintext ​

Given:

  • secret_value: "audit-test-secret"

When: record-resolve

Then:

  • assertion: no audit record contains the secret value
  • assertion: no record contains key material

Contracts verified: zero-plaintext-in-audit

audit-is-immutable ​

Given:

  • attempt_mutation: true

When: query-audit

Then:

  • assertion: no endpoint permits updating or deleting a record
  • assertion: attempts to mutate are rejected

Contracts verified: append-only

denials-are-recorded ​

Given:

  • valid_token: false

When: record-resolve

Then:

  • assertion: a record exists with a denial outcome
  • assertion: the record identifies the requester and target

Contracts verified: denials-recorded

attribution-complete ​

Given:

  • valid_token: true
  • injection_method: "inject-env"

When: record-resolve

Then:

  • assertion: the record contains requester, scope, jti, object id, host, and timestamp
  • assertion: the record joins to the token issuance event

Contracts verified: complete-attribution

Implementation ​

  • Primary: apps/control-plane/internal/store/store.go
  • Test code: apps/control-plane/internal/inttest/control_plane_test.go
  • Test code status: manual

See Also ​

  • safekeys/sidecar-resolution
  • safekeys/control-plane-api
  • safekeys/token-revocation