Skip to content

All posts

IT security, AI agents, Supply chain

AI gateway security: when one master key opens every API key

LiteLLM, an open-source AI gateway, had two incidents in one week with the same core: whoever holds the master key holds every credential its agents use. What to check before you deploy an AI gateway or agent platform.

For about two hours on 21 October, PyPI served a release of LiteLLM, the open-source AI gateway, that stole credentials. The vendor’s reconstruction of the attack starts with a mistake most engineering teams have made at least once: in late May a key ended up in a public repository, the commit was force-pushed away, and the key itself was never revoked. On the evening of 27 October a second advisory followed, describing a flaw through which the same kind of key could leak. This is not a careless vendor. According to its incident report, LiteLLM had hardened its release pipeline after an earlier incident in March. If it can happen there, it can happen in your shop.

Picture a pilot that has been running since spring: developers route their coding assistants through a central gateway to the big model providers, and a first agent already opens pull requests using the GitHub token of whoever set it up. The gateway’s master key was dropped into an environment variable on day one, and nobody can say for sure whether it has been rotated since.

An AI gateway is a proxy that sits between your applications and the language model APIs so that keys, spend and access are managed in one place. Its master key is the admin credential for the gateway or agent platform: whoever has it can read everything stored there, including provider API keys and the tokens your agents run with.

How an old key led into LiteLLM’s release pipeline

According to LiteLLM, on 27 May the master key of an internal “Agent Platform”, an experimental tool for coding agents, was committed in a configuration file to a public repository. On 10 October that never-revoked key let the attacker pull the configuration of every managed agent with a single API call. It contained a GitHub CLI token belonging to one of the two owners of the GitHub organisation, not a scoped service account. Such tokens are issued after two-factor login and are not challenged again for sensitive actions, the vendor writes.

That same evening, workflows on throwaway branches sent repository secrets to the outside, among them the personal GitHub tokens of two more maintainers. On 21 October branch protection rejected a change to the release repository; seconds later the owner token overrode it, and the build was pointed at a lookalike repository. Normally a release needed approval from an account tied to a physical device in the office. Per the incident report, that rule had been relaxed on the Monday of the same week so that two engineers could ship daily bugfix backports for customers. One stolen token triggered the release, a second one approved it.

The package went out via Trusted Publishing, a scheme in which PyPI trusts a pre-registered CI workflow instead of a long-lived upload token. The workflow was genuine, its source was not. Our reading: provenance tells you which workflow built a package, not where the code came from. Anyone who installed 1.107.0 or ran one of the affected images should, according to the vendor, treat that environment as compromised.

LiteLLM’s second flaw: file read on Enterprise proxies

Advisory GHSA-w4c7-34wj-hqm8, published on 27 October at 21:33 CET, describes how an unauthenticated attacker could make a LiteLLM proxy with an active Enterprise licence read a local file and send its contents to an address of the attacker’s choosing. The process environment gives up the master key and the provider keys, and with them full admin rights. Because a stranger becomes admin without logging in, the advisory rates it CVSS 10.0. Deployments without an Enterprise licence are not affected, according to the vendor. Fixed versions are 1.103.10, 1.104.8, 1.105.6 and 1.106.5; LiteLLM says Enterprise customers could get the fix from a private registry from 6 October. If you cannot patch right away, the advisory’s mitigation is to restrict the proxy’s outbound traffic to the configured model providers, so the exfiltration fails even when the vulnerable code is reached.

What the two incidents have in common

No source links the two incidents technically. The pattern is the same, though, and it is the point of this piece: the master key of an AI gateway or agent platform is a skeleton key for every credential you hand your agents, and a personal owner token inside an agent is an owner login without a second factor.

The technique is not rare. A Wiz analysis from 25 October describes an automated campaign, Gheist, that since mid-September has used stolen GitHub tokens to plant secret-dumping workflows, with traces from more than 850 accounts. None of the sources says LiteLLM was among its victims.

What to check on Monday

Start with an inventory of every master key, provider key and token in your gateway and in your agent configurations, each with the date it was last rotated. A key that ever appeared in a repository, a ticket or a chat is burned, however thoroughly the commit was rewritten, and gets revoked. Personal owner or admin tokens belong neither in an agent nor in a CI secret; agents get their own narrowly scoped identities, on GitHub for example a GitHub App or short-lived fine-grained tokens.

Load the master key from a secrets manager rather than the process environment, and let the proxy reach only the model providers it actually needs. Keep release approvals bound to devices or designated accounts even under deadline pressure, because “any two engineers” is not a four-eyes rule when both accounts can be stolen. If you run LiteLLM with an Enterprise licence, upgrade to one of the fixed versions.

We treat our AI gateway and every agent platform as a vault from now on: whoever holds the master key holds every credential our agents use, so agents no longer get personal admin tokens and any key that was ever exposed gets revoked.

Which tokens sit in your agents’ configurations, and whose are they?