The root cause of the vulnerability is a Server-Side Template Injection (SSTI) in the /prompts/test endpoint of LiteLLM. The endpoint uses a jinja2 template engine to render user-provided templates. Prior to the patch, the Jinja2 environment was not sandboxed, allowing an authenticated attacker to craft a malicious template that, when rendered, would execute arbitrary code on the server.
The patch, found in commit 9b33d9d4276a27fe96becaaf6b41a4d622385401, addresses this issue by replacing the standard jinja2.Environment with jinja2.sandbox.ImmutableSandboxedEnvironment within the PromptManager.__init__ method. This sandboxes the execution of templates, restricting access to unsafe attributes and methods, thereby mitigating the SSTI vulnerability.
While PromptManager.__init__ is the function where the vulnerable configuration is created, the function that would appear in a runtime profile during an exploit is the one that handles the POST /prompts/test request and calls the render method on the template. Although the exact name of this function could not be determined from the provided information, any stack trace related to this vulnerability would involve the PromptManager class and the rendering of a Jinja2 template.