If a Hugging Face token leaks, delete or refresh it from the Access Tokens tab straight away, then work out what it could read or write and check for changes. The Hub documentation warns that until a leaked token is rotated, anyone holding it can read or write your private repositories.
First ten minutes
- Revoke. Go to your token settings and delete or refresh the token. The docs describe both options under Manage.
- Replace. Create a new fine-grained token for the legitimate use, and update the secret store, not source code.
- Note the scope. Was it read, write or fine-grained? A write token on a personal account reaches every repository you can write to, plus organization resources based on your membership.
Then check for damage
- Review the commit history of every repository the token could write to. Look for commits you did not make, new files, and changed weight files.
- Pay particular attention to weight files and any Python files. A swapped model file is the supply chain risk.
- Check for newly created repositories, changed settings, or access changes.
- Check private repositories for downloads you cannot explain, if you have a way to see it.
- Consider whether secrets were also stored in the same places as the token.
If you find a bad commit, revert it, tell anyone who consumes the repository to move to a known good commit hash, and think about how downstream users pinned their revisions.
Find out how it leaked
Common sources are source code, notebooks, CI logs, chat messages and shell history. The Hub also runs TruffleHog on each push to scan for hard-coded secrets and emails you when it finds a verified one, so a leak in a pushed Space or repository may reach you that way. Fix the cause, not just the token.
If you found somebody else's token
The docs describe a revoke endpoint, POST /api/credentials/revoke, that accepts one or more token values and invalidates matching tokens immediately, across everything. You do not need rights over the owner's account. The owner is notified by email. The endpoint always answers 202 Accepted, whether or not a token existed, so it cannot be used to probe for valid tokens. The docs suggest passing values through environment variables or files so they stay out of shell history.
Prevention
Use fine-grained tokens, one per app, keep them out of repositories, and pin revisions so a bad push is less likely to reach production unnoticed. See pinning to a commit hash.
Quick check
Should I check the repositories even after revoking?
Yes. Revoking stops future use but does not undo anything done while the token was exposed.
Can I revoke a token I found in a public repository?
The docs describe a revoke endpoint that works without account rights. Use it, and pass the value through an environment variable instead of typing it into the command line.
Sources
Last reviewed: 19 October 2026.