Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

CVE-2024-22195: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in pallets jinja

0
Medium
VulnerabilityCVE-2024-22195cvecve-2024-22195cwe-79
Published: Thu Jan 11 2024 (01/11/2024, 02:25:44 UTC)
Source: CVE Database V5
Vendor/Project: pallets
Product: jinja

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.

AI-Powered Analysis

AILast updated: 11/03/2025, 23:53:54 UTC

Technical Analysis

CVE-2024-22195 is a Cross-Site Scripting (XSS) vulnerability identified in the Jinja templating engine, specifically affecting versions prior to 3.1.3. Jinja is widely used in Python web applications to generate dynamic HTML content through templates that support Python-like syntax. The vulnerability stems from the `xmlattr` filter, which is designed to convert a dictionary of attributes into a string of HTML attributes. However, this filter can be abused to inject arbitrary HTML attribute keys and values, effectively bypassing Jinja's auto-escaping mechanisms. This improper neutralization of input during web page generation (classified as CWE-79) allows an attacker to craft malicious templates or input that, when rendered, inject executable JavaScript code into the resulting HTML page. The attack vector requires no privileges (no authentication) but does require user interaction, such as a victim visiting a maliciously crafted page or submitting crafted input. The vulnerability can also bypass blacklist-based attribute validation checks, making it more difficult to detect or prevent through simple filtering. Although no exploits have been reported in the wild, the flaw poses a risk to confidentiality and integrity by enabling script injection that can steal user credentials, hijack sessions, or manipulate page content. The CVSS v3.1 score is 5.4 (medium severity), reflecting the network attack vector, low attack complexity, no privileges required, but requiring user interaction and limited impact on confidentiality and integrity. The vulnerability affects all Jinja versions before 3.1.3, and the recommended fix is to upgrade to version 3.1.3 or later where the issue is resolved.

Potential Impact

For European organizations, this vulnerability can lead to exploitation of web applications that use vulnerable Jinja versions, potentially resulting in Cross-Site Scripting attacks. Such attacks can compromise user data confidentiality by stealing cookies, session tokens, or other sensitive information. Integrity of web content can also be affected by unauthorized script execution, leading to phishing or defacement. Although availability impact is minimal, the reputational damage and regulatory consequences under GDPR for data breaches involving personal data could be significant. Organizations in sectors with high web application usage, such as finance, e-commerce, healthcare, and government services, are particularly at risk. The medium severity rating indicates that while exploitation is feasible, the impact is somewhat limited compared to more severe vulnerabilities. However, the ease of exploitation (no authentication required) and the widespread use of Jinja in Python web frameworks increase the risk profile. Failure to patch could expose European users to targeted attacks, especially in environments where user interaction with web applications is frequent.

Mitigation Recommendations

The primary mitigation is to upgrade all affected Jinja instances to version 3.1.3 or later, where this vulnerability has been addressed. Organizations should audit their codebases and dependencies to identify usage of the `xmlattr` filter and review how input is passed to it. Avoid passing untrusted or user-supplied data directly to this filter without proper sanitization. Implement strict input validation and sanitization routines for any data rendered in templates, especially when using dynamic attribute generation. Employ Content Security Policy (CSP) headers to restrict the execution of unauthorized scripts and reduce the impact of potential XSS attacks. Additionally, security teams should conduct code reviews and penetration testing focused on template injection and XSS vectors. Monitoring web application logs for unusual or suspicious input patterns can help detect attempted exploitation. Finally, educate developers about secure template usage and the risks of improper input handling in templating engines.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.2
Assigner Short Name
GitHub_M
Date Reserved
2024-01-08T04:59:27.371Z
Cvss Version
3.1
State
PUBLISHED

Threat ID: 6909261ffe7723195e0b4691

Added to database: 11/3/2025, 10:01:03 PM

Last enriched: 11/3/2025, 11:53:54 PM

Last updated: 12/13/2025, 4:50:34 PM

Views: 5

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats