CVE-2024-5225 SQL Injection in berriai/litellm

Medium 6.4 Published Updated

Attackers can inject SQL via the api_key parameter in the spend logs endpoint to read or modify data in LiteLLM.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-5225?

CVE-2024-5225 is a medium-severity SQL injection vulnerability in berriai/litellm, published on 6 Jun 2024. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

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).

Weakness: CWE-89

Which versions are affected by CVE-2024-5225?

3 open source packages ship an affected version, including litellm. It affects 1 product.

PackageAffectedFixed in
litellm PyPIAll versions1.40.0
litellm PyPIAll versions1.40.0
litellm PyPIAll versions1.40.0

Products include Litellm Litellm.

How do I fix CVE-2024-5225?

Upgrade litellm to 1.40.0 or later.

Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.

Is CVE-2024-5225 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-5225 exists.

Sources

Also known as GHSA-h6m6-jj8v-94jj, PYSEC-2026-1550.

Is CVE-2024-5225 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free