Security

Secrets at Rest & in Transit

Intermediate

A secret stays secret only as long as its worst-handled copy stays hidden. Secrets usually leak not from the vault but from a config file, a log line, an error message, a chat thread, or a screenshot. Protect every place a secret can rest or pass through, not just the one you designed.

Secrets management has two jobs: keep secrets out of everywhere they should not be (source control, logs, plaintext config, messages), and protect them everywhere they are allowed to be (a managed vault, encrypted transport, memory). Get the first wrong and the second does not matter.

The Finperiti sample held its secrets in raw configuration with no Key Vault. That meant every secret was one repo clone, one misconfigured log, or one leaked config file away from exposure. The fix is structural: a vault as the single source, references instead of values, and disciplined transport.

Keep secrets out

Secret in raw config "ConnectionStrings": {
"Db": "Server=...;Password=P@ssw0rd!;"
}

It is committed to the repo and readable by anyone with clone access or a leaked config file. The password should be a Key Vault reference resolved at runtime.

Vault reference plus managed identity "ConnectionStrings": {
"Db": "@Microsoft.KeyVault(SecretUri=https://kv.../db-conn)"
}

No secret in the repo. The app's managed identity reads it from the vault at startup, and rotation happens in one place.

Protect secrets where they live & travel

Self-review checklist

Why it matters: Exposed secrets are the fastest path from a small mistake to a full breach. One committed key can hand an attacker the database. A vault, scanning, and disciplined transport turn secrets from scattered risks into a single, controlled asset you can rotate.