Skip to main content

CVE-2024-56326 — Vulnerability in jinja2 — CVE Details

MEDIUM

Jinja has a sandbox breakout through indirect reference to format method

Published December 23, 2024Updated September 10, 2026Source: OSV

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.

Check my requirements.txt

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
Update jinja2 to 3.1.5 or later
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).

PackageFixed 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-693
    Protection Mechanism FailureMITRE

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 7.8 score means for each attack dimension.

Attack Vector
Local
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

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

CVSS Score
7.8

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
0.60%
EPSS percentile: 42.5

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

GHSA-q2x7-8rv6-6q7h
PYSEC-2026-1475

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my requirements.txt