CVE-2024-56201: Jinja2 Jinja Has A Sandbox Breakout Vulnerability
MODERATECVE-2024-56201 is a MODERATE (CVSS 8.8) jinja has a sandbox breakout vulnerability (CWE-150: Improper Neutralization of Escape, Meta, or Control Sequences) affecting Jinja2 libraries in the PyPI ecosystem. The issue involves jinja has a sandbox breakout through malicious filenames. Remediation is available by upgrading affected packages to version 3.1.5.
CVE-2024-56201 at a Glance
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).
How to Fix CVE-2024-56201
To remediate this vulnerability, upgrade all affected Jinja2 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 jinja2>=3.1.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show jinja2
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2024-56201, inspect your installed packages using pip:
pip show jinja2
Analyze the terminal output to locate any version of Jinja2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.1.5), your application is affected.
Note: The pip show jinja2 command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-150: Improper Neutralization of Escape, Meta, or Control Sequences, where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as escape, meta, or control character sequences when they are sent to a downstream component. In Jinja2, 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-2024-56201 Affected Jinja2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
jinja2
|
PyPI |
≥ 3.0.0
< 3.1.5
|
3.1.5
|
References
Frequently Asked Questions
What is CVE-2024-56201?
Which Jinja2 versions are affected?
What version fixes CVE-2024-56201?
Is jinja2 affected?
What is the CVSS score of CVE-2024-56201?
What CWE is associated with CVE-2024-56201?
How can I check PyPI dependencies for CVE-2024-56201?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-gmj6-6f8f-6699",
"modified" : "2025-01-08T16:06:01Z",
"published" : "2024-12-23T17:54:12Z",
"aliases" : [ "CVE-2024-56201" ],
"summary" : "Jinja has a sandbox breakout through malicious filenames",
"details" : "A bug in the Jinja compiler allows an attacker that controls both the content and filename of a template to execute arbitrary Python code, regardless of if Jinja's sandbox is used.\n\nTo exploit the vulnerability, an attacker needs to control both the filename and the contents of a template. Whether that is the case depends on the type of application using Jinja. This vulnerability impacts users of applications which execute untrusted templates where the template author can also choose the template filename.",
"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:L/AC:L/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "jinja2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.0"
}, {
"fixed" : "3.1.5"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.1.4"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/pallets/jinja/security/advisories/GHSA-gmj6-6f8f-6699"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-56201"
}, {
"type" : "WEB",
"url" : "https://github.com/pallets/jinja/issues/1792"
}, {
"type" : "WEB",
"url" : "https://github.com/pallets/jinja/commit/767b23617628419ae3709ccfb02f9602ae9fe51f"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/pallets/jinja"
}, {
"type" : "WEB",
"url" : "https://github.com/pallets/jinja/releases/tag/3.1.5"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-150" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-12-23T17:54:12Z",
"nvd_published_at" : "2024-12-23T16:15:07Z"
}
}