# CVE-2024-22195: Jinja vulnerable to Cross-Site Scripting (XSS)

> Attackers can inject arbitrary HTML attributes via the xmlattr filter, bypassing auto-escaping and leading to Cross-Site Scripting.

- **Severity:** Medium 5.4 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 11 Jan 2024
- **Updated:** 3 Nov 2025
- **Also known as:** ALPINE-CVE-2024-22195, ALSA-2024:2348, ALSA-2024:3102, AZL-33320, AZL-33349, AZL-35050, AZL-35134, BELL-CVE-2024-22195, DEBIAN-CVE-2024-22195, DLA-3715-1, ECHO-824c-172c-a93b, GHSA-h5c8-rqwp-cp95, OESA-2024-1128, PYSEC-2026-1473, RHBA-2024:0891, RHBA-2024:1416, RHSA-2024:2348, RHSA-2024:2733, RHSA-2024:3102, RLSA-2024:3102, ROOT-APP-PYPI-CVE-2024-22195, UBUNTU-CVE-2024-22195, openSUSE-SU-2024:13581-1

## What is CVE-2024-22195?

CVE-2024-22195 is a medium-severity cross-site scripting vulnerability in pallets jinja, published on 11 Jan 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

Jinja is an extensible templating engine. Special placeholders in the template allow writing code similar to Python syntax. It is possible to inject arbitrary HTML attributes into the rendered HTML template, potentially leading to Cross-Site Scripting (XSS). The Jinja `xmlattr` filter can be abused to inject arbitrary HTML attribute keys and values, bypassing the auto escaping mechanism and potentially leading to XSS. It may also be possible to bypass attribute validation checks if they are blacklist-based.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

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

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `jinja2` | PyPI | All versions | 3.1.3 |
| `jinja2` | PyPI | All versions | 3.1.3 |
| `jinja2` | PyPI | All versions | 3.1.3 |
| `python3-jinja2` | AlmaLinux:8 | All versions | 2.10.1-4.el8 |
| `python3-jinja2` | AlmaLinux:9 | All versions | 2.11.3-5.el9 |
| `fence-agents` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-aliyun-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-all` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-amt-ws` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-apc` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-apc-snmp` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-bladecenter` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-brocade` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-cisco-mds` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-cisco-ucs` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-common` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-compute` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-drac5` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-eaton-snmp` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-emerson` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-eps` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-heuristics-ping` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-hpblade` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ibm-powervs` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ibm-vpc` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ibmblade` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ifmib` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ilo-moonshot` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ilo-mp` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ilo-ssh` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ilo2` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-intelmodular` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ipdu` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-ipmilan` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-kdump` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-kdump-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-kubevirt` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |
| `fence-agents-kubevirt-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.2.1-121.el8_9.4 |

Products: Palletsprojects Jinja.

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

Upgrade jinja2 to 3.1.3 or later.

## Is CVE-2024-22195 being exploited?

There is no known exploitation of CVE-2024-22195 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-56201](https://insights.sbomify.com/CVE-2024-56201/): Jinja has a sandbox breakout through malicious filenames (medium 5.4)
- [CVE-2024-56326](https://insights.sbomify.com/CVE-2024-56326/): Jinja has a sandbox breakout through indirect reference to format method (medium 5.4)

## Fix prompt for AI coding agents

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

What it is: CVE-2024-22195 is a medium-severity cross-site scripting vulnerability in pallets jinja, published on 11 Jan 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2024-22195 in the wild and no public exploit code.

Affected packages and fixed versions:
- jinja2 (PyPI): affected all versions; fixed in 3.1.3
- jinja2 (PyPI): affected all versions; fixed in 3.1.3
- jinja2 (PyPI): affected all versions; fixed in 3.1.3

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-22195/ (Markdown: https://insights.sbomify.com/CVE-2024-22195/index.md)
```

## Sources

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

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