CVE-2024-56326 Jinja has a sandbox breakout through indirect reference to format method
Attackers controlling template content can execute arbitrary Python code via sandbox bypass if custom filters are present.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Local or same network only
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2024-56326?
CVE-2024-56326 is a medium-severity code injection vulnerability in pallets jinja, published on 23 Dec 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Official description
Jinja is an extensible templating engine. Prior to 3.1.5, 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. This vulnerability is fixed in 3.1.5.
Which versions are affected by CVE-2024-56326?
3 open source packages ship an affected version, including jinja2. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
jinja2 PyPI | All versions | 3.1.5 |
jinja2 PyPI | All versions | 3.1.5 |
jinja2 PyPI | All versions | 3.1.5 |
Linux distribution packages (37)
python3-jinja2 AlmaLinux:8 | All versions | 2.10.1-6.el8_10 |
python3-jinja2 AlmaLinux:9 | All versions | 2.11.3-7.el9_5 |
python-jinja2 Red Hat:enterprise_linux:8::appstream | All versions | 0:2.10.1-6.el8_10 |
python3-jinja2 Red Hat:enterprise_linux:8::appstream | All versions | 0:2.10.1-6.el8_10 |
python-jinja2 Red Hat:enterprise_linux:9::appstream | All versions | 0:2.11.3-7.el9_5 |
python3-jinja2 Red Hat:enterprise_linux:9::appstream | All versions | 0:2.11.3-7.el9_5 |
python-jinja2 Red Hat:rhel_aus:8.2::appstream | All versions | 0:2.10.1-2.el8_2.3 |
python3-jinja2 Red Hat:rhel_aus:8.2::appstream | All versions | 0:2.10.1-2.el8_2.3 |
python-jinja2 Red Hat:rhel_aus:8.4::appstream | All versions | 0:2.10.1-2.el8_4.1 |
python3-jinja2 Red Hat:rhel_aus:8.4::appstream | All versions | 0:2.10.1-2.el8_4.1 |
python-jinja2 Red Hat:rhel_aus:8.6::appstream | All versions | 0:2.10.1-4.el8_6.1 |
python3-jinja2 Red Hat:rhel_aus:8.6::appstream | All versions | 0:2.10.1-4.el8_6.1 |
python-jinja2 Red Hat:rhel_e4s:8.4::appstream | All versions | 0:2.10.1-2.el8_4.1 |
python3-jinja2 Red Hat:rhel_e4s:8.4::appstream | All versions | 0:2.10.1-2.el8_4.1 |
python-jinja2 Red Hat:rhel_e4s:8.6::appstream | All versions | 0:2.10.1-4.el8_6.1 |
python3-jinja2 Red Hat:rhel_e4s:8.6::appstream | All versions | 0:2.10.1-4.el8_6.1 |
python-jinja2 Red Hat:rhel_e4s:9.0::appstream | All versions | 0:2.11.3-4.el9_0.1 |
python3-jinja2 Red Hat:rhel_e4s:9.0::appstream | All versions | 0:2.11.3-4.el9_0.1 |
python-jinja2 Red Hat:rhel_els:7 | All versions | 0:2.7.2-5.el7_9 |
python-jinja2 Red Hat:rhel_eus:8.8::appstream | All versions | 0:2.10.1-4.el8_8.1 |
python3-jinja2 Red Hat:rhel_eus:8.8::appstream | All versions | 0:2.10.1-4.el8_8.1 |
python-jinja2 Red Hat:rhel_eus:9.2::appstream | All versions | 0:2.11.3-4.el9_2.1 |
python3-jinja2 Red Hat:rhel_eus:9.2::appstream | All versions | 0:2.11.3-4.el9_2.1 |
python-jinja2 Red Hat:rhel_eus:9.4::appstream | All versions | 0:2.11.3-6.el9_4 |
python3-jinja2 Red Hat:rhel_eus:9.4::appstream | All versions | 0:2.11.3-6.el9_4 |
python-jinja2 Red Hat:rhel_tus:8.4::appstream | All versions | 0:2.10.1-2.el8_4.1 |
python3-jinja2 Red Hat:rhel_tus:8.4::appstream | All versions | 0:2.10.1-2.el8_4.1 |
python-jinja2 Red Hat:rhel_tus:8.6::appstream | All versions | 0:2.10.1-4.el8_6.1 |
python3-jinja2 Red Hat:rhel_tus:8.6::appstream | All versions | 0:2.10.1-4.el8_6.1 |
python-jinja2 Rocky Linux:8 | All versions | 0:2.10.1-6.el8_10 |
python-jinja2 Rocky Linux:9 | All versions | 0:2.11.3-7.el9_5 |
python-Jinja2 SUSE:Enterprise Storage 7.1 | All versions | 2.10.1-150000.3.18.1 |
python-Jinja2 SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 2.10.1-150000.3.18.1 |
python-Jinja2 SUSE:Linux Enterprise High Performance Computing 15 SP4-ESPOS | All versions | 2.10.1-150000.3.18.1 |
python-Jinja2 SUSE:Linux Enterprise High Performance Computing 15 SP4-LTSS | All versions | 2.10.1-150000.3.18.1 |
python-Jinja2 SUSE:Linux Enterprise High Performance Computing 15 SP5-ESPOS | All versions | 2.10.1-150000.3.18.1 |
python-Jinja2 SUSE:Linux Enterprise High Performance Computing 15 SP5-LTSS | All versions | 2.10.1-150000.3.18.1 |
Products include Palletsprojects Jinja.
How do I fix CVE-2024-56326?
Upgrade jinja2 to 3.1.5 or later.
Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.
Is CVE-2024-56326 being exploited?
There is no known exploitation of CVE-2024-56326 in the wild and no public exploit code.
Other vulnerabilities in pallets jinja
Sources
Also known as ALPINE-CVE-2024-56326, ALSA-2025:0667, ALSA-2025:0711, AZL-54647, AZL-54654, BELL-CVE-2024-56326 and 29 more.