CVE-2024-2952: LiteLLM has Server-Side Template Injection vulnerability in /completions endpoint
LiteLLM before 1.34.42 has a server-side template injection in the /completions endpoint. The hf_chat_template method renders the chat_template value from a model's tokenizer_config.json through Jinja without sandboxing, so a crafted file executes code on the server. Upgrade to litellm 1.34.42.
Published Apr 10, 2024 · Updated Jul 6, 2026 · Analysis Nov 18, 2026
What an attacker can do
For Hugging Face models, LiteLLM's proxy fetches tokenizer_config.json and passes its chat_template string to hf_chat_template, which renders it with the Jinja template engine. A normal Jinja environment lets a template reach Python objects, so a malicious template can run arbitrary code. An attacker who controls the tokenizer_config.json that the proxy loads, for instance by pointing a request at an attacker-controlled model repository, gets code execution in the proxy process.
The CVSS 3.0 vector (AV:N/AC:L/PR:N/UI:N) rates it 9.8 with no authentication. LiteLLM proxies hold provider API keys, the database connection and the master key, so code execution exposes all of them and lets the attacker use the upstream accounts. How easy it is to reach depends on whether callers can name arbitrary Hugging Face model sources through the proxy.
Who is affected
The pip package litellm is affected before 1.34.42, in proxy deployments whose /completions endpoint can be used with Hugging Face models by untrusted callers.
Check the version:
pip show litellmFor Docker, check the image tag.
litellm
- Ecosystem
- PyPI
- Affected
- < 1.34.42
- Fixed in
- 1.34.42
- Check
pip show litellm
How to fix it
Upgrade to litellm 1.34.42:
pip install --upgrade litellm==1.34.42Pull request 2941 switches Jinja rendering to the ImmutableSandboxedEnvironment, which stops templates reaching dangerous Python objects. The sources we read give no workaround. Until you upgrade, restrict which models and model sources callers can name, and rotate provider keys if you suspect abuse.
How to tell if you were hit
Look at proxy logs for requests to /completions that name unfamiliar Hugging Face repositories, and for fetches of tokenizer_config.json from unexpected sources. Check for unexpected child processes of the proxy, outbound connections to unknown hosts, and use of your provider keys that you cannot match to normal traffic.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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.
Credited to ishaan-jaff, r3kumar, cookesan.
Questions
- Which LiteLLM version fixes CVE-2024-2952?
LiteLLM 1.34.42 fixes it. Every version before 1.34.42 is affected, so upgrade the package.
- What triggers the bug?
A tokenizer_config.json whose chat_template holds a malicious Jinja expression. The proxy renders it without a sandbox through hf_chat_template.
- What did the fix change?
Pull request 2941 moves rendering to Jinja2's ImmutableSandboxedEnvironment, according to the commit titles on the PR.
References
Read for this analysis:
- https://nvd.nist.gov/vuln/detail/CVE-2024-2952
- https://huntr.com/bounties/a9e0a164-6de0-43a4-a640-0cbfb54220a4
- https://github.com/BerriAI/litellm/blob/0d803e13798db40aa7463e64a6bafaee386424f5/litellm/proxy/proxy_server.py#L2087
- https://github.com/BerriAI/litellm/issues/2949
- https://github.com/BerriAI/litellm/commit/8a1cdc901708b07b7ff4eca20f9cb0f1f0e8d0b3
- https://github.com/BerriAI/litellm
- https://github.com/pypa/advisory-database/tree/main/vulns/litellm/PYSEC-2026-387.yaml
- https://pypi.org/project/litellm
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
