You don't want long-lived keys

· security · Source ↗

TLDR

  • Long-lived keys accumulate risk over time; ephemeral credentials like EC2 Instance Connect and PyPI trusted publishers make rotation a built-in feature.

Key Takeaways

  • Key risk compounds with time: departing employees, brute-force exposure, and AES-GCM message limits (after 2^32 messages) all grow the longer a key lives.
  • Ephemeral keys (~1 day lifetime) sidestep rotation pain by making credential refresh automatic, eliminating stale docs and botched rollout outages.
  • EC2 Instance Connect, PyPI trusted publishers, and SSO replace static SSH keys, static PyPI tokens, and per-app passwords with time-limited assertions tied to recent auth checks.
  • When long-lived keys are unavoidable: limit scope to a specific shard or function, rotate at least quarterly, and concentrate maintenance in a dedicated security team.
  • Distributing key rotation toil across all engineering teams leads to stale documentation, forgotten deadlines, and outages with wide blast radius when rollouts are rushed.

Hacker News Comment Review

  • The brute-force-over-time argument drew pushback: rotation only forces repeated guessing; adding key length is more effective and does not require operational overhead.
  • Service-to-service integrations like Sentry-to-Jira expose the thesis’s practical limit – durable access is still needed, and whether it is called a key or an OAuth refresh token is largely semantic.
  • Operational friction cuts both ways: APIs that allow only a single active token make zero-downtime rotation impossible, and some operators prefer static API key simplicity over ephemeral credential pipeline complexity.

Notable Comments

  • @peterldowns: OIDC with IRSA or Workload Identity Federation in practice means no stored credentials at all – services authenticate to each other without any explicit keys in a vault.
  • @gleenn: Post-Vercel-compromise key rotation across many services in a hurry was painful enough to motivate real adoption of automated short-lived key infrastructure.

Original | Discuss on HN