Secrets in Hugging Face Spaces, revisited
What happens to a key after it leaks in a Hugging Face Space? It seems like nothing: thousands of them still work.

What happens to a key after it leaks in a Hugging Face Space? It seems like nothing: thousands of them still work.
Leaked keys in Hugging Face Spaces are a known problem. A study presented at ICSE 2026, a software engineering conference, found 11,557 of them in Spaces created up to December 2024. Today Hugging Face checks every push with TruffleHog, a tool that finds keys in code, and emails the owner when it finds a key that works.
I wanted to know what happens after that email. Does a leaked key actually get turned off?
So I checked the file names in all 1.5 million public Spaces, downloaded the files that usually hold keys, and tested which keys still work. The full method is at the end of the post.
Here is what I learned:
- Scanning didn't make the problem go away. About 1 in 100 Spaces has a real
.envfile in it, and I found 2,807 different keys that still work. - A leaked key only dies if the company that issued it hears about it. For example, every leaked Anthropic key I found is already dead, while hundreds of leaked Groq keys still work.
- The worst leaks aren't AI keys. 446 of the working keys are database logins, and 547 are Google Cloud key files. A stolen API key costs its owner money, but a stolen database login gives away the data of everyone in that database.
- AI coding agents add a new kind of leak. Files that an agent writes into a project went from almost none in 2025 to about 1 in 50 Spaces by mid-2026. They rarely hold keys, but they show how the developer's machine is set up and what the agent is allowed to do.
None of this is a new kind of problem. It's a fresh measurement of a known one, on the part of Hugging Face that the newest reports don't cover.
So this post is mostly about awareness and hygiene. And hygiene is never only about you. If you don't shower, the people around you are the ones who suffer. It's the same with keys: if you don't look after them, your users are the ones who get hurt.
The post goes in this order: who publishes Spaces, what leaks, why it matters, who turns leaked keys off, what AI agents add, and what to change.
What a Space is, and who publishes one
A Space is an app hosted by Hugging Face. You push your code to it the way you push to a git repository, and Hugging Face builds the app and runs it at a public address. The basic tier is free.
Most Spaces are small demo pages. About 3 in 10 are Docker Spaces, which can run any app, including a full backend with a database.
Who publishes Spaces explains why keys end up in them, so it's worth a look before the findings. The data points to beginners working alone:
- Two out of three accounts have exactly one Space, so for most people this is their first one.
- 93% of Spaces have zero likes. Nobody is reviewing them, so nobody tells the owner about a leaked key. The key still works for anyone who goes looking, and a leaked Telegram login, for example, can be used against the owner's family and friends.
- The most common names among the leaking Spaces are
chatbot,rag-chatbot,todo-appandcareer-conversation. The last one looks like the same course exercise, published by dozens of students.
So the typical Space is somebody's first deployed app: a course assignment, a hackathon entry or a weekend chatbot. These people don't have a security team or a build pipeline. They have a folder that works on their laptop, and pushing that folder is the deployment.
That's also why advice alone won't fix this. The people who leak the keys are the least likely to read a post like this one, so the platform has to catch the mistake for them.
What still leaks
First, the size of the problem today. This section covers how many keys are exposed, which kinds, and what a leak looks like in practice.
How many keys
About 1 in 100 Spaces has a real .env file in it. In those files, and in a few other files made to hold keys, I found 2,807 different keys that still work.
Which kinds
Three groups stand out:
- Google Cloud key files: 547 working keys. These are files like
serviceAccountKey.jsonthat let a program log in to Google Cloud. About half of them are Firebase admin keys, which give full access to an app's database and its users. - Database logins: 446 working keys. These are logins to Postgres and MongoDB databases, and whoever has one can read the app's data.
- AI keys. Groq, Gemini, OpenRouter and OpenAI together account for about 1,000 working keys.
What a leak looks like
Here are two examples, without names:
- One Space is the backend of a crypto payment app. Its
.envhas the production database, the key that signs user logins, the payment provider's API key and the wallet address where the money goes. - Another has a database URL, a Google login secret, a Gmail app password and a video service key. TruffleHog recognised only one key in that file and missed the rest, so Hugging Face's scanner most likely never warned the owner.
More than half of the leaking Spaces are Docker Spaces. People use them as free hosting for a real backend, and the backend comes with its .env.
Why this matters
A count of leaked keys doesn't say much by itself. Here is what these keys mean for the people who own them, in four points.
Anyone can do what I did. The file names are public, the tool is free, and the whole thing ran on one laptop in a day. Attackers and bug bounty hunters run the same kind of search all the time. Believe me, I know, because I'm one of those bug bounty hunters.
A working key is direct access. What an attacker gets depends on the key:
- A database login gives them the users' data. That's a data breach.
- A Google Cloud or Firebase admin key gives them the whole backend of the app.
- A key for email, Telegram, Discord or Slack lets them send messages in the owner's name, which is perfect for phishing.
- A GitHub token gives them the code, and maybe a way to change it. Have you heard of supply chain attacks? This is how they often start.
- An AI key lets them run up the owner's bill.
The keys stay open for a long time. Almost half of the Spaces with a working key haven't been updated since 2025. Nobody is coming back to fix them.
It isn't only a student problem. Most Spaces are first projects, but the keys in them are real. One of the examples above is a payment backend with its production database. And when somebody builds a weekend demo with a key from work, the demo lives outside the company's own repos, so the company's scanners never see that key.
A leaked key only dies if its issuer hears about it
This is the main finding of the post. It answers the question from the start: after the scanner finds a key and the owner gets an email, does the key get turned off?
The scanner warns, it doesn't block
Hugging Face's scanner warns, but it doesn't block. The push goes through, the owner gets an email, and the file stays public. So when a key in a Space stops working, either the owner replaced it or the company that issued it found out and turned it off.
Three groups of keys
I counted how many leaked keys of each type still work. They fall into three groups:
- Almost always dead: Hugging Face's own tokens, Anthropic, and new Gemini keys. Of the 157 Hugging Face tokens, one works, and it's a read-only token. None of the 109 Anthropic keys work.
- Dying slowly: OpenAI, GitHub, OpenRouter and Groq. About 1 in 10 OpenAI keys still work, and almost 4 in 10 OpenRouter keys. GitHub and Groq are in between. For OpenAI and Groq, older keys are dead more often than new ones, which is what it looks like when only the owners clean up.
- Almost always working: email services, Google Cloud key files and databases. For example, 54 of the 57 email service keys work.
The Gemini keys show the mechanism best. In Spaces last updated in 2024, almost half of the Gemini keys still work. In Spaces updated in 2026, it's 8 out of more than 800. Somebody started turning off new leaks at some point and never went back for the old ones.
Why the groups differ
It isn't that some companies care and others don't. Most of them turn off a leaked key as soon as somebody tells them:
- According to Truffle Security, Hugging Face, GitHub, Anthropic, OpenAI and Slack turn off the keys that get reported to them.
- Google turns off leaked Cloud keys by default, and has done so since 2024. Its post names the scanning programs at GitHub and GitLab as the source of the reports.
- GitHub runs a partner program that sends each leaked key straight to the company that issued it.
What's missing in Spaces
In Spaces that chain is missing. Hugging Face's docs only talk about emailing the owner. Somebody clearly reports the keys in the first group, and I can't tell from the outside whether it's Hugging Face or the issuers checking Spaces themselves. For everything else, it seems nobody tells the issuer.
The Google Cloud keys make the point. If one of them leaks on GitHub, Google turns it off by default. In Spaces, I could test 678 of them, and 8 in 10 still work.
And nobody can turn off your database password for you.
What may change
Truffle's post announces a program that sends working leaked keys to the company that issued them, and sixteen companies joined, including Hugging Face. The sources Truffle lists include GitHub, Docker Hub, npm and Hugging Face datasets. Spaces aren't on that list yet.
AI agents leave their files here too
This section is about a newer kind of file in Spaces: the ones AI coding agents write into a project. It covers how fast they're spreading and what they give away.
I got to this topic through AI coding agents. Earlier this year I wrote about .claude/settings.local.json, the file where Claude Code remembers every command you clicked "don't ask again" on. In npm packages, about 1 in 13 of those files held a key. Spaces were the next place to look, because people build them with coding agents and push the whole project folder from their laptop, the same way a package gets published.
How fast they're spreading
The ICSE study couldn't see agent files, because its data ends in December 2024.
In 2025, about 1 in 700 updated Spaces had an agent file. By June 2026 it was about 1 in 50, and it has stayed in that range since.
What they give away
To say it plainly: in this research I didn't find many keys leaked through agent files. What these files expose is the developer's machine and habits.
- Few keys. 1,149 Spaces have a
settings.local.json, and only 13 of those files contain a key I can recognise. That's about 1%, the same rate Apiiro measured on GitHub. - The machine. A third of the files contain a home folder path with the developer's username. A quarter run PowerShell, so those are Windows laptops.
- The habits. More than a quarter allow a whole language runtime, like
Bash(python:*), which lets the agent run anything. 17% allowgit push, so the agent publishes the Space by itself. Only 4 files have any deny rule (yes, literally 4 files, not 4%). - The rest of the folder tells the same story. Hundreds of Spaces have the developer's custom skills and commands for the agent. Some have the agent's memory files, full chat logs, or complete copies of other branches of the project. I don't think it's that bad for an open project to show how it was built. But those sessions can also contain requests and data that have nothing to do with the project. Think how often you get distracted in the middle of a chat and type "BTW, can you also...".
- The
.envis next to them. A Space with agent files is about three times as likely to also have a.env. Both come from the same habit of pushing the whole project folder without checking what's in it.
Apart from that, two Spaces have the login file of OpenAI's Codex CLI, with tokens for the developer's account, and ten have a key written into an MCP config, the file that connects an agent to outside tools.
What to change
The fix is different depending on who you are, so this section is split into five groups.
If you publish an app on Spaces or a similar platform
- Put keys in the platform's settings, not in a file. In a Space that's "Variables and secrets", and the app reads them the same way it reads a
.envfile. - Look at the files in your commit before you push it. Check for
.env, key files and agent folders like.claude/. - If a key was ever pushed, revoke it and create a new one. Deleting the file doesn't help, because a Space is a git repository and keeps every earlier version of every file.
- Make each key as small as you can: one key per project, a spending limit on AI keys, and a database user that can only do what the app needs. Then a leak costs you less.
If you run security for a team
- Search Hugging Face for your company's names, domains and projects. Your scanners watch your own repos, and a demo that an employee pushed to a personal Space is outside of those repos.
- Don't count on the platform or the key's issuer to clean up. This post shows that for most key types nobody does.
- Treat
.envfiles, key files and AI agent folders as files that hold keys, on laptops as well as in repos.
If your company issues API keys
- Give people a way to report a leaked key, and turn it off when they do. The Anthropic and Gemini numbers show how well that works.
For Hugging Face
- A scanner that finds a working database password should stop the push, not send an email. GitHub already does this with push protection.
- Report each working key to the company that issued it, the way GitHub's partner program does. The scanner already knows which keys work.
If your developers use coding agents
- Don't let the agent publish by itself. A
git pushor a deployment should need a person to approve it. - Don't give the agent real keys if you can avoid it. Whatever the agent sees can end up in its settings, memory files and chat logs.
Disclosure: where I work
Those last two points are what I work on every day, so I should say where. I work at Legit Security, where we build VibeGuard. It's a guard that sits on the developer's machine, between the coding agent and everything the agent touches. This research wasn't done to sell it, but it does exactly these two things:
- Publishing stays a decision for a person. Every command the agent wants to run is checked against rules that the security team wrote, before it runs. The security team can make a
git pushor an upload to Hugging Face need human approval every time, in every project. - The agent never gets the real key. VibeGuard hands the agent a placeholder such as
VG_SECRET_<id>and puts the real value in only at the moment the command runs. A settings file, a memory file or a chat log written by that agent then holds the placeholder, and a leaked placeholder opens nothing.
To be fair, VibeGuard won't help the student who pushes a first chatbot with a .env inside. That case needs Hugging Face to block the push. VibeGuard is built for teams, where the same habits exist and the keys open much bigger doors.
Closing
Leaked keys are still one of the easiest wins for bug bounty hunters and for attackers. I wrote this post to raise awareness on both sides: the people who push the keys, and the platforms that host them. The big companies have clearly put a lot of work into this problem, and it's clearly not enough yet :)
Appendix: how I measured it
- File names. Hugging Face's API tells you which files a Space contains, for free. I got the names for all 1,525,321 public Spaces in about two and a half hours. Private Spaces and Spaces that need approval aren't included.
- Which files. I picked three groups by name: files that about 35 AI coding tools leave behind, real
.envfiles, and files made to hold keys (Google Cloud key files, Streamlit'ssecrets.toml, SSH keys and similar). I skipped example files and anything inside bundled libraries. - Download. I downloaded only those files, about 48,000 in total.
- Testing. I used TruffleHog, the same tool Hugging Face runs. For each key it makes one read-only call to the service and sees if the key is accepted. "Works" means the key was accepted on November 11, 2026. I never used any key for anything else. I count every key once, even when it appears in several Spaces.
- Reading. I read the agent settings files myself, with the key values masked.
The limits:
- I only looked at the current version of each Space. A Space is a git repository, so it keeps every earlier version of every file, including keys that were deleted later. The ICSE study found that 30% of leaks exist only in that history.
- I didn't check the app code, so a key pasted into
app.pyisn't counted. - Some tests timed out, mostly for databases. I count those as "unknown", not as working.
So every number in this post is a minimum.
A note for researchers: there may be more to find below the history too. Truffle Security showed that on GitHub you can find deleted commits by guessing short commit hashes. I didn't try this on Hugging Face and I don't know if it works there, but it could be a nice way to hunt for what everybody else missed.
Appendix: the numbers
Totals
- 1,525,321 public Spaces, owned by about 820,000 accounts.
- 15,005 Spaces have a real
.envfile. - 2,807 different working keys, in 2,888 Spaces. Of these, 2,212 are in
.envand agent files. The other 595 appear only in other key files, mostly Google Cloud key files. - People reuse keys: 258 working keys show up in two or more Spaces. Most of the time it's one person who pushed the same
.envto several of their own projects. - Almost half of the Spaces with a working key haven't been updated since 2025.
Working keys by type (working, out of those found)
- Anthropic: 0 of 109.
- Hugging Face tokens: 1 of 157, and that one is read-only (the ICSE study found 55 working tokens with write access).
- Gemini: 235 of 2,465. In Spaces last updated in 2024: 43% work. In Spaces updated in 2026: 8 of 827.
- OpenAI: 145 of 1,343.
- GitHub tokens: 15 of 88.
- OpenRouter: 189 of 501.
- Groq: at least 476 of 1,817. Of the keys that leaked two to six months ago, 65% work. After a year it's 18%.
- Pinecone (a vector database): 116 of 122.
- SendGrid and Resend (email services): 54 of 57.
- Google Cloud key files: 547 of the 678 that gave a clear answer.
- Postgres and MongoDB: 446 work and 41 were rejected. For about 430 more the database server didn't answer.
Other key files (counted, not tested unless stated)
- Google Cloud key files with a private key: 858 Spaces.
secrets.toml, the file where Streamlit (a Python framework for data and AI apps) keeps an app's keys: 767 Spaces. More than 500 have real-looking values, and 54 keys tested as working.- Telegram
.sessionfiles, each a logged-in account if it still works: 248 Spaces. kaggle.jsonwith an API key: 65 Spaces.- SSH private keys with no passphrase: 18 Spaces.
- Shell history files such as
.bash_history: 15 Spaces.
Agent files
- 9,475 Spaces have agent files, and two out of three are Docker Spaces. I left out 1,694 Spaces that only carry the same Claude skill template,
hf-space-sandbox. - By type:
CLAUDE.md4,254 Spaces,AGENTS.md3,458, the.claudefolder 2,306,settings.local.json1,149, Cursor files 594, Gemini files 472. - In
settings.local.json: 35% contain a home folder path, 28% allow a whole language runtime, 25% run PowerShell, 17% allowgit push, 15% let the agent read outside the project, 8% allow uploads to Hugging Face. 4 files have a deny rule. The largest file has 1,585 rules. - Other agent files: Claude skills in 400 Spaces, custom commands in 230, subagent definitions in 187, MCP configs in about 210, memory files in 52, worktrees (copies of other branches) in 10.
- Of the Spaces updated in 2026 that have agent files, 2.9% also have a
.env. - Of the Spaces updated in 2026 without agent files, 1.0% have a
.env. - Truffle Security reports the same trend: 2,655 working keys in AI coding tools' config files since January 2025, and none in 2024.
Want to learn more? Register here for Kirill's webinar on Thursday, December 3rd.
Legit Security needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, check out our Privacy Policy.
More insights for modern AppSec teams

Secrets in Hugging Face Spaces, revisited
What happens to a key after it leaks in a Hugging Face Space? It seems like nothing: thousands of them still work.

Your coding agents are still shipping your secrets: the state of the VS Code Marketplace
I checked all 154,420 extensions in the VS Code Marketplace. Almost 1 in 100 ships Claude Code's local settings file, and about 30 AI tools leave their files behind.



See it in your stack
Every prompt, every commit, every deploy, covered the moment you're ready.

