AI agent campaign API key theft

How Automated AI Agents Are Hunting for Stolen API Keys in Your Infrastructure

Attackers have deployed autonomous AI agents that systematically scan for vulnerable instances of LiteLLM, Dify, One API and similar applications to extract API keys and credentials. Amazon's threat intelligence team discovered this self-sustaining cycle by monitoring decoy servers, where they watched stolen keys being recycled to power the very agents conducting the theft.

AI Agent Campaign Targets LiteLLM, Dify for API Key Theft

What Amazon's Threat Team Discovered

Amazon's security researchers identified a coordinated campaign in which attackers deployed artificial intelligence agents to probe internet-facing instances of popular AI orchestration platforms. The agents specifically targeted LiteLLM (a proxy for managing multiple language model providers), Dify (a no-code AI application builder), and One API (a multi-provider gateway service). Rather than rely on manual scanning, the attackers had weaponized AI itself to automate the reconnaissance and extraction of API keys and provider credentials stored within these exposed applications.

The campaign operated as a feedback loop: stolen API keys from one target were immediately used to provision the computational resources needed to run the scanning agents themselves. This self-sustaining model allowed attackers to scale their operation without requiring direct payment for cloud compute resources.

How the Self-Sustaining Attack Cycle Works

The attack chain follows a logical progression. First, threat actors scan public IP ranges or use shodan-style queries to find instances of vulnerable applications. Once a target is identified, the AI agent probes for common misconfigurations, default credentials, or exposed API endpoints. When successful, it extracts stored API keys or credentials. These stolen keys—particularly those belonging to OpenAI, Anthropic, or other major model providers—grant access to substantial token budgets or usage quotas.

The attackers then use these compromised keys to spawn new instances of their scanning agents, which continue the hunt for more targets. Amazon's researchers captured this loop by deploying honeypot servers that mimicked vulnerable LiteLLM and Dify installations. The decoys attracted the malicious agents and logged their activities, revealing the full scope of the attack methodology and the identities of compromised credentials being exploited.

Why These Applications Are Attractive Targets

LiteLLM, Dify, One API and similar platforms act as intermediaries between applications and AI model providers. By design, they must store or temporarily hold API credentials to function. If deployed without proper access controls—exposed to the public internet with weak authentication, default settings, or unpatched vulnerabilities—they become treasure troves of high-value keys. A single compromised OpenAI API key with a monthly spend limit of thousands of dollars represents immediate stolen value that attackers can monetize or resell.

These platforms are also attractive because many organizations deploy them quickly in development or proof-of-concept environments without hardening them against external access. A developer might expose a Dify instance to test it with colleagues, then forget to restrict access or rotate credentials. Such misconfigurations persist for weeks or months, creating the exact window attackers need.

What Defenders Should Verify Now

If your organization uses LiteLLM, Dify, One API, or similar AI gateway applications, take the following actions:

  1. Verify that no instances are exposed to the public internet without authentication
  2. Rotate all API keys and credentials stored within these applications immediately
  3. Check your API provider usage logs (OpenAI, Anthropic, etc.) for suspicious or unexpected requests
  4. Deploy firewall rules or security groups to restrict access to these applications to internal networks only
  5. Enable audit logging to track which credentials were accessed and when
  6. Review any recent billing anomalies from your AI service providers

If you find unauthorized usage, many providers allow you to reset API keys and dispute fraudulent charges, though the process and timeline vary.

The Broader Threat Pattern in AI Infrastructure

This campaign illustrates a category of threat that will likely expand as more organizations adopt AI tooling without mature operational security practices. The attackers are not exploiting zero-day vulnerabilities but rather the familiar problem of exposed credentials and misconfigured access. What makes this campaign notable is the attacker's use of AI agents to automate the entire kill chain at scale. Rather than manually scanning and extracting keys, they deployed agents that can work continuously across thousands of potential targets.

The self-funding mechanism—using stolen keys to power the scanning agents—also reduces attacker friction and overhead, making the campaign economically viable even against targets with modest API budgets.

Key Takeaways and Your Next Steps

The core lesson is that AI infrastructure requires the same defensive practices as any system holding valuable credentials: assume it will be probed, restrict exposure ruthlessly, and monitor usage constantly. Stolen API keys are a leading cause of unexpected cloud bills and unauthorized model usage, yet many organizations still treat them as a low-priority risk during deployment.

Your first action today should be to inventory any AI applications your team has deployed—especially LiteLLM, Dify, or similar platforms—and confirm they are not reachable from the public internet without authentication. If you find any exposed instances, rotate all credentials immediately and review the access logs to check for unauthorized activity.

FAQ

What is LiteLLM and why is it targeted? LiteLLM is a proxy library that lets applications switch between different AI model providers (OpenAI, Anthropic, Azure, etc.) without rewriting code. It's targeted because it stores API keys for these providers, which represent direct access to paid services.

How do I know if my API keys were compromised in this campaign? Check your usage logs with each API provider you use (OpenAI, Anthropic, etc.) for requests you did not make. If you see unexpected API calls, tokens consumed, or geographic anomalies, assume compromise and rotate keys immediately.

What should I do if I use Dify or LiteLLM in production? Ensure these applications are not accessible from the internet without strong authentication, use a VPN or private network, enable audit logging, rotate all stored credentials regularly, and monitor usage patterns for anomalies.

Can attackers do anything dangerous with a stolen API key beyond using my quota? Yes. A stolen key grants full access to your account, which may include the ability to access conversation history, fine-tuning data, or other sensitive model outputs, depending on the provider and the key's scope.

Source: The Hacker News