VCF

Unit 9 · Ship it and keep it alive

Leaked an API key? Revoke it first

Revoke the key at the provider first. Whoever copied it already has it, and it keeps working while you tidy the code. Then issue a new key, store it as an environment variable, and clean up.

The mix-up

What people often think

“Deleting the key from the code stops the leak.”

What the tutor says

Whoever copied the key already has it. Revoke it at the provider first, then clean up the code.

If someone wrote your house key code on a napkin, does repainting the door help?

How it works

Making the repository private does not un-copy the key either. Only revoking it makes the copy useless.

Secrets belong in environment variables, never in code, even in a private repository: private repos get shared, cloned and flipped public.

An example

What worksExample
1. Revoke the leaked key in the provider’s dashboard
2. Create a new key
3. Set it as an environment variable on the host
4. Redeploy
5. Remove the key from the code
The order matters.

Close cousins of this mix-up

The tutor watches for these in the same lesson.

  • “Clean the code first, then deal with the key.”

    While you tidy the code, the copied key keeps working. Revoke it first.

  • “Making the repo private undoes the leak.”

    Hiding the repo does not un-copy the key. Only revoking it makes the copy useless.

  • “A secret is safe in code as long as the repo is private.”

    Private repos get shared, cloned and flipped public. Secrets belong in environment variables, never in code.

Practise it with a tutor watching

Secrets

Respond to a leaked key in the right order: revoke first, then clean up, and know what git remembers.

25 minutes See it Build it Break it Say it
Start the lesson

Free, no account needed.