TRUFFLEHOG

COMPANY

RESOURCES

Truffle Security

Revoking a Leaked Secret Doesn’t Have to Be a Gamble

Revoking a Leaked Secret Doesn’t Have to Be a Gamble

Truffle Security

A leaked secret can stay live long after someone finds it, waiting on one question: what will break if this is turned off? Until someone can answer it, the ticket sits, and the secret keeps working.

That question has an answer, and the steps below get to it. They let a team replace an exposed secret, switch it off in a way that can be undone, and confirm afterward that the old value no longer works.

Why revoking feels risky

Revoking a key takes one click. The risk is everything that click touches. A key that has been in use for two years can sit in a cron job, a deployment pipeline, a partner integration, and a service that has not been opened since its original owner moved teams.

The team that receives the alert is rarely the team that runs those systems. They can see the key. They cannot see what depends on it, and revoking without that answer is a guess. A wrong guess is an outage.

So the work is answering that question first, then changing the order of operations so a wrong answer is cheap to undo.

Revoking without an outage, in five steps: check usage, meaning when the key was last used and by what; replace it, with a new secret issued and consumers moved; disable the old one, which is reversible, and watch errors and logs; delete it once the window passes quietly; and retest, because the old value must fail. Disabling can be undone in seconds if something breaks.

1. Find out what still uses it

Start with the provider’s own record of use. AWS shows when each access key was last used and for which service. Google Cloud reports activity for service account keys. Most SaaS providers keep an audit log of API calls. If the key has not been used in months, there is nothing to break, and it can be revoked now.

If it is in use, the same logs tell you where from: source addresses, user agents, the services being called. Pair that with a search of the places the secret would be configured, such as vault entries, CI variables, and deployment manifests, and you have a list of consumers to move.

This is also the moment to check what the key can reach. A key that can write to production storage and has been public for a week cannot wait for a rotation window. A read-only key in an internal system usually can.

2. Issue the replacement before you pull the old one

The safest rotations overlap. Many providers let a single identity hold more than one active secret at a time, which is exactly what you need:

  • An AWS IAM user can have two access keys at once.

  • A Google Cloud service account can hold several keys.

  • A GitHub App can have more than one private key registered.

  • Stripe can roll an API key and keep the old one working for a period you choose.

Create the new secret, store it in your vault, and move each consumer over. If the services read the secret from the vault at runtime, this is one change. If the value is pasted into configs, it is one change per config, which is worth knowing before the next incident.

Where a provider allows only one secret per identity, create a second identity with the same permissions, move consumers to it, and retire the first.

Two keys, one cutover. The new key is issued while the old key is still live, so both work while consumers switch. After consumers have moved, the old key is disabled, which is reversible, and later deleted. The new key stays live throughout, so nothing goes dark.

3. Disable before you delete

Several providers separate turning a secret off from destroying it. AWS can mark an access key inactive. Google Cloud can disable a service account key. Both can be reversed in seconds.

Use that. Disable the old secret, then watch error rates and the provider’s logs for a set period. If something breaks, re-enable it, fix the consumer you missed, and try again. Changes can take a little while to apply across a provider, so give it time before you conclude nothing depends on it.

When the window passes quietly, delete it. A reversible step turns revocation from a gamble into an ordinary change with a rollback plan.

4. Prove it stopped working

Test the exposed value itself, not the replacement. Try to authenticate with the old secret and confirm the provider refuses it. Record the result.

That check is the only evidence the exposure ended. A deploy that rolled out the new key shows the new key works. It says nothing about the old one, which can stay valid if it was disabled on the wrong account, missed in one region, or re-enabled during a rollback.

Retesting works best where the provider gives a definite answer, which is true of most cloud and SaaS APIs: a revoked key gets a specific rejection. Database passwords and internal systems are harder, because a failed connection can mean the secret is dead or that the test simply could not reach the system. For those, run the check from inside the network, or have the system’s owner confirm the old value no longer works.

When it cannot wait

Sometimes the overlap is a luxury. If the secret is public, verified live, and can reach production data, revoke it first and handle the fallout second. An outage you start on purpose, with the on-call team ready, is easier to recover from than access you cannot see.

Can it wait for a rotation window? If the key has not been used recently, revoke it now, because nothing depends on it. If it is public, live, and able to reach production data, revoke it now, accept the breakage, and have on-call ready. Otherwise, rotate with an overlap: replace it, move consumers, disable, watch, delete, and retest. Either way, retest the old secret and record that it fails.

The same retest applies. Fast revocation still needs proof.

Make the next one easier

Every rotation shows where the next one will hurt. A few habits shrink that list:

  • Read secrets from the vault at runtime. Rotation becomes one change instead of a hunt through configs.

  • Give each service and environment its own secret. Revoking one key should not take down five systems.

  • Use short-lived tokens where the platform supports them. Workload identity and OIDC federation leave less to rotate.

  • Keep an owner on every secret. The person who can answer what depends on it should be one message away.

For provider-specific steps, How to Rotate has open-source rotation tutorials for dozens of services.

The worry that revoking will break something is reasonable. The answer is a procedure: know what uses the secret, replace it, disable the old one, watch, delete, and confirm it no longer works.

The Dig · Truffle Security Co.

Ready to talk to the team?

See how TruffleHog Enterprise shows what each live secret can reach and who owns it, then retests after rotation to confirm the old secret no longer works.

infra