# CVE-2024-56201: Jinja has a sandbox breakout through malicious filenames

> Attackers controlling template filename and content can execute arbitrary Python code, bypassing Jinja's sandbox in affected versions.

- **Severity:** Medium 5.4 (`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`)
- **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:** Yes
- **Published:** 23 Dec 2024
- **Updated:** 18 Feb 2025
- **Also known as:** ALPINE-CVE-2024-56201, AZL-54650, AZL-54660, BELL-CVE-2024-56201, CLEANSTART-2026-JN63910, CLEANSTART-2026-WJ72873, DEBIAN-CVE-2024-56201, ECHO-2933-1e79-af27, GHSA-gmj6-6f8f-6699, MINI-hxxc-qr7w-7vxc, MINI-vxwv-h4m4-mr94, OESA-2025-1007, OESA-2025-1008, PYSEC-2026-1472, ROOT-APP-PYPI-CVE-2024-56201, UBUNTU-CVE-2024-56201

## What is CVE-2024-56201?

CVE-2024-56201 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. In versions on the 3.x branch prior to 3.1.5, a bug in the Jinja compiler allows an attacker that controls both the content and filename of a template to execute arbitrary Python code, regardless of if Jinja's sandbox is used. To exploit the vulnerability, an attacker needs to control both the filename and the contents 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 where the template author can also choose the template filename. This vulnerability is fixed in 3.1.5.

Weakness: CWE-150 (Improper Neutralization of Escape, Meta, or Control Sequences)

## Which versions are affected by CVE-2024-56201?

3 open source packages ship an affected version, including jinja2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `jinja2` | PyPI | From 3.0.0 | 3.1.5 |
| `jinja2` | PyPI | From 3.0.0 | 3.1.5 |
| `jinja2` | PyPI | From 3.0.0 | 3.1.5 |

Products: Palletsprojects Jinja.

## How do I fix CVE-2024-56201?

Upgrade jinja2 to 3.1.5 or later.

## Is CVE-2024-56201 being exploited?

There is no known exploitation of CVE-2024-56201 in the wild and no public exploit code.

## Other vulnerabilities in pallets jinja

- [CVE-2016-10745](https://insights.sbomify.com/CVE-2016-10745/): Jinja2 sandbox escape vulnerability (high 8.6)
- [CVE-2024-56326](https://insights.sbomify.com/CVE-2024-56326/): Jinja has a sandbox breakout through indirect reference to format method (medium 5.4)
- [CVE-2024-22195](https://insights.sbomify.com/CVE-2024-22195/): Jinja vulnerable to Cross-Site Scripting (XSS) (medium 5.4)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-56201 and fix it if it is affected.

What it is: CVE-2024-56201 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.
Exploitation: There is no known exploitation of CVE-2024-56201 in the wild and no public exploit code.

Affected packages and fixed versions:
- jinja2 (PyPI): affected from 3.0.0; fixed in 3.1.5
- jinja2 (PyPI): affected from 3.0.0; fixed in 3.1.5
- jinja2 (PyPI): affected from 3.0.0; fixed in 3.1.5

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-56201/ (Markdown: https://insights.sbomify.com/CVE-2024-56201/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-56201
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-56201
- OSV: https://osv.dev/vulnerability/CVE-2024-56201

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-56201/
Summaries are generated and may contain mistakes; the official description above is the record.
