The "Key" to Security is Deleting Your Keys?

PUBLISHED:
February 12, 2026
|
BY:
Geet Hiwarat

It’s 3 AM. Your slack fires up. An bot attack just scraped a hardcoded AWS Access Key from a public GitHub repository that a developer accidentally committed. Within minutes, compute instances are spinning up in eu-west-1 mining crypto.

If you’ve worked in cloud security long enough, this isn't a hypothetical scenario it’s a rite of passage.

Managing secrets, database passwords, API tokens, TLS certificates was easy when we had a monolithic server in a locked cage. We just wrote them into a configuration file and forgot about them. But in the cloud-native world of ephemeral containers, serverless functions, and distributed microservices, that model is dead. The perimeter is gone, and identity is the new firewall.

This is a deep dive into how we handle secrets today: the native tools, the architectural patterns, the "Secret Zero" paradox, and the war stories that taught us why hardcoding is a cardinal sin.

Table of Contents

  1. The Core Problem: Static Secrets in a Dynamic World
  2. Native Cloud Vaults: A Comparative Look
  3. The Kubernetes Headache
  4. The "Secret Zero" Problem and Identity Federation
  5. War Stories: How It Goes Wrong
  6. Conclusion

The Core Problem: Static Secrets in a Dynamic World

In a traditional setup, trust was implied by the network. If App-A could talk to DB-B over the LAN, it was trusted. In the cloud, Zero Trust mandates that every single connection be authenticated. This explosion of microservices leads to an explosion of secrets, a phenomenon we call Secrets Sprawl.

As engineers, we classify secrets into two buckets:

  1. Static Secrets: Long-lived passwords or API keys (e.g., Stripe keys). These are dangerous because if they leak, they are valid until someone manually rotates them.
  2. Dynamic Secrets: Ephemeral, short-lived credentials generated on the fly. This is the holy grail. If a dynamic credential leaks, it’s useless within minutes (or seconds).

Native Cloud Vaults: A Comparative Look

Every major cloud provider has built a vault-as-a-service. They all encrypt data, but their architectural opinions differ significantly. Here is how they stack up from an engineering POV.

AWS Secrets Manager: The Rotation Heavyweight

In the AWS ecosystem, Secrets Manager is the go-to. Its superpower is Envelope Encryption using AWS KMS. The service doesn't just encrypt your secret; it encrypts the data key that encrypts your secret, creating a hierarchy of trust.

The killer feature here is automated rotation. AWS delegates rotation logic to Lambda functions. When a rotation triggers, the Lambda spins up, talks to the database, changes the password, and updates the secret value.

  • Pro Tip: Use the "Alternating Users" strategy for rotation. This maintains two database users (user_A and user_B). While user_A is active, the Lambda rotates user_B's password and then flips the secret pointer. This ensures zero downtime for your applications during the rotation window.

Azure Key Vault: Hardware-Backed Assurance

Azure Key Vault (AKV) distinguishes itself with its tiering. The Premium Tier offers keys backed by Hardware Security Modules (HSMs) validated to FIPS 140-2 Level 2 or 3.

  • The Gotcha: If you need Key Sovereignty, where even Microsoft technically cannot access your keys, you need Managed HSM. This gives you a single-tenant cluster of HSMs, essential for highly regulated industries like banking.

GCP Secret Manager: Global by Default

Google’s engineering philosophy often defaults to global scale, and Secret Manager is no exception. Unlike AWS, where secrets are regional, GCP allows for automatic global replication.

  • The Engineer's View: This simplifies disaster recovery massively. You don't need to write custom scripts to sync secrets from us-east1 to europe-west1; Google handles the consistency for you.

The Kubernetes Headache

Kubernetes is the operating system of the cloud, but its native secret management is... lacking. By default, Kubernetes Secrets are stored in etcd as base64 encoded strings not encrypted. Anyone with API access or disk access to etcd can read them in plaintext.

We have three main patterns to fix this:

  1. Encryption at Rest: You configure the API server to encrypt secrets before writing them to etcd, using a key from your cloud provider (AWS KMS, Google Cloud KMS). This is the bare minimum for production.
  2. External Secrets Operator (ESO): This is the most popular "bridge." ESO runs inside your cluster, polls your external vault (like AWS Secrets Manager), and syncs the data into native Kubernetes Secrets.
    • Trade-off: You still have secrets in etcd, but you get a centralized source of truth.
  3. Secrets Store CSI Driver: This mounts secrets directly from the vault into the Pod as a volume. The secret never touches etcd; it lives only in the Pod's memory (tmpfs).
    • Trade-off: It's more secure, but many legacy apps struggle to read secrets from files and expect environment variables.

The "Secret Zero" Problem and Identity Federation

Here is the paradox: To fetch a secret from a vault, your application needs a token to authenticate. Where do you store that token? That’s the Secret Zero problem.

If you hardcode an AWS Access Key in your CI/CD runner to deploy code, you’ve just moved the problem, not solved it. The modern solution is Identity Federation (OIDC).

GitHub Actions & AWS: The Keyless Flow

Instead of storing long-lived AWS credentials in GitHub Secrets, we configure AWS to trust GitHub as an OIDC Identity Provider.

  1. GitHub signs a JWT token asserting the workflow's identity (repo, branch, commit).
  2. The runner sends this token to AWS STS (AssumeRoleWithWebIdentity).
  3. AWS validates the signature and issues temporary credentials.

Result? No static keys to leak. If the workflow isn't running, no credentials exist. This is how you stop the bleeding in CI/CD pipelines.

War Stories: How It Goes Wrong

We learn more from failures than successes. Here are three incidents that shaped our current security posture.

1. The SSRF Classic: Capital One

An attacker tricked a WAF into making a request to the AWS Instance Metadata Service (IMDSv1). Because IMDSv1 was a simple request/response protocol without authentication, it happily handed over the EC2 instance's temporary IAM credentials. The attacker used these to dump S3 buckets.

  • The Fix: AWS introduced IMDSv2, which requires a session token and (critically) sets the IP packet TTL to 1. This prevents WAFs and proxies from forwarding the request. Enforce IMDSv2 everywhere.

2. The Supply Chain Hack: Codecov

Attackers modified the Codecov Bash Uploader script. How did they get in? They found a static Google Cloud Storage credential inside a Codecov Docker image. Even though it wasn't in the final layer, it was retrievable from the image history.

  • The Lesson: Never build secrets into Docker images, not even intermediate ones. Use multi-stage builds carefully, or better yet, inject credentials at runtime only.

3. Session Hijacking: CircleCI

An engineer's laptop was compromised with malware that stole a valid 2FA-backed SSO session cookie. The attackers impersonated the engineer and accessed production seeds. Rotating the secrets wasn't enough; they had to rotate the signing keys that protected the secrets.

  • The Lesson: "Rolling secrets" is reactive. Proactive security means short session limits and hardware-bound keys (FIDO2) that can't be stolen via cookies.

Conclusion

The days of .env files and hardcoded config maps are over. As cloud security engineers, our job is to architect systems where secrets are:

  1. Ephemeral: They exist only as long as needed.
  2. Identity-Based: Workloads prove who they are, not what they know.
  3. Centralized: One source of truth, replicated automatically.

If you are still manually rotating keys, you are fighting a losing battle. Automate it, federate it, and sleep better at night.

Security leaders must recognize that the secrets battle is fundamentally a workload identity problem, not a storage one. To architect this keyless, identity-centric future and secure your CI/CD pipelines, strategic guidance is paramount. This is precisely the domain of specialized counsel, such as the strategic cloud security expertise provided by we45.

FAQ

What is Secrets Sprawl in cloud security?

Secrets Sprawl is the phenomenon where the explosion of microservices in a Zero Trust, cloud-native environment leads to a corresponding, massive increase in the number of secrets that must be managed, authenticated, and secured.

What is the difference between static and dynamic secrets?

Static secrets are long-lived credentials (like passwords or API keys) that remain valid until a manual rotation. Dynamic secrets are the preferred, ephemeral credentials generated on the fly, which become useless seconds or minutes after a leak.

How does AWS Secrets Manager handle rotation?

AWS Secrets Manager delegates its automated rotation logic to Lambda functions. It is recommended to use the "Alternating Users" strategy, which maintains two database users to ensure zero downtime for applications during the rotation window.

What is the primary advantage of GCP Secret Manager over regional vaults?

GCP Secret Manager's default engineering philosophy is global scale, allowing for automatic global replication of secrets. This simplifies disaster recovery by eliminating the need for custom scripts to sync secrets across different regions.

Why is Kubernetes native secret management considered insecure by default?

By default, Kubernetes Secrets are stored in etcd as base64 encoded strings, which are not encrypted. This allows anyone with API access or disk access to etcd to read the secret values in plaintext.

What is the Secret Zero Problem?

The Secret Zero problem is the paradox where an application requires an initial token or credential to authenticate itself and fetch its first secret from a vault. Modern solutions like Identity Federation are used to solve this by eliminating the need to store this initial token.

How does Identity Federation (OIDC) eliminate static keys in CI/CD pipelines?

Using OIDC, services like GitHub Actions are configured to act as an Identity Provider that AWS trusts. The runner sends a temporary signed JWT token to AWS STS, which validates the signature and issues temporary, ephemeral credentials. This ensures no static keys exist to be leaked.

What is the fix for the security flaw exploited in the Capital One breach?

The fix was the introduction of AWS IMDSv2 (Instance Metadata Service Version 2). This version requires a session token and sets the IP packet TTL to 1, which prevents WAFs and proxies from forwarding the request and stealing the EC2 instance's temporary IAM credentials.

What is the crucial lesson from the Codecov supply chain hack?

The lesson is to never build secrets into Docker images, not even intermediate ones, as they can be retrieved from the image history. Credentials should be injected at runtime only.

Geet Hiwarat

I’m Geet Hirawat—a cloud security engineer who breaks things to make them better. I work across AWS, Azure, and Kubernetes, locking down misconfigurations, tightening container security, and making DevSecOps actually work. I’m big on automation, obsessed with Rust, and always ready to script the pain away. If it runs in the cloud, I want to know how to secure it. And how to break it first. Want to talk security, cloud, or why Rust beats your favorite language? Ping me (just don’t expect an ICMP reply).
View all blogs
X