CVE-2024-2952 Server-Side Template Injection in BerriAI/litellm

Critical 9.8 Published Updated

Attackers can execute arbitrary code on the server by exploiting Server-Side Template Injection in the LiteLLM library via malicious tokenizer configurations.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-2952?

CVE-2024-2952 is a critical code injection vulnerability in berriai/litellm, published on 10 Apr 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

BerriAI/litellm is vulnerable to Server-Side Template Injection (SSTI) via the `/completions` endpoint. The vulnerability arises from the `hf_chat_template` method processing the `chat_template` parameter from the `tokenizer_config.json` file through the Jinja template engine without proper sanitization. Attackers can exploit this by crafting malicious `tokenizer_config.json` files that execute arbitrary code on the server.

Weakness: CWE-76

Which versions are affected by CVE-2024-2952?

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

PackageAffectedFixed in
litellm PyPIAll versions1.34.42
litellm PyPIAll versions1.34.42
litellm PyPIAll versions1.34.42

Products include Litellm Litellm.

How do I fix CVE-2024-2952?

Upgrade litellm to 1.34.42 or later.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2024-2952 being exploited?

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

Sources

Also known as GHSA-46cm-pfwv-cgf8, PYSEC-2026-387.

Is CVE-2024-2952 in your software?

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

Check your SBOMs for free