Skip to content
BENIBIX Learn

Secrets Management

Development🔐 SecurityDefences

Also known as Secret Management, Secrets Manager, Vault, Secrets

Keeping passwords and keys out of your code, in a safe place apps read from.

Think of it like

Think of it like a safe for your keys. You do not leave them taped to the front door.

Example

Lucy moves her database password out of config.js and into a vault. Her app reads it when it starts. The repo no longer holds it.

Why it matters

Leaked secrets are one of the commonest causes of breaches. Code gets shared; secrets must not travel with it.

Definition

Secrets management keeps passwords and keys out of your code. A secret in a code file ends up in every copy of the repo, forever. Instead, apps read secrets from settings or a vault when they start. A vault also logs who read each secret. It makes them easy to change, too. Changing secrets on a schedule is called rotation.

Example code

console
$ export DATABASE_PASSWORD='s3cret'
$ node app.js
The app reads the password from a setting, not from a file in the repo.

Common mistake

Deleting a leaked key from the latest commit and stopping there. It is still in Git history; revoke it and make a new one.

Key takeaways

  1. 1
    Never in code. Not even once.
  2. 2
    Read at start-up. From the environment or a vault.
  3. 3
    Rotate. Change them on a schedule.