Defensive Security

Secrets Management for Small Teams: Getting Credentials Out of the Repository

Every small team starts the same way. A database password in a config file, an API key pasted into chat so a colleague can test something, production credentials in a file on someone's laptop. None of it was a decision; it was just the quickest thing at the time.

Secrets Management for Small Teams: Getting Credentials Out of the Repository

The problem is that credentials are sticky. They spread into backups, repository history, chat archives and laptops, and they outlive the people who created them.

Why committed secrets are worse than they look

Deleting a secret from a file and committing the change does not remove it. It remains in history, retrievable by anyone with access to the repository, and present in every clone already made.

If the repository was ever public, or became public briefly, assume the credential is compromised. Automated scanners watch public repositories continuously and act within minutes.

The only correct response to a committed secret is to rotate it. Rewriting history is worth doing afterwards for hygiene, but it does not undo exposure and it does not reach the clones.

A path that works at small scale

Step one: stop adding new ones. Add secret scanning to the pipeline so a commit containing a credential pattern fails. Most platforms offer this; several good open-source scanners exist. This is a one-afternoon change that prevents the problem growing while you deal with the backlog.

Step two: find what is already there. Scan full history, not just the current checkout. Expect to be surprised. Build a list, rotate in order of blast radius — production database and cloud credentials first, then third-party APIs that can spend money or send mail, then everything else.

Step three: move configuration out of code. Environment variables with a committed .env.example listing variable names and no values. The real file stays out of version control. This is enough for a small team and costs nothing.

Step four: use a real secret store when you outgrow that. Your cloud provider's secret manager is usually the cheapest sensible option, with the application fetching at startup using an identity attached to the workload rather than a credential of its own. The managed options are inexpensive at small scale and remove the problem of who holds the master copy.

Rotation is the control people skip

A credential nobody can rotate quickly is a credential that stays valid after every departure and every laptop loss.

For each production secret, answer: who can rotate it, how long does it take, and what breaks when it changes? If nobody knows, you do not have a rotation capability, and the first time you need one will be during an incident.

Build the ability to rotate before you need it. Supporting two valid credentials during an overlap window turns rotation from a risky outage into a routine operation.

Human credentials need a different answer

Secret managers handle machine credentials. Shared human passwords — the hosting account, the domain registrar, the social media logins — need a team password manager.

The registrar and DNS accounts deserve particular attention. They are often registered to one person's personal email, protected by a password nobody else has, and they control your entire domain. This is a single point of failure that is discovered at the worst possible moment.

Reduce how many secrets exist

The most durable improvement is needing fewer of them.

Use workload identity where your platform supports it, so an application proves what it is rather than presenting a stored key. Prefer short-lived tokens over long-lived keys. Scope every credential to the minimum it needs, so an exposure is contained rather than total.

A credential that does not exist cannot be committed, pasted into chat, or found in a backup two years later.

Frequently asked questions

We committed an API key and removed it. Are we fine?
No. It remains in git history and in every existing clone. Rotate the credential; rewriting history is useful hygiene afterwards but does not undo the exposure.
Are .env files good enough?
For a small team, yes, provided the real file is never committed and a .env.example documents the variable names. Move to a managed secret store as the team or environment count grows.
How often should secrets be rotated?
On any suspicion of exposure, on staff departure, and otherwise on a schedule you can actually meet. The more important capability is being able to rotate quickly without causing an outage.

Related reading

0 comments

Leave a comment

Comments are moderated before appearing.