CVE-2026-40217: Litellm LiteLLM Has A Sandbox Escape Vulnerability

HIGH
Advisory Identifier: GHSA-wxxx-gvqv-xp7p
CVSS 8.8
CWE-913 CWE-420
Published
Advisory Summary

CVE-2026-40217 is a HIGH (CVSS 8.8) litellm has a sandbox escape vulnerability (CWE-913: Improper Control of Dynamically-Managed Code Resources) affecting Litellm libraries in the PyPI ecosystem. The issue involves litellm has a sandbox escape in custom-code guardrail. Remediation is available by upgrading affected packages to version 1.83.10.

CVE-2026-40217 at a Glance

CVE Identifier CVE-2026-40217
GHSA Identifier GHSA-wxxx-gvqv-xp7p
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-913: Improper Control of Dynamically-Managed Code Resources
Affected Product Litellm
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-40217

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.83.10
pip install litellm>=1.83.10
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-40217, 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.83.10), 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-913: Improper Control of Dynamically-Managed Code Resources, where the product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements. 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 The `POST /guardrails/test_custom_code` endpoint runs user-supplied Python inside a hand-rolled sandbox. The sandbox can be escaped using bytecode-level techniques, allowing arbitrary code execution in the proxy process — which runs as root in the default Docker image. **Reaching the endpoint requires a proxy-admin credential** in default configurations. ### Patches Fixed in **`1.83.11`**. The hand-rolled sandbox has been replaced with `RestrictedPython`. Upgrade to `1.83.11` or later. ### Workarounds If upgrading is not immediately possible, block `POST /guardrails/test_custom_code` at your reverse proxy or API gateway. ### References - Patched release: [`v1.83.10-stable`](https://github.com/BerriAI/litellm/releases/tag/v1.83.10-stable)

CVE-2026-40217 Affected Litellm Versions

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

References

Frequently Asked Questions

What is CVE-2026-40217?
CVE-2026-40217 is a security vulnerability in Litellm involving LiteLLM has a sandbox escape in custom-code guardrail under CWE-913: Improper Control of Dynamically-Managed Code Resources.
Which Litellm versions are affected?
Affected versions include releases prior to 1.83.10 across affected packages: litellm.
What version fixes CVE-2026-40217?
Upgrading to 1.83.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is litellm affected?
Yes, litellm is affected in releases prior to 1.83.10. Upgrade your dependency to 1.83.10 or later.
What is the CVSS score of CVE-2026-40217?
CVE-2026-40217 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-40217?
CVE-2026-40217 is classified under CWE-913: Improper Control of Dynamically-Managed Code Resources (The product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.).
How can I check PyPI dependencies for CVE-2026-40217?
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-wxxx-gvqv-xp7p",
  "modified" : "2026-05-11T16:17:23Z",
  "published" : "2026-05-11T16:17:23Z",
  "aliases" : [ "CVE-2026-40217" ],
  "summary" : "LiteLLM has a sandbox escape in custom-code guardrail",
  "details" : "### Impact\n\nThe `POST /guardrails/test_custom_code` endpoint runs user-supplied Python inside a hand-rolled sandbox. The sandbox can be escaped using bytecode-level techniques, allowing arbitrary code execution in the proxy process — which runs as root in the default Docker image.\n\n**Reaching the endpoint requires a proxy-admin credential** in default configurations.\n\n### Patches\n\nFixed in **`1.83.11`**. The hand-rolled sandbox has been replaced with `RestrictedPython`. Upgrade to `1.83.11` or later.\n\n### Workarounds\n\nIf upgrading is not immediately possible, block `POST /guardrails/test_custom_code` at your reverse proxy or API gateway.\n\n### References\n\n- Patched release: [`v1.83.10-stable`](https://github.com/BerriAI/litellm/releases/tag/v1.83.10-stable)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:H/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "litellm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.81.8"
      }, {
        "fixed" : "1.83.10"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/BerriAI/litellm/security/advisories/GHSA-wxxx-gvqv-xp7p"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40217"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/BerriAI/litellm"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/BerriAI/litellm/releases/tag/v1.83.10-stable"
  }, {
    "type" : "WEB",
    "url" : "https://www.x41-dsec.de/lab/advisories/x41-2026-001-litellm"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-420", "CWE-913" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-11T16:17:23Z",
    "nvd_published_at" : null
  }
}