Secrets Management Principles
Secrets Management Principles
Before you reach for HashiCorp Vault or AWS Secrets Manager, you need to understand the principles that every serious secrets management system is built on. These four pillars — central storage, least privilege, rotation, and auditing — are not features of a specific tool. They are the architectural properties that separate a system that survives a breach from one that becomes the breach.
Teams at Google, Netflix, and Stripe do not all use the same secrets manager. What they share is ruthless adherence to these principles, enforced through policy, tooling, and culture. Understanding the "why" behind each principle is what lets you evaluate any tool — and make defensible trade-offs under pressure.
Pillar 1: Central Storage — One Source of Truth
The single most dangerous secrets anti-pattern in production is secret sprawl: the same database password lives in a .env file on the CI server, hardcoded in a Lambda deployment package, copy-pasted into Confluence, stored in a Kubernetes Secret created by hand, and emailed to three engineers who joined six months ago. When you need to rotate that credential, you have no idea where all the copies live. You will miss one. That one will be the one attackers find.
Central storage means there is exactly one authoritative location where a secret lives. Every consumer — your app, your CI pipeline, your Kubernetes pod — reads from that location at runtime. No copies, no caches with unbounded TTLs, no files checked into Git.
git-secrets, trufflehog, and gitleaks exist specifically to scan repos for accidentally committed credentials. At big tech companies, a single secret found in a public repo triggers an immediate incident response and mandatory rotation within minutes.
The practical shape of central storage in 2025: a secrets manager (Vault, AWS Secrets Manager, GCP Secret Manager, Azure Key Vault) with a well-defined path hierarchy, and strict policies about which paths applications can read. A concrete Vault path structure for a multi-environment setup:
The hierarchy is not cosmetic. It maps directly onto your ACL (Access Control List) policies. The api-service in production can read secret/production/api-service/* and nothing else. It cannot read staging secrets, it cannot read another service's credentials, and it absolutely cannot read CI registry credentials. This is enforced cryptographically — not by honor system.
Pillar 2: Least Privilege — Access What You Need, Nothing More
Least privilege in secrets management means every consumer has read access to exactly the secrets it needs to function, scoped to the environment it runs in, and no more. This sounds obvious, but violating it is the norm in most engineering organizations.
The most common failure mode: a shared service account or IAM role with read access to all secrets, because "it was easier to set up." When that account's credentials are compromised — stolen from a pod, leaked in a log line, phished from an engineer — the attacker has every secret in the system simultaneously.
Implementing least privilege requires service identities — a unique, verifiable identity for each workload. In Kubernetes, this is the ServiceAccount + Vault's Kubernetes auth method. In AWS, it is an IAM role bound to an ECS task or a pod via IRSA (IAM Roles for Service Accounts). The identity is not a username and password; it is a cryptographically attested fact about what the workload is and where it runs.
secret/production/ reveals your entire secret inventory to any compromised service — a serious information disclosure. Always explicitly deny the list and metadata capabilities on path prefixes above the service's own namespace.
Pillar 3: Rotation — Secrets Have Lifespans
A secret that never rotates is a time bomb. Every day it exists unchanged, the probability that it has been exfiltrated and not yet used grows. Rotation is the practice of replacing secrets on a regular schedule — or immediately upon suspicion of compromise — while keeping dependent services available. This is harder than it sounds.
There are two rotation patterns you need to understand:
- Manual rotation: an operator generates a new credential, updates the secrets manager, and rolls pods/services to pick it up. Viable for rarely-used secrets (annual SSL certificates, long-lived service accounts). High toil, human error risk.
- Automatic dynamic secrets: the secrets manager generates a fresh, short-lived credential on every request, and destroys it when the lease expires. The application never holds the same credential twice. This is the production-grade default for database passwords and cloud API keys — covered in depth in Lesson 4.
A practical rotation schedule for a production system:
Pillar 4: Auditing — Every Access Must Leave a Trail
Auditing is how you answer three questions after a security event: Was this secret accessed? By whom or what? When? Without audit logs, you cannot scope a breach. You cannot tell the difference between "attacker read the database password once" and "attacker has been exfiltrating it in bulk for six months." Both look identical from the outside.
A complete audit trail for secrets access includes the secret path, the accessor identity (service, pod, human operator), the operation (read, write, delete, renew), the timestamp, the source IP, and the outcome (success or deny). These logs must be:
- Immutable: written to a sink the accessor cannot modify (centralized logging, SIEM, write-once S3 bucket). An attacker with root on your app server should not be able to erase evidence of their secret reads.
- Retained: regulatory minimums are 90 days to 1 year for most industries (SOC 2, PCI-DSS). Store 13 months to cover year-over-year analysis.
- Alertable: anomalous patterns (bulk reads, reads from unexpected IPs, reads outside business hours, first-seen service account) should trigger real-time alerts — not just be discoverable after the fact.
Putting It Together: The Principle Hierarchy
These four principles are not independent checkboxes. They reinforce each other into a defense-in-depth posture:
- Central storage gives you the control plane — one place to enforce policy, rotate, and audit.
- Least privilege limits the blast radius when a service identity is compromised — the attacker gets only that service's secrets.
- Rotation limits the time window during which a stolen credential is valid — even if rotation fails, short-lived dynamic secrets expire automatically.
- Auditing ensures that compromise is detectable — both in real time (alerting) and after the fact (forensics).
The next lesson goes inside HashiCorp Vault's architecture to see exactly how it implements these principles at scale — the seal/unseal mechanism, auth methods, secret engines, and the policy language that ties them together.