CVE-2026-59821: BerriAI LiteLLM code injection in Custom Code Guardrails

CVE-2026-59821 · Severity: medium · CVSS 4 · Published 2026-07-08

LiteLLM, a tool used to manage and proxy various AI models, contains a vulnerability in its 'Custom Code Guardrails' feature. This flaw allows users with administrative access to bypass security sandboxing and execute arbitrary Python code on the server. If a master key is not configured, even non-administrative users might be able to exploit this, potentially leading to the theft of sensitive API keys and service disruption.

Technologies: Berriai LiteLLM, litellm (PyPI). Vendors: Berriai, PyPI.

Quick answers

Is CVE-2026-59821 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-59821 being exploited in the wild.
How severe is CVE-2026-59821?
Medium severity, with a CVSS score of 4, published 8 July 2026.
Which products and versions are affected?
Berriai LiteLLM < 1.82.0, < 1.82.0-stable; litellm (PyPI) ECOSYSTEM:introduced=0,fixed=1.82.0.
Is there a fix for CVE-2026-59821?
Yes. litellm (PyPI): upgrade to 1.82.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-59821 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-59821?
Check whether you run Berriai LiteLLM or litellm (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • litellm (PyPI): upgrade to 1.82.0 or later
    pip install "litellm>=1.82.0"

Technical details

A code injection vulnerability exists in LiteLLM's production endpoints for creating and updating Custom Code Guardrails (POST /guardrails and PUT /guardrails/{guardrail_id}). Unlike the test endpoint, these production paths failed to apply proper sandboxing and validation to user-submitted Python code. An attacker with administrative privileges—or a standard user in deployments where LITELLM_MASTER_KEY is not set—can execute arbitrary Python code within the LiteLLM proxy container. This can lead to full container compromise and the exposure of environment variables and secrets. The issue is resolved in version 1.82.0-stable.

Affected products

  • BerriAI litellm < 1.82.0

Identifiers

  • CVE-2026-59821
  • GHSA-72m8-9m7m-h278
  • PYSEC-2026-3478

Timeline

  • 2026-06-30: disclosed: Initial disclosure by reporter
  • 2026-07-08: advisory: NVD publication
  • 2026-07-22: advisory: GitHub Advisory published

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.