CVE-2024-56326 — Vulnerability in jinja2 — CVE Details
Jinja has a sandbox breakout through indirect reference to format method
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.60%). Schedule for your next planned update.
Does your project use an affected jinja2 version?
Paste your requirements.txt to check it for CVE-2024-56326 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
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.
To 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.
Jinja'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.
Advisory Timeline
- First published December 23, 2024 (703 days ago).
- Last revised September 10, 2026 — 625 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
pip install "jinja2>=3.1.5"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: PyPI (1).
| Package | Fixed In |
|---|---|
| jinja2 PyPI · Affected: 2.0, 2.0rc1, 2.1, 2.1.1 (+46 more) | 3.1.5 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-693Protection Mechanism FailureMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.8 score means for each attack dimension.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
References
- https://github.com/pallets/jinja/security/advisories/GHSA-q2x7-8rv6-6q7hWEB
- https://nvd.nist.gov/vuln/detail/CVE-2024-56326ADVISORY
- https://github.com/pallets/jinja/commit/48b0687e05a5466a91cd5812d604fa37ad0943b4WEB
- https://github.com/pallets/jinjaPACKAGE
- https://github.com/pallets/jinja/releases/tag/3.1.5WEB
- https://lists.debian.org/debian-lts-announce/2025/04/msg00022.htmlWEB
Frequently Asked Questions
- What is CVE-2024-56326?
- Jinja has a sandbox breakout through indirect reference to format method. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 7.8/10).
- How do I check if my project is affected by CVE-2024-56326?
- CVE-2024-56326 affects jinja2. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2024-56326 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is a below-median EPSS score — only 42.5% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2025-27516HIGH
Jinja2 vulnerable to sandbox breakout through attr filter selecting format method
- CVE-2024-56201HIGH
Jinja has a sandbox breakout through malicious filenames
- CVE-2024-34064MEDIUM
Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter
- CVE-2026-129221MEDIUM
NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels
- CVE-2025-27516MEDIUM
Jinja2 vulnerable to sandbox breakout through attr filter selecting format method
- CVE-2024-56201MEDIUM
Jinja has a sandbox breakout through malicious filenames
- CVE-2024-34064MEDIUM
Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter
- CVE-2026-128140MEDIUM
NLTK: Downloader cyclic collection indices cause an infinite closure walk