CVE-2026-59821: LiteLLM Custom Code Guardrails Production Endpoints Vulnerability
LOWCVE-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
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.
pip install litellm>=1.82.0
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
CVE-2026-59821 Affected LiteLLM Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
litellm
|
PyPI |
< 1.82.0
|
1.82.0
|
References
Frequently Asked Questions
What is CVE-2026-59821?
Which LiteLLM versions are affected?
What version fixes CVE-2026-59821?
Is litellm affected?
What CWE is associated with CVE-2026-59821?
How can I check PyPI dependencies for CVE-2026-59821?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}