LiteLLM has Server-Side Template Injection vulnerability in /completions endpoint
The hf_chat_template method in LiteLLM processes the chat_template parameter from tokenizer_config.json through Jinja without sanitisation. An attacker who can supply a malicious tokenizer_config.json could execute arbitrary code on the server.
BerriAI/litellm
Originally disclosed on huntr
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.
From the GitHub Advisory Database (GHSA-46cm-pfwv-cgf8, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the chat_template value from tokenizer_config.json is rendered as a Jinja template without sanitisation or sandboxing, allowing template expressions to execute server-side code.
Impact
An attacker could execute arbitrary code on the server, but the text does not state whether any defence or configuration limits the exploit.
What the attacker needed
Ability to supply a malicious tokenizer_config.json
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
LiteLLM is a tool that helps applications talk to large language models. It reads a configuration file that describes how to format chat messages, and it uses a template engine called Jinja to fill in that template. Because the template is not checked, someone who can control that file can make the server run their own code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.