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

Medium 5.4 Published Updated

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

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-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

Which versions are affected by CVE-2024-22195?

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

PackageAffectedFixed in
jinja2 PyPIAll versions3.1.3
jinja2 PyPIAll versions3.1.3
jinja2 PyPIAll versions3.1.3
Linux distribution packages (37)
python3-jinja2 AlmaLinux:8All versions2.10.1-4.el8
python3-jinja2 AlmaLinux:9All versions2.11.3-5.el9
fence-agents Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-aliyun-debuginfo Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-all Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-amt-ws Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-apc Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-apc-snmp Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-bladecenter Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-brocade Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-cisco-mds Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-cisco-ucs Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-common Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-compute Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-debuginfo Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-debugsource Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-drac5 Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-eaton-snmp Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-emerson Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-eps Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-heuristics-ping Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-hpblade Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ibm-powervs Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ibm-vpc Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ibmblade Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ifmib Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ilo-moonshot Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ilo-mp Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ilo-ssh Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ilo2 Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-intelmodular Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ipdu Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-ipmilan Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-kdump Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-kdump-debuginfo Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-kubevirt Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4
fence-agents-kubevirt-debuginfo Red Hat:enterprise_linux:8::appstreamAll versions0:4.2.1-121.el8_9.4

Products include Palletsprojects Jinja.

How do I fix CVE-2024-22195?

Upgrade jinja2 to 3.1.3 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-22195 being exploited?

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

Sources

Also known as ALPINE-CVE-2024-22195, ALSA-2024:2348, ALSA-2024:3102, AZL-33320, AZL-33349, AZL-35050 and 17 more.

Is CVE-2024-22195 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free