NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · LiteLLM

CVE-2024-5225: SQL injection in litellm

mediumCVSS 3.0 6.4GHSA-h6m6-jj8v-94jj

The LiteLLM proxy builds a SQL query for `/global/spend/logs` by concatenating the `api_key` parameter, which allows SQL injection. A successful attack can expose or change stored data and cause a crash. LiteLLM older than 1.40.0 is affected. Upgrade to 1.40.0.

Published Jun 6, 2024 · Analysis Nov 2, 2026

What an attacker can do

The handler for /global/spend/logs puts the unvalidated api_key value directly into its SQL text. A crafted value can change the query. The advisory names unauthorized access, data manipulation, exposure of confidential information and denial of service.

The proxy database stores spend logs, keys and user data, so the likely target is API key material and usage records. The CVSS 3.0 vector needs a low-privilege account (PR:L) and rates confidentiality and integrity as low but with a changed scope.

One limit from the fix discussion: a maintainer said the sk- prefix is checked in user_api_key_auth before this code runs, and doubted that the issue was reachable. The fix still shipped in 1.40.0 (commit f75c15d), so treat older proxies as exposed.

Who is affected

pip package litellm older than 1.40.0, when the proxy server runs with a database behind it and the /global/spend/logs endpoint is reachable by callers. The SDK alone, without the proxy, has no such endpoint. Check the installed version with:

pip show litellm

litellm

Ecosystem
PyPI
Affected
< 1.40.0
Fixed in
1.40.0
Check
pip show litellm

How to fix it

Upgrade litellm to 1.40.0.

pip install --upgrade "litellm>=1.40.0"

The fix is commit f75c15d. The earlier pull request 3940 was closed without merging; the maintainers said the fix landed in that commit instead. No workaround is listed. Until you upgrade, limit access to the proxy and its spend endpoints.

How to tell if you were hit

In proxy logs, search for requests to /global/spend/logs where the api_key value contains quotes, --, ;, UNION or SELECT. Look for database errors in the proxy output, and for unusually slow responses on that endpoint.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

An SQL Injection vulnerability exists in the berriai/litellm repository, specifically within the /global/spend/logs endpoint. The vulnerability arises due to improper neutralization of special elements used in an SQL command. The affected code constructs an SQL query by concatenating an unvalidated api_key parameter directly into the query, making it susceptible to SQL Injection if the api_key contains malicious data. This issue affects the latest version of the repository. Successful exploitation of this vulnerability could lead to unauthorized access, data manipulation, exposure of confidential information, and denial of service (DoS).

Questions

Which version fixes CVE-2024-5225?

litellm 1.40.0. Versions below it are listed as vulnerable.

Is it reachable without a valid key?

A maintainer said the sk- prefix is checked in user_api_key_auth before the query runs. The CVSS vector also requires low privileges. Do not rely on that: upgrade.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More LiteLLM vulnerabilities

All LiteLLM entries