CVE-2026-59821: LiteLLM Custom Code Guardrails Production Endpoints Vulnerability

LOW
Advisory Identifier: GHSA-72m8-9m7m-h278
CWE-94
Published
Advisory Summary

CVE-2026-59821 is a LOW custom code guardrails production endpoints vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting LiteLLM libraries in the PyPI ecosystem. The issue involves custom code guardrails production endpoints bypass code safety checks. Remediation is available by upgrading affected packages to version 1.82.0.

CVE-2026-59821 at a Glance

CVE Identifier CVE-2026-59821
GHSA Identifier GHSA-72m8-9m7m-h278
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product LiteLLM
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2026-59821

To remediate this vulnerability, upgrade all affected LiteLLM dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

litellm fixed: 1.82.0
pip install litellm>=1.82.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show litellm

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-59821, inspect your installed packages using pip:

pip show litellm

Analyze the terminal output to locate any version of LiteLLM in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.82.0), your application is affected.

Note: The pip show litellm command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In LiteLLM, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact LiteLLM's Custom Code Guardrails production create/update paths did not apply the same sandboxing and validation used by the test endpoint. A privileged user with access to create or update guardrails could submit custom Python code that executed in the LiteLLM proxy environment. In deployments without a configured master key, callers could be treated as proxy administrators, making this reachable without intended administrative authorization. This could allow arbitrary code execution in the LiteLLM proxy container and exposure of secrets available to the process. ### Patches The issue is fixed in `1.82.0-stable`. LiteLLM recommend upgrading to `1.82.0-stable` or later. ### Workarounds If upgrading is not immediately possible: 1. Restrict access to `POST /guardrails` and `PUT /guardrails/{guardrail_id}` to trusted administrators only. 2. Ensure `LITELLM_MASTER_KEY` is configured. 3. Avoid enabling Custom Code Guardrails for untrusted users.

CVE-2026-59821 Affected LiteLLM Versions

1 component(s)
Fixed Versions:
1.82.0
Product / Package Ecosystem Affected Versions Fixed Version
litellm
PyPI
< 1.82.0
1.82.0

References

Frequently Asked Questions

What is CVE-2026-59821?
CVE-2026-59821 is a security vulnerability in LiteLLM involving Custom Code Guardrails production endpoints bypass code safety checks under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which LiteLLM versions are affected?
Affected versions include releases prior to 1.82.0 across affected packages: litellm.
What version fixes CVE-2026-59821?
Upgrading to 1.82.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is litellm affected?
Yes, litellm is affected in releases prior to 1.82.0. Upgrade your dependency to 1.82.0 or later.
What CWE is associated with CVE-2026-59821?
CVE-2026-59821 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check PyPI dependencies for CVE-2026-59821?
Run the dependency tree command: 'pip show litellm'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-72m8-9m7m-h278",
  "modified" : "2026-07-22T22:38:55Z",
  "published" : "2026-07-22T22:38:55Z",
  "aliases" : [ "CVE-2026-59821" ],
  "summary" : "LiteLLM: Custom Code Guardrails production endpoints bypass code safety checks",
  "details" : "### Impact\n\nLiteLLM's Custom Code Guardrails production create/update paths did not apply the same sandboxing and validation used by the test endpoint.\n\nA privileged user with access to create or update guardrails could submit custom Python code that executed in the LiteLLM proxy environment. In deployments without a configured master key, callers could be treated as proxy administrators, making this reachable without intended administrative authorization.\n\nThis could allow arbitrary code execution in the LiteLLM proxy container and exposure of secrets available to the process.\n\n### Patches\n\nThe issue is fixed in `1.82.0-stable`.\n\nLiteLLM recommend upgrading to `1.82.0-stable` or later.\n\n### Workarounds\n\nIf upgrading is not immediately possible:\n\n1. Restrict access to `POST /guardrails` and `PUT /guardrails/{guardrail_id}` to trusted administrators only.\n2. Ensure `LITELLM_MASTER_KEY` is configured.\n3. Avoid enabling Custom Code Guardrails for untrusted users.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "litellm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.82.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/BerriAI/litellm/security/advisories/GHSA-72m8-9m7m-h278"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-59821"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/BerriAI/litellm/commit/e50b4486d0f7aa0497185a1ebcdd2c91f1769eba"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/BerriAI/litellm"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/BerriAI/litellm/releases/tag/v1.82.0-stable"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-22T22:38:55Z",
    "nvd_published_at" : "2026-07-08T20:16:57Z"
  }
}