CVE-2024-56326: Jinja2 Jinja Has A Sandbox Breakout Vulnerability
MODERATECVE-2024-56326 is a MODERATE (CVSS 7.8) jinja has a sandbox breakout vulnerability (CWE-693: Protection Mechanism Failure) affecting Jinja2 libraries in the PyPI ecosystem. The issue involves jinja has a sandbox breakout through indirect reference to format method. Remediation is available by upgrading affected packages to version 3.1.5.
CVE-2024-56326 at a Glance
Security Impact
CVSS: 7.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2024-56326
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-56326, 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-693: Protection Mechanism Failure, where the product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. 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-56326 Affected Jinja2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
jinja2
|
PyPI |
< 3.1.5
|
3.1.5
|
References
Frequently Asked Questions
What is CVE-2024-56326?
Which Jinja2 versions are affected?
What version fixes CVE-2024-56326?
Is jinja2 affected?
What is the CVSS score of CVE-2024-56326?
What CWE is associated with CVE-2024-56326?
How can I check PyPI dependencies for CVE-2024-56326?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-q2x7-8rv6-6q7h",
"modified" : "2025-11-03T22:50:50Z",
"published" : "2024-12-23T17:56:08Z",
"aliases" : [ "CVE-2024-56326" ],
"summary" : "Jinja has a sandbox breakout through indirect reference to format method",
"details" : "An oversight in how the Jinja sandboxed environment detects calls to `str.format` allows an attacker that controls the content of a template to execute arbitrary Python code.\n\nTo exploit the vulnerability, an attacker needs to control the content 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.\n\nJinja's sandbox does catch calls to `str.format` and ensures they don't escape the sandbox. However, it's possible to store a reference to a malicious string's `format` method, then pass that to a filter that calls it. No such filters are built-in to Jinja, but could be present through custom filters in an application. After the fix, such indirect calls are also handled by the sandbox.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/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" : "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-q2x7-8rv6-6q7h"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-56326"
}, {
"type" : "WEB",
"url" : "https://github.com/pallets/jinja/commit/48b0687e05a5466a91cd5812d604fa37ad0943b4"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/pallets/jinja"
}, {
"type" : "WEB",
"url" : "https://github.com/pallets/jinja/releases/tag/3.1.5"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2025/04/msg00022.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-693" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-12-23T17:56:08Z",
"nvd_published_at" : "2024-12-23T16:15:07Z"
}
}