· via dev.to (home feed)
Leaked MCP configs expose Hugging Face tokens, dev.to security lab shows
A dev.to security lab shows how a deployed .mcp.json file leaks a Hugging Face token, and how far an attacker could get with one fine-grained credential.

What happened
A security write-up published on dev.to on November 17, titled "MCP Configs Are the New .env: Triaging a Leaked Hugging Face Token", walks through an increasingly plausible accident: a web deployment that shipped a developer's dotfiles, including the configuration file of an AI coding agent, with a credential sitting inside it in plain text.
The piece is a lab exercise, not a breach report. The author built a deliberately vulnerable storefront — installable with npx or Docker — that serves a fake Hugging Face token derived from a fixed seed and backed by a local mirror of the Hub. The people, the token and the data are simulated; the failure mode it demonstrates is not.
How the file leaks
According to the post, Claude Code reads project-level MCP server definitions from a .mcp.json file at the root of a repository, and VS Code understands the same portable file alongside its own .vscode/mcp.json. Because the lab's storefront was deployed straight from a developer's checkout, every dotfile went along with it, including a .mcp.json whose environment block hardcodes an HF_TOKEN.
Routine scanning would not necessarily catch it. The author notes that SecLists' common.txt and quickhits.txt wordlists contain no entry for mcp.json. Nuclei, by contrast, already ships templates for exactly this file — vscode-mcp-json and claude-settings-exposure — which request /mcp.json and /.mcp.json and match on an mcpServers object. The post also singles out documentation as an amplifier: the README of Hugging Face's own MCP server suggests, for manual setups, an mcp.json snippet with the token spelled out in plain text.
Triaging the token
The write-up treats discovery as the easy part and concentrates on what follows: which provider issued it, who owns it, what it opens, and how to revoke it. The hf_ prefix plus the 34 characters after it identify a Hugging Face user access token, and the variable name HF_TOKEN matches what the Hub's Python libraries and the @llmindset/hf-mcp-server package read.
One detail in the config adds a second risk. A second server entry sets HF_ENDPOINT to a mirror URL, and huggingface_hub sends every request to whatever that variable names. The author warns that pointing it at a mirror you do not trust hands that mirror your token — and that if HF_TOKEN fails to export (for instance because jq is missing), the client silently falls back to the credential saved with hf auth login and sends that instead.
Against the lab's mirror, the official client's whoami call and the /api/whoami-v2 endpoint reveal the owner and the scope: a fine-grained token named "support-evals", belonging to a user who can write to the organization, limited to reading one private dataset, oopssec-store/support-chat-transcripts.
The blast radius
The simulated token cannot write to the organization even though its owner can. Its reach is a single dataset — but that dataset holds customer support conversations, and its own card states that names, emails, phone numbers and delivery addresses have not yet been scrubbed. One hf download command pulls the whole thing, in the chat format fine-tuning jobs expect.
The post draws a firm legal line for anyone tempted to replay this outside a lab: identify the provider from the prefix and go no further. Using a found token, even for a whoami lookup, means using someone else's credential, which can amount to unauthorized access under computer-crime laws. The correct response is to report it, not to explore it.
Why it matters
MCP configuration files are on track to become as common as .env files, and they carry the same class of secret in the same plain-text form. The scenario is really a deployment-hygiene problem: any pipeline that copies a working directory will publish .mcp.json unless it is excluded explicitly, and scanner templates for the filename already exist.
The mitigations the lab implies are straightforward. Keep tokens out of MCP configs and inject them at runtime; treat .mcp.json like .env in ignore rules, artifact checks and web-root hygiene; and prefer fine-grained tokens. In the simulation, fine-grained scoping contained the damage to one dataset — though that dataset still held unscrubbed personal data, a reminder that least privilege shrinks a breach without preventing one.
- #mcp
- #security
- #hugging-face
- #ai-agents
- #secrets