Rotate your Hugging Face access token: a security checklist

Hugging Face advised users to rotate access tokens after the July 2026 security incident. Exact steps to revoke, replace, and scope your token, plus where to check for compromise.

Ashley Innocent

Ashley Innocent

23 July 2026

Rotate your Hugging Face access token: a security checklist

Apidog for Enterprise

On-Premises Deploy

SSO & RBAC

SOC 2 Compliant

Explore Apidog Enterprise

Hugging Face disclosed a security incident in July 2026 and advised every user to rotate any access tokens and review recent account activity. This page lists the exact steps to do both. It applies whether or not you think you were affected; after an incident, you rotate on suspicion, not on proof.

What happened, briefly

The action item for individual users is small and specific: rotate your tokens.

Rotate your token now

  1. Go to the Access Tokens page in your settings.
  2. Find each active token in the list. Click Manage on a token to delete or refresh it. Deleting invalidates the old token immediately.
  3. Click New token to create a replacement. Select the fine-grained role for anything running in production.
  4. Copy the new token once and store it in a secrets manager, not in code or a shared document.
  5. Update every place that used the old token (see the next section), then confirm the old token no longer works.

Hugging Face’s own documentation is blunt on why this matters: “Try not to leak your token.” A rotated token closes the window in which a stolen one still works.

Where your token might be hiding

A token is only rotated when every copy of it is replaced. Check each of these:

Miss one copy and the rotation is incomplete. The old credential stays live wherever it was left.

Scope the new token correctly

Hugging Face offers three token roles. Pick the narrowest one that still lets the job run.

Role Grants Use it for
fine-grained Access limited to specific repos, orgs, and permissions you choose Production apps, CI jobs, anything shared across a team
read Read access to repositories you can already read Downloading private models, running inference
write Read plus write to repos you can write to Pushing models, editing model cards, training uploads

Two rules from Hugging Face’s best practices:

The OAuth 2.0 scopes model is the same idea applied elsewhere: grant the minimum, not the maximum.

Review your account activity

After rotating, check for anything you did not do:

If anything looks off, contact security@huggingface.co and rotate again.

For teams and CI/CD

Individual rotation is step one. Teams have extra levers:

For the wider principle, see how to secure AI agent API credentials and secure ways to store API keys across teams.

Keep the new token out of your test traffic

A common way tokens leak is through testing and debugging: pasted into a request, saved in a collection, committed by accident. Keeping auth values in environment variables rather than inline in requests reduces that risk.

If you call the Hugging Face Inference API while building, Apidog stores the token as an environment variable and passes it as a bearer token at request time, so the secret stays out of your saved requests and can be swapped in one place after a rotation. That also makes it easy to verify the rotation worked: run one call with the new token and confirm it succeeds, then confirm the old token now returns a 401 or 403. For how bearer tokens work, see basic auth vs bearer token.

Related: the full OpenAI and Hugging Face breach breakdown and the Hugging Face access token documentation.

FAQ

Do I have to rotate if I was not affected? Yes. Hugging Face advised all users to rotate, and after an incident you cannot confirm which credentials an attacker read. Rotating is cheap; assuming you were safe is not.

How do I know if my token was used by someone else? Review your Access Tokens list, recent commits, organization changes, billing, and connected apps. Hugging Face does not expose a full per-token audit trail on personal accounts, so treat any token that shared an environment with the incident as suspect and rotate it.

Will rotating break my scripts? Only until you update the token. Every script, notebook, and CI job using the old token needs the new value. This is why one token per app is the recommended pattern; you replace them one at a time without a cascade.

Read token or fine-grained token? Use read for simple, personal download and inference tasks. Use fine-grained for production, CI, and anything shared, because it limits access to the specific resources you name.

Where should the new token live? In a secrets manager or environment variable, never in source code, a notebook cell, or a shared document. Store it once and reference it everywhere else.

Explore more

How to Test Your API Against Untrusted Input (Before an Agent Does)

How to Test Your API Against Untrusted Input (Before an Agent Does)

Input is an attack surface. Build negative tests for injection, oversized, and malformed payloads, make schema a security control, and run them in CI.

23 July 2026

Gemini 3.5 Flash-Lite vs 3.6 Flash: which one should you use?

Gemini 3.5 Flash-Lite vs 3.6 Flash: which one should you use?

Gemini 3.5 Flash-Lite vs 3.6 Flash compared: price, speed, benchmarks, a use-case matrix, and a same-workload cost example so you pick the right tier fast.

22 July 2026

Gemini 3.6 Flash vs 3.5 Flash: what changed and should you upgrade?

Gemini 3.6 Flash vs 3.5 Flash: what changed and should you upgrade?

Gemini 3.6 Flash vs 3.5 Flash: same $1.50 input, output cut to $7.50, 17% fewer output tokens, higher computer-use scores. What changed and should you upgrade?

22 July 2026

Practice API Design-first in Apidog

Discover an easier way to build and use APIs

Rotate your Hugging Face access token: a security checklist