12 million exposed .env files are a warning for AI agent credentials

Mysterium VPN found over 12 million IPs serving public .env files with API keys and DB passwords. Local agents that read plaintext secrets multiply that risk. Here is how I vault credentials for production agents.

SaifullahSaifullah
5 min read
12 million exposed .env files are a warning for AI agent credentials

Your agent is not more secure than the file it reads secrets from. If that file is a .env on a developer laptop, you have merged "helpful automation" with "keys to the kingdom on a machine that also runs random npm packages."

A February 2026 scan from Mysterium VPN found 12,088,677 IP addresses serving publicly accessible .env-style files. Not theoretical misconfigurations. Live endpoints leaking database passwords, API keys, JWT signing secrets, and service tokens. The US alone accounted for roughly 2.8 million IPs (~23% of the pool).

That number landed in the same news cycle as viral stories about local agents with full inbox access. Connect the dots: we are giving autonomous tools more power while secret hygiene is still a dumpster fire.

What the Mysterium scan actually found

Researchers used internet-wide scanning to identify hosts serving environment configuration files without authentication. These files are meant to live outside public web roots. Deployment mistakes, missing deny rules, and bad defaults put them on the open web anyway.

Coverage from Security Affairs and SC Media highlights the same headline: this is operational hygiene at scale, not one buggy framework.

Exposed asset typeWhy attackers care
Database URLs + passwordsDirect data theft
API keys (Stripe, SendGrid, cloud)Abuse paid services, send spam
JWT signing secretsForge sessions
OAuth client secretsBuild token-grabbing flows

Geography spreads the pain: Japan, Germany, India, France, UK, Singapore, Ireland, Canada, Australia all show six-figure counts. Secret leaks are not a US-only sin. They are a "we shipped Friday and skipped the nginx rule" sin.

Map-style diagram showing global scale of exposed .env configuration files on public IPs

Why agents make this worse, not better

Classic web apps read env vars at boot. Attackers need a path to the server. Local and desktop agents change the shape:

  • Secrets on the endpoint. OpenClaw-style agents, coding harnesses, and "run on my Mac mini" setups often store Gmail, Slack, and CRM tokens in local env files or sqlite cred stores the agent can read.
  • Autonomous exfiltration paths. If the agent can browse, render markdown images, or call arbitrary URLs, a compromised instruction can ship secrets out. I cover that attack class in indirect prompt injection for local agents.
  • More integrations per user. One agent, twelve APIs. One leaked laptop equals twelve breach notifications.

The AlphaSignal deep dive on team agents versus solo bots put it plainly: deploying an agent for a 50-person team with plaintext .env credentials on each laptop is not a scaling strategy. It is fifty miniature vaults with no audit trail.

Architecture I push for production agents

When a client moves from "my Claude Code experiment" to "our ops bot," credential design comes before prompt design.

1. Air gap between model and raw tokens

The agent executes in a sandbox. API credentials live in an encrypted vault or managed secret store (AWS Secrets Manager, Azure Key Vault, HashiCorp Vault). When the agent "searches Gmail," it calls an integration service that holds the OAuth token. The model never sees the refresh string.

2. Scoped OAuth apps per role

Finance gets read-only purchase orders. Support gets ticket create, not billing refund. Scope at the identity layer, not in a markdown file the model might forget during compaction. Related: the solo agent ceiling post on why team memory and policy layers matter.

3. Short-lived tokens where possible

Prefer tokens that expire in hours, with rotation and audit logs. Long-lived API keys in env files are convenient until they show up in a Mysterium scan headline.

4. No secrets in prompts or retrieved docs

Treat RAG chunks and tool outputs as untrusted. Never paste DATABASE_URL into system prompts "for convenience." If your retrieval pipeline can surface env files from a repo, you have already lost.

# DO NOT put live secrets in agent context export AGENT_SYSTEM_PROMPT="Use API_KEY=$STRIPE_SECRET from env"
# Agent calls your service; service holds the secret curl -X POST https://integrations.internal/v1/gmail/search \ -H "Authorization: Bearer $USER_SESSION_JWT" \ -d '{"query":"label:warehouse"}'
Agent credential air gap: sandboxed agent calls integration layer with vault-held OAuth tokens

Immediate hygiene if you run local agents today

You do not need a six-month platform project to reduce risk this week:

  1. Rotate anything that ever lived in a committed or shared .env.
  2. Scan repos and buckets for accidental env uploads. Tools like GitGuardian or trufflehog are boring and useful.
  3. Block web serving of dotfiles at nginx, CDN, and platform defaults.
  4. Separate dev and prod keys. Agents love prod keys because prod has real data. That is exactly why they should not have them.
  5. Require approval before tools that read filesystem paths like ~/.env or ~/.aws/credentials.

If you expose services publicly, verify you are not in the scan population. Mysterium's post includes remediation guidance: remove public access, rotate exposed values, invalidate tokens.

How this fits the bigger agent security picture

Credential leaks and prompt injection are different bugs with the same lesson: do not trust the model to guard secrets or policy. Put enforcement in infrastructure.

LayerProtects against
Vault + integration proxyStolen laptops, leaked env files
Input/output classifiersMalicious content in web pages and emails
Human approval on writesDestructive tools (bulk delete, payments)
Audit logs"Who exfiltrated what" after the fact

Enterprise agent products that market "3,000 integrations" are selling connector breadth. The security question is always: where do tokens live, who can revoke them, and what happens when compaction eats a safety prompt?

Bottom line

Twelve million exposed env files is not an AI story. It is a decades-old deployment mistake story. AI agents amplify it because they are designed to use the keys those files contain, quickly, repeatedly, while you are not watching.

Before you give an agent another integration, ask where the credential sleeps at night. If the answer is "plaintext on a Mac mini," fix that before you fix the prompt.

Need help designing agent integrations without handing models raw OAuth tokens? Book a free discovery call and we can map vault patterns to your stack.

Share this post

Related posts