Monthly research note. Theme: Cryptographic Infrastructure.

TL;DR

A focused memo on Logging for Forensics: Tamper Evident Event Pipelines: define the model, state the properties, then design the system so those properties remain true under failure and adversaries.

Key insight

Most failures are boundary failures: parsing, persistence, concurrency, retries, and upgrades.

Key takeaways

  • Treat key IDs as capabilities; never pass raw private key material across boundaries.
  • Side-channel constraints turn performance details into security boundaries.
  • Audit logs are evidence: make them tamper-evident and queryable during incidents.
  • Make boundaries boring: validate inputs, cap costs, and be deterministic where needed.
  • Automate guardrails; humans are for judgment, not for consistent enforcement.

Why this matters

  • Operational reality (rotation, audit, rollback) is where crypto systems fail.
  • Cryptographic agility is useless if rollout and rollback are unsafe.
  • Managed services shift responsibilities; they don’t remove them.
  • Most organizations don’t know where their keys live—until an incident.

Key questions

  • How do you separate duties (operators vs developers vs security responders)?
  • What is your disaster recovery story for KMS/HSM outages?
  • How do keys rotate safely (overlap windows, dual-sign, staged rollout)?
  • What is the root of trust (HSM, TPM, offline CA, threshold ceremony)?
  • What is the rollback plan when a new algorithm breaks production?
  • How do you prove usage (who signed what, when, and why) without leaking secrets?

Assumptions

  • Secrets leak through logs, metrics, crash dumps, and backups unless prevented.
  • Key usage is high-volume; audit pipelines must scale without sampling away truth.
  • Some environments are hostile (CI, ephemeral runners, shared build agents).
  • Attackers can observe timing and resource usage in shared environments.

Non-goals

  • Assuming “HSM = secure” without defining the threat model.
  • Designing audit trails that expose sensitive plaintext or identifiers.
Attack surface

Observability pipelines can be attacked (cardinality explosions, log injection). Protect them.

Model & invariants

A practical safety statement for key usage is least authority:

capability(key, purpose)¬use(key, other purpose).\text{capability}(\text{key},\ \text{purpose}) \Rightarrow \neg \text{use}(\text{key},\ \text{other purpose}).

Assume compromise and design for recovery: rotation, revocation, and forensics.

Bind every derived key to context: protocol, role, version, and transcript.

Invariant

Monotonicity beats timestamps: counters and epochs survive clock skew.

Security properties

  • Replay resistance: duplicated inputs do not change outcomes.
  • Least authority: privileges are scoped by purpose and time.
  • Evidence: critical actions emit verifiable audit events.
  • Authenticity: actions are bound to identity and purpose.

Failure modes

  • Recovery paths that only work when nothing is broken.
  • Config drift that weakens security posture over time.
  • Timeout ambiguity causing double-apply or partial state transitions.
  • Mixed-version behavior that violates assumptions silently.
Pitfall

Mixed-version deployments create states you never tested—plan for them explicitly.

Design sketch

flowchart LR
  policy["Policy (purpose + TTL)"] --> service["Signer Service"]
  service --> hsm["HSM/KMS"]
  service --> audit["Audit Stream"]
  audit --> siem["Detection/Response"]

Implementation notes

Never pass secrets around; pass handles with purpose constraints.

Rule of thumb

Acknowledge only after durability (or make “ack” explicitly best-effort).

#[derive(Clone, Copy, Debug)]
pub enum Purpose { Tls, Jwt, Firmware, Ledger }

pub struct KeyHandle { id: String, purpose: Purpose }

// Enforce purpose and algorithm policy at the boundary, not in the caller.

Verification strategy

  • Forensics tests: can you reconstruct “who signed what” under load?
  • Constant-time validation: microbenchmarks + side-channel tooling where feasible.
  • Chaos for KMS: inject throttling, partial outages, and latency spikes.
  • Rotation drills: staged rollout, dual-sign windows, and rollback.
  • Misuse resistance tests: wrong purpose, wrong context, wrong key type must fail.

Operational notes

  • Automate rotation with safety rails (canary, dual-sign, fast rollback).
  • Make audit streams append-only and queryable during incidents.
  • Separate duties and restrict production key access paths.
  • Test backup/restore for crypto material with the same rigor as databases.
  • Alert on policy drift: cipher suites, key sizes, algorithm toggles, TTL changes.
Operational note

Make degraded modes explicit: fail closed vs fail open is a policy choice.

What to monitor

  • Retry/timeout rates by endpoint and client cohort.
  • Admission-control / rate-limit rejections (by reason).
  • Authz failures and policy denials (unexpected spikes).
  • Invariant violation rate (should be ~0).
  • Error budget burn + tail latency under load.

Rollback plan

  • Preserve evidence (configs, artifacts, audit logs) to reconstruct what changed.
  • Define an explicit rollback trigger (metrics + thresholds).
  • Keep dual-write / dual-verify windows where appropriate.
  • Use canaries and staged rollout; stop early when signals degrade.
  • Prefer backward-compatible changes; avoid “flag day” upgrades.

Evidence

  • Jepsen (1) — Fault injection and correctness testing for distributed systems.
    • Evidence: Turn faults into test cases; prioritize partition and clock-skew scenarios that violate user-visible guarantees.
  • Designing Data-Intensive Applications (Kleppmann) (2) — The systems-engineering baseline for correctness, replication, and failure.
    • Evidence: Replication and consistency tradeoffs as engineering constraints; use as reference when naming guarantees.

Open questions

  • Which secrets must remain confidential for 10+ years and where are they stored today?
  • What is your plan for emergency revocation at global scale?
  • What would a KMS compromise look like in your telemetry?
  • How do you guarantee that audit does not become a data exfiltration channel?

Checklist

  • Assumptions listed and reviewed.
  • Safety properties stated as invariants.
  • Telemetry captures correctness signals.
  • Rollback plan rehearsed and automated.
  • Costs bounded (CPU/memory/bandwidth) under adversarial inputs.
  • Failure modes enumerated with mitigations.

Further reading

1.
Jepsen. Jepsen: Distributed Systems Safety Analysis [Internet]. Web; Available from: https://jepsen.io/
2.
Kleppmann M. Designing Data-Intensive Applications [Internet]. O’Reilly Media; 2017. Available from: https://dataintensive.net/