security

AI Agents Are Now Hunting Your AI App's API Keys

Attacker-controlled AI agents are now actively scanning internet-exposed AI applications like LiteLLM and Dify to steal API keys for their own use.

Attacker-controlled AI agents are now automatically scanning for and stealing API keys from internet-exposed AI applications. According to Amazon's threat intelligence team, these attacks are not theoretical; they are actively targeting popular tools like LiteLLM and Dify to hijack credentials and use them to power the attackers' own models.

How does the attack work?

The attack pattern is a simple, automated loop. An agent scans the internet for known vulnerabilities in AI middleware. Once it finds an exposed instance, it exploits it to extract API provider keys—think OpenAI, Anthropic, or Cohere credentials. The captured logs show the agent then immediately uses these stolen keys to make its own LLM calls, likely to power further scanning and exploitation. This new report on how **attackers are using AI agents** confirms what was previously seen in different contexts, like Microsoft's reports of similar agentic tools hunting for secrets on GitHub.

What's the concrete risk?

The immediate risk is financial. If your OpenAI API key is stolen, you're on the hook for whatever charges the attacker racks up until you notice and revoke it. The attack specifically targets middleware like LiteLLM, which acts as a proxy to various model providers. A common mistake is leaving a LiteLLM instance open to the public internet with keys stored in its config file or as environment variables. The attackers' agents are built to find exactly this misconfiguration. They'll probe default ports and common API endpoints, looking for a way in.

Should you be worried?

Yes, if you have any internet-facing AI tooling. Tools like LiteLLM and Dify are useful, but deploying them with default settings to a public IP is asking for trouble. Lock them down. Put them behind a VPC, use a firewall, and implement authentication. Never store keys directly in the application's configuration on a web-facing server. Use a dedicated secrets manager like AWS Secrets Manager, GCP Secret Manager, or HashiCorp Vault. The verdict is clear: the convenience of these AI tools doesn't excuse sloppy security practices, and attackers are now building their own tools to punish that sloppiness.

FAQ

Which applications are being targeted? A: The report specifically names LiteLLM and Dify as targets, but you should assume any internet-facing AI middleware or custom application that manages API keys is at risk.

How can I protect my API keys? A: Do not hardcode keys in configuration files or environment variables on web-facing instances. Use a dedicated secrets management service like AWS Secrets Manager or HashiCorp Vault to inject secrets at runtime.

Is this different from regular vulnerability scanning? A: Yes. The key difference is the use of AI agents to automate the entire chain: discovery, exploitation, and immediate reuse of the stolen credentials to self-fund subsequent attacks. This accelerates the process.