Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 2 min read

A leaked key must be revoked, not just deleted

You pushed an API key by mistake. You noticed, deleted the file and pushed again. Is the problem gone? No. GitHub's documentation says to treat any leaked secret as compromised, and that removing it from the code, pushi

You pushed an API key by mistake. You noticed, deleted the file and pushed again. Is the problem gone?

No. GitHub's documentation says to treat any leaked secret as compromised, and that removing it from the code, pushing a new commit, or deleting and recreating the repository does not stop it from being exploited.

The numbers show why this matters. In a study published on November 23, 2026, GitGuardian warned companies about leaked credentials. Of the valid credentials it found, 62% still worked afterward, and 77.8% of the leaks that were public when it emailed were still accessible in late November. The median high-impact leak had already been public for 320 days before it was flagged.

What to do, following GitHub's remediation guide

  1. Find out what the secret is, which provider issued it, and who owns it.
  2. Assess the risk. A secret in a public repository, or one that is still active, needs speed.
  3. Revoke the secret at the provider. Revoking stops the old key from working once it takes effect. It does not undo anything someone already did with it.
  4. Create a replacement key if the service needs one, and update every service that used the old key. If downtime is a concern, GitHub notes you can switch the application to a new key first and then revoke the old one.
  5. Check for unauthorized access. Review the provider's logs and your account for activity you do not recognize, and for resources or credentials you did not create. What to check depends on the provider and what the key could do.
  6. Clean the repository, then set up prevention such as secret scanning and push protection.

Docker builds need their own care

GitGuardian's November 25 write-up reports that .gitignore does not apply to Docker builds, and that bots used AWS keys planted in public Docker Hub images within 7.86 seconds in a Stony Brook study. Docker's documentation says build arguments and environment variables are not suitable for build secrets because they persist in the final image. Use build secret mounts (docker build --secret) instead, keep secret files out of the build context with .dockerignore, and inject runtime secrets when the container starts rather than baking them into the image.

How does your team handle a leaked key? I would like to hear what works for you.

Sources

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.