CVE-2024-34064: Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter

Published May 6, 2024
·
Updated

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.

Other sources

Jinja is vulnerable to cross-site scripting, caused by the acceptance of keys containing non-attribute characters by the xmlattr filter. A remote attacker could exploit this vulnerability to inject other attributes into a Web page which would be executed in a victims Web browser within the security context of the hosting Web site, once the page is viewed. An attacker could use this vulnerability to steal the victim's cookie-based authentication credentials.

IBM

Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter

Microsoft

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 the previous GHSA-h5c8-rqwp-cp95 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.

GitHub

Affected Software

25 affected componentsFixes available
ubuntu/jinja2<2.10-1ubuntu0.18.04.1+
2.10-1ubuntu0.18.04.1+
ubuntu/jinja2<2.10.1-2ubuntu0.3
2.10.1-2ubuntu0.3
ubuntu/jinja2<3.0.3-1ubuntu0.2
3.0.3-1ubuntu0.2
ubuntu/jinja2<3.1.2-1ubuntu0.23.10.2
3.1.2-1ubuntu0.23.10.2
ubuntu/jinja2<3.1.2-1ubuntu1.1
3.1.2-1ubuntu1.1
ubuntu/jinja2<2.7.2-2ubuntu0.1~
2.7.2-2ubuntu0.1~
ubuntu/jinja2<3.1.4
3.1.4
ubuntu/jinja2<2.8-1ubuntu0.1+
2.8-1ubuntu0.1+
pip/Jinja2<3.1.4
3.1.4
debian/jinja2<=2.11.3-1, <=3.1.2-1, <=3.1.3-1
IBM Concert Software<=1.0.0, 1.0.1, 1.0.2, 1.0.2.1, 1.0.3
F5 Traffix SDC=5.1.0
5.2.0
redhat/jinja2<3.1.4
3.1.4
palletsprojects Jinja<3.1.4
Fedoraproject Fedora=39
Fedoraproject Fedora=40
Microsoft cbl2 python-jinja2 3.0.3-7
Microsoft cbl2 nodejs18 18.20.3-5
Microsoft cbl2 nodejs18 18.20.3-5
Microsoft azl3 nodejs 20.14.0-8
Microsoft cbl2 python-jinja2 3.0.3-4
Microsoft azl3 nodejs 20.14.0-1
Microsoft azl3 python-jinja2 3.1.2-2
Microsoft azl3 python-jinja2 3.1.2-3
Microsoft cbl2 nodejs18 18.20.3-4

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade ubuntu/jinja2 to a version that resolves this vulnerability.

    Fixed in 2.10-1ubuntu0.18.04.1+
  2. Upgrade

    Upgrade ubuntu/jinja2 to a version that resolves this vulnerability.

    Fixed in 2.10.1-2ubuntu0.3
  3. Upgrade

    Upgrade ubuntu/jinja2 to a version that resolves this vulnerability.

    Fixed in 3.0.3-1ubuntu0.2
  4. Upgrade

    Upgrade ubuntu/jinja2 to a version that resolves this vulnerability.

    Fixed in 3.1.2-1ubuntu0.23.10.2
  5. Upgrade

    Upgrade ubuntu/jinja2 to a version that resolves this vulnerability.

    Fixed in 3.1.2-1ubuntu1.1
  6. Upgrade

    Upgrade ubuntu/jinja2 to a version that resolves this vulnerability.

    Fixed in 2.7.2-2ubuntu0.1~
  7. Upgrade

    Upgrade ubuntu/jinja2 to a version that resolves this vulnerability.

    Fixed in 3.1.4
  8. Upgrade

    Upgrade ubuntu/jinja2 to a version that resolves this vulnerability.

    Fixed in 2.8-1ubuntu0.1+
  9. Upgrade

    Upgrade pip/Jinja2 to a version that resolves this vulnerability.

    Fixed in 3.1.4
  10. Upgrade

    Upgrade F5 Traffix Systems Signaling Delivery Controller to a version that resolves this vulnerability.

    Fixed in 5.2.0
  11. Upgrade

    Upgrade redhat/jinja2 to a version that resolves this vulnerability.

    Fixed in 3.1.4
  12. Upgrade

    Upgrade jinja to a version that resolves this vulnerability.

    Fixed in 3.1.4Patch GHSA-h75v-3vvj-5mfj
  13. Configuration

    Do not pass user input as the *keys* parameter to the Jinja `xmlattr` filter. Accepting keys as user input is explicitly considered an unintended use case and code that does so without otherwise validating the input should be flagged as insecure (regardless of Jinja version).}}]}]} }]}

    Jinja (xmlattr filter) input_type_for_xmlattr_keys = disallow_keys_as_user_input

Event History

May 6, 2024
CVE Published
via Ubuntu·12:00 AM
Advisory Published
via GitHub·02:20 PM
CVE Published
via MITRE·02:41 PM
Data Sourced
via MITRE·02:41 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·03:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·03:15 PM
RemedyAffected Software
May 7, 2024
Data Sourced
via Red Hat·06:30 AM
DescriptionSeverityAffected Software
May 13, 2024
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity
Updated
via Microsoft·07:00 AM
Description
Jun 29, 2024
Data Sourced
via Launchpad·05:52 PM
Description
Sep 20, 2024
Advisory Published
via F5·10:01 PM

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-34064?

CVE-2024-34064 has been assigned a vulnerability severity that indicates potential risks related to the xmlattr filter in Jinja.

2

How do I fix CVE-2024-34064?

To fix CVE-2024-34064, upgrade to the patched versions of Jinja listed in the affected software section.

3

Which versions of Jinja are affected by CVE-2024-34064?

Versions of Jinja prior to 2.11.4 and 3.1.4 are affected by CVE-2024-34064.

4

What does CVE-2024-34064 weaken in Jinja?

CVE-2024-34064 weakens the security by allowing keys with non-attribute characters in XML/HTML attributes.

5

Is my deployment vulnerable to CVE-2024-34064?

If you are using affected versions of Jinja, your deployment is vulnerable to CVE-2024-34064 and should be updated immediately.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203