Vulnerability · Published Dec 23, 2024 · Assigned by GitHub_M
CVE-2024-56326Jinja has a sandbox breakout through indirect reference to format method
High 7.8
In plain English
A high-severity security flaw in jinja from pallets. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.5% (higher than 44% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
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.
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| AlmaLinux:9 | fence-agents-common | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-agents-compute | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-agents-ibm-powervs | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-agents-ibm-vpc | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-agents-kubevirt | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-agents-virsh | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-virt | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-virtd | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-virtd-cpg | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-virtd-libvirt | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-virtd-multicast | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-virtd-serial | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:9 | fence-virtd-tcp | 4.10.0-76.el9_5.4.alma.1 | ALSA-2025:0308 |
| AlmaLinux:8 | python3-jinja2 | 2.10.1-6.el8_10 | ALSA-2025:0711 |
| AlmaLinux:9 | python3-jinja2 | 2.11.3-7.el9_5 | ALSA-2025:0667 |
| Alpine:v3.20 | py3-jinja2 | 3.1.5-r0 | ALPINE-CVE-2024-56326 |
| Alpine:v3.21 | py3-jinja2 | 3.1.5-r0 | ALPINE-CVE-2024-56326 |
| Alpine:v3.22 | py3-jinja2 | 3.1.5-r0 | ALPINE-CVE-2024-56326 |
| Alpine:v3.23 | py3-jinja2 | 3.1.5-r0 | ALPINE-CVE-2024-56326 |
| Alpine:v3.24 | py3-jinja2 | 3.1.5-r0 | ALPINE-CVE-2024-56326 |
| Debian:12 | jinja2 | 3.1.2-1+deb12u2 | DEBIAN-CVE-2024-56326 |
| Debian:13 | jinja2 | 3.1.5-1 | DEBIAN-CVE-2024-56326 |
| Debian:14 | jinja2 | 3.1.5-1 | DEBIAN-CVE-2024-56326 |
| PyPI | jinja2 | 3.1.5 | PYSEC-2026-1475 |
| PyPI | jinja2 | 3.1.5 | GHSA-q2x7-8rv6-6q7h |
| Rocky Linux:8 | python-jinja2 | 0:2.10.1-6.el8_10 | RLSA-2025:0711 |
| Rocky Linux:9 | python-jinja2 | 0:2.11.3-7.el9_5 | RLSA-2025:0667 |
| Ubuntu:22.04:LTS | jinja2 | 3.0.3-1ubuntu0.4 | USN-7343-1 |
| Ubuntu:22.04:LTS | jinja2 | 3.0.3-1ubuntu0.3 | USN-7244-1 |
| Ubuntu:22.04:LTS | jinja2 | 3.0.3-1ubuntu0.3 | UBUNTU-CVE-2024-56326 |
| Ubuntu:24.04:LTS | jinja2 | 3.1.2-1ubuntu1.2 | USN-7244-1 |
| Ubuntu:24.04:LTS | jinja2 | 3.1.2-1ubuntu1.2 | UBUNTU-CVE-2024-56326 |
| Ubuntu:24.04:LTS | jinja2 | 3.1.2-1ubuntu1.3 | USN-7343-1 |
Affected products (as reported)
Weakness: CWE-1336, CWE-693 · Vector: 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-6q7h x_refsource_CONFIRM
- https://github.com/pallets/jinja/commit/48b0687e05a5466a91cd5812d604fa37ad0943b4 x_refsource_MISC
- https://github.com/pallets/jinja/releases/tag/3.1.5 x_refsource_MISC
- https://lists.debian.org/debian-lts-announce/2025/04/msg00022.html