Hugging Face Access Token
Detects Hugging Face user access tokens (hf_ prefix), used to authenticate to the Hugging Face Hub API. A leaked token grants access to private models, datasets and Spaces, and can incur inference billing.
- Type
- regex
- Engine
- universal
- Confidence
- high
- Confidence justification
- High confidence: the distinctive hf_ prefix with a fixed 34-character body is highly specific to Hugging Face access tokens.
- Jurisdictions
- global
- Regulations
- Criminal Code Act 1995 (Cth)
- Frameworks
- CIS Controls, ISO 27001, NIST CSF, SOC 2
- Data categories
- credentials, security
- Scope
- narrow
- Risk rating
- 8
- Platform compatibility
- Purview: Compatible, GCP DLP: Unsupported, Macie: Unsupported, Zscaler: Compatible, Palo Alto: Unsupported, Netskope: Unsupported
Pattern
(?<![A-Za-z0-9_])hf_[A-Za-z0-9]{34}(?![A-Za-z0-9])
Corroborative evidence keywords
hugging face, huggingface, HF_TOKEN, access token, api token, transformers, inference api
Proximity: 300 characters
Should match
hf_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh— Low-tier probe - complete token without provider or deployment contextHugging Face access token: hf_aB3dE6gH9jK2mN5pQ8sT1uV4wX7yZ0pLkJ— Medium-tier probe - provider-labelled token without live deployment contextProduction inference deployment secret HF_TOKEN=hf_zyxwvutsrqponmlkjihgfedcba01234567— High-tier probe - provider label plus live inference context
Should not match
hf_ABCDEFGHIJKLMNOP— Too short to be a valid Hugging Face tokenhg_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh— Wrong prefix (hg_ instead of hf_)load the model with your hugging face access token set as HF_TOKEN— Prose mention without a token valuePublic documentation example: production deployment HF_TOKEN=hf_zyxwvutsrqponmlkjihgfedcba01234567— Public example containing a structurally complete tokenTemplate placeholder token: Hugging Face access token hf_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh for production inference— Template contains otherwise high-tier evidence
Known false positives
- Documentation or examples showing placeholder hf_ strings. Mitigation: Require corroborative keywords and check for placeholder markers (example, xxxx).