Skip to content

Lesson 11 of 14 · 14m

Secret Manager vs Key Vault: Same Shape, Different Knives

GCP scopes secrets as individual IAM resources; Azure's vault has two auth models — and one of them lets Contributor self-grant.

GCP: the secret is a resource

Secret Manager treats each secret as a first-class resource carrying its own IAM policy. roles/secretmanager.secretAccessor grants secretmanager.versions.access — permission to read payload bytes. Reads are versioned — gcloud secrets versions access latest --secret=prod-db resolves the latest alias; older versions remain readable until disabled or destroyed — and replication is either automatic or user-managed to specific regions. The design center: per-secret IAM is normal and cheap. Grant the runtime service account accessor on prod-db and it can read prod-db and nothing else. One workload, one secret, one binding — no vault-wide blast radius unless you build one at the project level.

Azure: pick your authorization model

Key Vault bundles secrets, keys, and certificates inside one vault and offers two permission systems — this choice is the trap.

Vault access policy is the legacy model: per-principal get/list/set permissions configured inside the vault's own policy blade. Its flaw is structural — anyone with management-plane write on the vault, which means Contributor, can edit the access policy and grant themselves get on every secret inside. Control-plane write silently became data-plane read, and the grant doesn't even appear in az role assignment list output.

Azure RBAC mode fixes it: data access requires roles like Key Vault Secrets User, Key Vault Secrets Officer, or Key Vault Administrator, and granting those requires Microsoft.Authorization/roleAssignments/write — the self-grant hole closes because the Contributor can't grant roles. Use RBAC mode.

Two lifecycle switches that matter: soft-delete — mandatory for all vaults since February 2025 — gives deleted secrets a recovery window, and purge protection on top blocks even the vault admin from permanently deleting during that window. Enable both. The second one is what stands between you and ransom-delete.

The vault moved the boundary; it didn't remove it

The wrong mental model: "it's in a vault so it's safe." A vault relocates the trust boundary — to the IAM wrapping the vault, and to whatever carries the secret to the app. Anyone with accessor reads every version, current and historical, so disabled-version hygiene matters. And the delivery path leaks independently of the vault: a secret injected as an environment variable shows up in orchestration metadata, container specs, crash dumps, and /proc/environ — surfaces nobody thinks of as secret storage but every exfiltration writeup features.

Fetching at runtime from the vault is tighter — the secret never sits in an env var — at a real price: vault availability becomes a cold-start dependency, and naive per-request fetches add latency and rate-limit exposure. The pattern that holds up: fetch at startup, cache with a TTL, fail closed.

Version lifecycle is part of the security story too: gcloud secrets versions disable/destroy kill specific versions — destroyed payloads are unrecoverable even though the secret object survives, which is the right answer to "we rotated but the old value is still readable." And the Azure vault has a network side: the vault firewall plus private endpoints gate which networks can ask for secrets at all — IAM decides who, the firewall decides from where.

And check the logging defaults: GCP secret reads are Data Access events — invisible unless you enabled them — and Azure vault reads require a diagnostic setting on the vault. Under stock defaults, the exfiltration of your secrets records nothing at all.

Land it

Runtime-fetch over env-injection where the dependency is acceptable. Accessor or Secrets-User scoped per secret or per vault to the workload identity only. RBAC mode plus purge protection on every vault. Read logging enabled before you need it — after is the other team's timeline. And keep roles/secretmanager.admin and Key Vault Secrets Officer off workload identities: rotation and deletion powers don't belong to the reader.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.