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.
- 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
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
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 | Affected | Fixed in |
|---|---|---|
jinja2 PyPI | All versions | 3.1.4 |
jinja2 PyPI | All versions | 3.1.4 |
Jinja2 PyPI | All versions | 3.1.4 |
Linux distribution packages (37)
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 include Fedoraproject Fedora, Palletsprojects Jinja.
How do I fix CVE-2024-34064?
Upgrade jinja2 to 3.1.4 or later.
Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.
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: 7 proofs of concept on GitHub.
Other vulnerabilities in Fedoraproject Fedora
Sources
Also known as ALPINE-CVE-2024-34064, ALSA-2024:3820, ALSA-2024:4231, ALSA-2024:9150, AZL-40369, AZL-40420 and 27 more.