Off Guard: Breaking LiteLLM from authentication bypass to cloud compromise
LiteLLM had an MCP authentication bypass where any Bearer token created a valid session, and a post-auth remote code execution via custom code guardrails that lacked sandboxing. An attacker could gain root code execution on the host and steal cloud credentials, especially when default or missing authentication was present.
Published on wiz.io
Nearly 1 in 10 publicly accessible LiteLLM instances accept a default master key or require no authentication at all. We found this while scanning roughly 3,000 internet-facing deployments of the most popular open-source LLM gateway.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The MCP auth handler treated any failed token validation as a valid OAuth2 passthrough and returned an empty authenticated object, while the guardrail registration endpoint executed user-supplied Python without stripping builtins or applying the forbidden-patterns check used by the test endpoint.
Impact
An attacker could achieve root-level code execution on the host and steal cloud IAM credentials, but the RCE required admin access or a default master key, and the MCP bypass alone only allowed MCP server access.
What the attacker needed
Network access to LiteLLM; default master key or no auth for RCE; admin access for guardrail RCE
The fix
The issues were fixed by requiring PROXY_ADMIN for guardrail endpoints, enforcing the sandbox on registration, and changing the default role from PROXY_ADMIN to INTERNAL_USER.
How it was found
- Send a request to the MCP endpoint with any Bearer token.
- The server returns a valid MCP session ID despite the token being invalid.
- Use the MCP session to execute tools with arbitrary arguments.
- For RCE, send a POST to /guardrails with custom code that imports os and runs a command.
- The code executes immediately when the guardrail is registered.
- Send a chat completion to trigger the guardrail and see the command output as the block reason.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
LiteLLM is a gateway that sits between applications and AI providers. Two flaws let attackers in: one accepted any made-up token as a valid login for a tool-connection feature, and another let an admin-level user run Python code on the server without a sandbox. Combined with default passwords, this gave attackers full control of the server and its cloud access.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.