# CVE-2024-34064: Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter

> Attackers can inject HTML attributes via user-controlled keys in the xmlattr filter, leading to XSS in applications rendering this input.

- **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:** 6 May 2024
- **Updated:** 3 Nov 2025
- **Also known as:** ALPINE-CVE-2024-34064, ALSA-2024:3820, ALSA-2024:4231, ALSA-2024:9150, AZL-40369, AZL-40420, AZL-40439, AZL-40444, AZL-75801, BELL-CVE-2024-34064, DEBIAN-CVE-2024-34064, ECHO-648f-de3d-6831, GHSA-h75v-3vvj-5mfj, MINI-3c85-f2q7-jr76, OESA-2024-1605, PYSEC-2026-1474, RHSA-2024:3795, RHSA-2024:3811, RHSA-2024:3820, RHSA-2024:4231, RHSA-2024:4404, RHSA-2024:4414, RHSA-2024:4427, RHSA-2024:4958, RHSA-2024:6011, RHSA-2024:9150, RLSA-2024:3820, RLSA-2024:4231, RLSA-2024:9150, ROOT-APP-PYPI-CVE-2024-34064, SUSE-SU-2024:1948-1, UBUNTU-CVE-2024-34064, USN-6787-1

## What is CVE-2024-34064?

CVE-2024-34064 is a medium-severity cross-site scripting vulnerability in Fedoraproject Fedora, published on 6 May 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. The `xmlattr` filter in affected versions of Jinja accepts keys containing non-attribute characters. XML/HTML attributes cannot contain spaces, `/`, `>`, or `=`, as each would then be interpreted as starting a separate attribute. If an application accepts keys (as opposed to only values) as user input, and renders these in pages that other users see as well, an attacker could use this to inject other attributes and perform XSS. The fix for CVE-2024-22195 only addressed spaces but not other characters. Accepting keys as user input is now explicitly considered an unintended use case of the `xmlattr` filter, and code that does so without otherwise validating the input should be flagged as insecure, regardless of Jinja version. Accepting _values_ as user input continues to be safe. This vulnerability is fixed in 3.1.4.

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

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

3 open source packages ship an affected version, including jinja2 and Jinja2. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `jinja2` | PyPI | All versions | 3.1.4 |
| `jinja2` | PyPI | All versions | 3.1.4 |
| `Jinja2` | PyPI | All versions | 3.1.4 |
| `python3-jinja2` | AlmaLinux:8 | All versions | 2.10.1-5.el8_10 |
| `fence-agents-aliyun` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-all` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-amt-ws` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-apc` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-apc-snmp` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-aws` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-azure-arm` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-bladecenter` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-brocade` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-cisco-mds` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-cisco-ucs` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-common` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-compute` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-drac5` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-eaton-snmp` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-emerson` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-eps` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-gce` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-heuristics-ping` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-hpblade` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ibm-powervs` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ibm-vpc` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ibmblade` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ifmib` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ilo-moonshot` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ilo-mp` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ilo-ssh` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ilo2` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-intelmodular` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ipdu` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-ipmilan` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-kdump` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-kubevirt` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-lpar` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-mpath` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |
| `fence-agents-openstack` | AlmaLinux:9 | All versions | 4.10.0-62.el9_4.3 |

Products: Fedoraproject Fedora, Palletsprojects Jinja.

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

Upgrade jinja2 to 3.1.4 or later.

## Is CVE-2024-34064 being exploited?

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

Public exploit code:

- CVE-2024-34064 demo - baseline (no sanitisation) (github_poc): https://github.com/SandBlastx/flask-vuln-baseline
- CVE-2024-34064 demo - v3 subtle vuln no misleading comment (github_poc): https://github.com/SandBlastx/flask-vuln-v3
- CVE-2024-34064 demo - v4 subtle vuln good comment (github_poc): https://github.com/SandBlastx/flask-vuln-v4
- CVE-2024-34064 demo - v1 genuine fix honest comments (github_poc): https://github.com/SandBlastx/flask-vuln-v1
- CVE-2024-34064 demo - v2 genuine fix bad comments (github_poc): https://github.com/SandBlastx/flask-vuln-v2
- CVE-2024-34064 demo - v5 regex missing end anchor (github_poc): https://github.com/SandBlastx/flask-vuln-v5

## Other vulnerabilities in Fedoraproject Fedora

- [CVE-2024-4577](https://insights.sbomify.com/CVE-2024-4577/): PHP-CGI OS Command Injection (critical 9.8, exploited in the wild)
- [CVE-2021-39226](https://insights.sbomify.com/CVE-2021-39226/): Grafana Authentication Bypass (critical 9.8, exploited in the wild)
- [CVE-2019-5544](https://insights.sbomify.com/CVE-2019-5544/): VMware ESXi and Horizon DaaS OpenSLP Heap-Based Buffer Overflow (critical 9.8, exploited in the wild)
- [CVE-2024-4947](https://insights.sbomify.com/CVE-2024-4947/): Google Chromium V8 Type Confusion (critical 9.6, exploited in the wild)
- [CVE-2024-4671](https://insights.sbomify.com/CVE-2024-4671/): Google Chromium Visuals Use-After-Free (critical 9.6, exploited in the wild)

## Fix prompt for AI coding agents

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

What it is: CVE-2024-34064 is a medium-severity cross-site scripting vulnerability in Fedoraproject Fedora, published on 6 May 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-34064 in the wild and no public exploit code.

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

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

## Sources

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

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