Skip to content
Heist/ feed
Back to feed
Medium

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

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2024-34064
Confirmed fixed CVEs
Not specified
Updated in this feed
6 Nov 2026, 04:12 UTC · Revision 1

Source evidence

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

core-osv · Original source

Published 6 May 2024, 14:41 UTC

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.

osv:CVE-2024-34064
Complete source record
{
  "id": "2d6ed9214a72deb465f0e1baa22260e2c4be775a85d8a6f650396f0e1ce056b8",
  "url": "https://osv.dev/vulnerability/CVE-2024-34064",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter",
    "summary": "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.",
    "evidence": "osv:CVE-2024-34064",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2024-34064",
      "aliases": [
        "CVE-2024-34064",
        "GHSA-h75v-3vvj-5mfj",
        "PYSEC-2026-1474"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/pallets/jinja",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "dd4a8b5466d8790540c181590b14db4d4d889d57"
                },
                {
                  "fixed": "0668239dc6b44ef38e7a6c9f91f312fd4ca581cb"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:palletsprojects:jinja:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "3.1.4"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "0668239dc6b44ef38e7a6c9f91f312fd4ca581cb"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "3.1.2",
            "3.1.1",
            "3.1.0",
            "3.0.0",
            "3.0.0rc2",
            "3.0.0rc1",
            "3.0.0a1",
            "2.11.0",
            "2.10",
            "2.9",
            "2.8",
            "2.7",
            "2.6",
            "2.5.3",
            "2.5.1",
            "2.5",
            "2.4.1",
            "2.4",
            "2.3",
            "2.2.1",
            "2.2",
            "2.1.1",
            "2.1",
            "2.0",
            "2.0rc1"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-34064.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:46.380043017Z",
      "provider": "osv",
      "references": [
        "https://lists.debian.org/debian-lts-announce/2024/12/msg00009.html",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/567XIGSZMABG6TSMYWD7MIYNJSUQQRUC/",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/GCLF44KY43BSVMTE6S53B4V5WP3FRRSE/",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SSCBHIL6BYKR5NRCBXP4XMP2CEEKGFVS/",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZALNWE3TXPPHVPSI3AZ5CTMSTAVN5UMS/",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/34xxx/CVE-2024-34064.json",
        "https://github.com/pallets/jinja/security/advisories/GHSA-h75v-3vvj-5mfj",
        "https://nvd.nist.gov/vuln/detail/CVE-2024-34064",
        "https://github.com/pallets/jinja/commit/0668239dc6b44ef38e7a6c9f91f312fd4ca581cb"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-79"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/34xxx/CVE-2024-34064.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2024-34064",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 514583,
  "published_at": "2024-05-06T14:41:39.912+00:00"
}