Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter
Published 11 Jan 2024 · Updated 10 Sept 2026
Is your project on an affected jinja2?
Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- <3.1.3
- Fixed in
- 3.1.3
pip install 'jinja2>=3.1.3'Details
The xmlattr filter in affected versions of Jinja accepts keys containing spaces. XML/HTML attributes cannot contain spaces, as each would then be interpreted as 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. Note that accepting keys as user input is not common or a particularly intended use case of the xmlattr filter, and an application doing so should already be verifying what keys are provided regardless of this fix.
Is GHSA-h5c8-rqwp-cp95 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected jinja2, and gives you the command that fixes it.
More advisories for jinja2
- MediumCVE-2025-27516Jinja2 vulnerable to sandbox breakout through attr filter selecting format method · 5 Mar 2025
- MediumCVE-2024-56326Jinja has a sandbox breakout through indirect reference to format method · 23 Dec 2024
- MediumCVE-2024-56201Jinja has a sandbox breakout through malicious filenames · 23 Dec 2024
- MediumCVE-2024-34064Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter · 6 May 2024
- MediumCVE-2014-0012Insecure Temporary File in Jinja2 · 17 May 2022
- HighCVE-2014-1402Incorrect Privilege Assignment in Jinja2 · 14 May 2022
References
- Linkgithub.com/pallets/jinja/security/advisories/GHSA-h5c8-rqwp-cp95
- Advisorynvd.nist.gov/vuln/detail/CVE-2024-22195
- Linkgithub.com/pallets/jinja/commit/716795349a41d4983a9a4771f7d883c96ea17be7
- Packagegithub.com/pallets/jinja
- Linkgithub.com/pallets/jinja/releases/tag/3.1.3
- Linklists.debian.org/debian-lts-announce/2024/01/msg00010.html
- Linklists.debian.org/debian-lts-announce/2024/12/msg00009.html
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/5XCWZD464AJJJUBOO7CMPXQ4ROBC6JX2
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/DELCVUUYX75I5K4Q5WMJG4MUZJA6VAIP
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/O7YWRBX6JQCWC2XXCTZ55C7DPMGICCN3
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.