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-34064: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in pallets jinja

0
Medium
VulnerabilityCVE-2024-34064cvecve-2024-34064cwe-79
Published: Mon May 06 2024 (05/06/2024, 14:41:39 UTC)
Source: CVE Database V5
Vendor/Project: pallets
Product: jinja

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.

AI-Powered Analysis

AILast updated: 11/04/2025, 00:01:04 UTC

Technical Analysis

Jinja is a widely used extensible templating engine in Python web applications. The vulnerability CVE-2024-34064 affects the xmlattr filter in Jinja versions prior to 3.1.4. This filter is designed to convert a dictionary of key-value pairs into XML/HTML attributes. However, it improperly accepts keys containing characters such as spaces, '/', '>', or '=', which are not valid in XML/HTML attribute names. When an application accepts user input as keys (rather than just values) for this filter, an attacker can craft keys that inject additional attributes or malicious payloads, leading to cross-site scripting (XSS). This can result in the execution of arbitrary JavaScript in the context of other users viewing the affected page. The vulnerability was partially addressed in CVE-2024-22195 by blocking spaces in keys, but other dangerous characters remained exploitable. The Jinja project now explicitly considers accepting keys as user input an unintended and insecure use case. The vulnerability is fixed in Jinja 3.1.4, which properly restricts invalid characters in keys. Exploitation requires no privileges but does require user interaction (e.g., a victim visiting a maliciously crafted page). No known exploits are currently in the wild. The CVSS 3.1 score is 5.4 (medium), reflecting the moderate impact and ease of exploitation in specific scenarios.

Potential Impact

For European organizations, this vulnerability poses a risk primarily to web applications using Jinja templating versions earlier than 3.1.4 that accept user input as keys in the xmlattr filter. Successful exploitation can lead to cross-site scripting attacks, compromising the confidentiality and integrity of user sessions, potentially leading to session hijacking, credential theft, or unauthorized actions performed on behalf of users. This can damage organizational reputation, lead to regulatory non-compliance (e.g., GDPR breaches if personal data is exposed), and cause operational disruptions. The impact is heightened in sectors with sensitive data or critical services, such as finance, healthcare, and government. However, the vulnerability requires specific unsafe coding practices (accepting keys as user input), so the overall risk depends on application design. The absence of known exploits reduces immediate threat but patching is advised to prevent future attacks.

Mitigation Recommendations

1. Upgrade all Jinja installations to version 3.1.4 or later to ensure the vulnerability is patched. 2. Audit application code to identify any use of the xmlattr filter where user input is accepted as keys; refactor such code to avoid this practice entirely. 3. Implement strict input validation and sanitization on any user-supplied data that might be used in templating, especially keys for attribute generation. 4. Employ Content Security Policy (CSP) headers to reduce the impact of potential XSS by restricting script execution sources. 5. Conduct security code reviews and penetration testing focusing on template injection and XSS vectors. 6. Educate developers about the risks of accepting user input as keys in templating filters and encourage secure coding practices. 7. Monitor web application logs and user reports for signs of XSS exploitation attempts. 8. If immediate upgrade is not possible, consider temporary mitigations such as disabling features that accept user input as keys or applying custom filters to sanitize keys before rendering.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.2
Assigner Short Name
GitHub_M
Date Reserved
2024-04-30T06:56:33.380Z
Cvss Version
3.1
State
PUBLISHED

Threat ID: 69092624fe7723195e0b47a1

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

Last enriched: 11/4/2025, 12:01:04 AM

Last updated: 11/5/2025, 1:51:37 PM

Views: 1

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