What is a secret leak and why is it dangerous?
BeginnerConceptGitleaks
Answer
Short answer
A secret leak is when a password, API key, token, private key or connection string ends up somewhere it shouldn't — most often committed to a Git repository, but also in CI logs, Docker images or chat. It's dangerous because anyone who finds it can act as you: read databases, spin up cloud resources, push code or steal customer data.
Real-world examples of what happens
- An AWS access key pushed to a public repo is found by bots within minutes and used to launch crypto-mining instances — a huge bill by morning.
- A GitHub token in a private repo is used after a laptop is stolen to push malicious code.
- A database password in an old commit is still valid years later.
Why "I deleted it" isn't enough
Git keeps full history. Deleting the line in a new commit leaves it in every clone, fork and backup. The only real fix is to rotate (revoke and replace) the secret.
Where secrets leak
| Place | Example |
|---|---|
| Source code | const API_KEY = "sk_live_..." |
| Config files | application.yml, .env, terraform.tfvars |
| CI logs | echo $TOKEN, verbose curl output |
| Docker images | COPY .env ., secrets in ENV or build args |
| Notebooks, docs, tickets | Pasted credentials |
What to say in the interview
"A secret leak exposes credentials that let an attacker act as us. Git history makes leaks permanent, so prevention is scanning before commit and in CI, and the response to any leak is immediate rotation."
More on Gitleaks
What is Gitleaks and how do you use it?BeginnerWhat is Gitleaks?BeginnerHow do you scan a repository's full history with Gitleaks and create a report?BeginnerHow do you stop secrets before they're committed using a pre-commit hook?BeginnerHow do you run Gitleaks in a CI pipeline and fail the build on findings?BeginnerGitleaks found a real AWS key in the repo. What do you do?Beginner