CVE-2024-5225: SQL injection in litellm
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 litellmlitellm
- 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 inuser_api_key_authbefore the query runs. The CVSS vector also requires low privileges. Do not rely on that: upgrade.
References
Read for this analysis:
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 entriesCVE-2026-114612
LiteLLM: Privilege Escalation to Proxy Admin via Cross-Domain Reuse of the Salt Key
high9.9Oct 27, 2026GHSA-g5ff-637f-6q2m
LiteLLM: internal_user_viewer arbitrary local file read via `vertex_ai_credentials`
high8.1Oct 27, 2026GHSA-hhww-mrg2-969h
LiteLLM vulnerable to reflected XSS in /sso/debug/callback
medium6.8Oct 27, 2026CVE-2026-84377
LiteLLM: Authenticated SSRF and provider-credential exfiltration via unvalidated request-body routing parameters
medium6.5Sep 30, 2026CVE-2026-59823
LiteLLM Proxy has server-side request forgery via the `user_config` request parameter
medium5.3Sep 17, 2026CVE-2026-37004
LiteLLM vulnerable to server-side template injection in the /prompts/test endpoint
critical9.8Aug 27, 2026
