Exposure Medium

Revoke the exposed Hugging Face token

A Hugging Face access token (hf_...) acts as the account it was created for. Depending on its scope it can run paid inference, read private models and datasets, or write to them. In a browser bundle it is available to anyone who loads the page.

Find out whether your site has this problem, and every other check, in one free scan.

Check your site free

Why it matters

A Hugging Face access token acts as the account it belongs to: depending on its scope it can run paid inference, read private models and datasets, or push changes to them.

How to fix

  1. 1 Revoke the token in Hugging Face (Settings > Access Tokens, Invalidate) and create a new, fine-grained one with only the scope the feature needs.
  2. 2 Move every call that needs it behind an endpoint on your own server that holds the new token.
  3. 3 Purge the old token from git history so it is not recoverable from a prior commit.
  4. 4 Redeploy and confirm the shipped bundle has no hf_ token in it.

Common mistakes

  • Creating a write token when the feature only needs to read or run inference, which widens what a leaked token can change.
  • Putting the key in a build-time environment variable and assuming that keeps it private: a bundler that inlines it (NEXT_PUBLIC_, VITE_, PUBLIC_) ships it to every visitor.
  • Removing the key from the current build without revoking it: copies in git history, old deploys and CDN caches keep working until it is revoked.

How to verify

  1. 1 Re-run the scan and confirm the Hugging Face token finding is gone.
  2. 2 Search the deployed JavaScript for hf_ to confirm no token remains.
  3. 3 Confirm the old token is no longer listed under Access Tokens in your Hugging Face settings.

Related checks

Ready to see where you stand?

Scan your site and get your Engineering Score with a prioritized roadmap in under a minute, no signup required.

Scan your site

Session expired

Your session has expired for security. Please log in again to continue.