How to find leaked API keys and secrets on your own machine
Most leaked keys are not stolen by genius. They sit in a file that many programs can read. Here is where to look, how to judge what you find, and what to do next.
Where secrets hide
- Project code and config: a key pasted into
config.php,settings.pyor a test script "just for now". .envfiles: normal and fine when the file is private and git-ignored. A problem when it is committed, world-readable, or copied into a backup.- Git history: deleting a key from the current file does not delete it from older commits.
- Cloud and tool credentials:
~/.aws/credentials,.npmrcwith a token, Docker and Kubernetes configs. - Agent and MCP config: tokens inside
mcp.jsonor an agent's settings file. - Web roots of servers: backups like
.env.bakorconfig.php~that a web server happily serves.
How to judge a finding
A key in a private, git-ignored .env in your own project is normal. The same key becomes a finding when one of these is true:
- The file is world-readable (other accounts or services can open it).
- The file is tracked or was ever committed to Git.
- It sits in a folder a web server publishes.
- It is a long-lived token with write power (publishing packages, cloud admin).
How Dante does it
The deep run (deep, or weekly if you agree to a schedule) searches your project folders for secrets using patterns for 1,111 formats - AWS, GitHub, Stripe, private keys, database URLs and many more. It first looks which systems are in the project (package.json, composer.json, requirements.txt) and only uses the fitting patterns, so it stays fast and quiet. On a hit it looks closer: file rights, is it in Git, was it ever committed, is it ignored.
It shows the file, the line and the kind of secret - never the value. Example files (*.example) and placeholder lines are skipped, as are node_modules, .git, vendor and build folders. Nothing leaves your machine.
user ❯ deep
OPEN GitHub token app/deploy.sh line 8
in Git history (committed 2026-03-02) · file mode 644
SAFE AWS key .env (private, git-ignored: normal for a local .env)What to do when you find one
- Rotate first. Assume the key is known. Create a new one at the provider and revoke the old one. Removing the line is not enough.
- Move the new secret to a place that is not committed: a private git-ignored
.env, your OS keychain, or a secrets manager. - If it was committed, rotating matters more than rewriting history; rewrite only to stop further spreading.
- Tighten file rights: private files should be readable by you only (mode 600 on Mac and Linux).
npx dante-watch. Step-by-step for Mac, Windows and Linux.~/.dante and it is gone.Questions people ask
How do I find API keys in my code?
Search the project for known key formats and check each hit for file rights, Git tracking and history. A tool with a library of formats does this faster and with fewer false alarms than a plain text search.
Is a key in my local .env a leak?
Not if the file is private, git-ignored and never committed. It becomes a problem if it is world-readable, tracked by Git, or in a folder a web server publishes.
Does Dante show my secrets?
No. It shows the file, the line and the kind of secret, never the value.
More
- AI agent security risks: seven ways an agent on your machine gets abusedPrompt injection, over-broad permissions, poisoned MCP tools, secrets in readable files, supply-chain malware that talks to your AI assistant.
- Is my server hacked? How to check your own server for warning signsA practical checklist for a server you own: SSH settings, world-writable files, web shells, outdated PHP, unknown cron jobs and keys - and what a read-only check can and cannot prove..
- Bait files that warn you when someone uses your secretsA fake .env, mcp.json, .npmrc or AWS credential that nobody legitimate would ever use.
- Install Dante in three minutes - and what the packs costStep-by-step install for Mac, Windows and Linux with one command, how to talk to Dante, the free and paid parts, and how updates and knowledge packs work.
- After the Hugging Face incidents: check your tokens and the models you downloadedWhat was reported about Hugging Face Spaces secrets and malicious models, what to rotate, why pickle files are risky, and how to check your own cache and agent config without sending anything anywhere..