{"id":"CVE-2026-34231","aliases":["GHSA-w7rv-gfp4-j9j3","PYSEC-2026-2279"],"title":"Slippers Vulnerable to Cross-Site Scripting (XSS) in `attrs` Template Tag","summary":"Slippers Vulnerable to Cross-Site Scripting (XSS) in `attrs` Template Tag","severity":"medium","cvss":6.1,"cvssVector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","vendor":"slippers","product":"slippers","ecosystem":"pip","affected":["slippers < 0.6.3"],"patched":["slippers 0.6.3"],"published":"2026-03-30","updated":"2026-07-13","source":"OSV","sourceUrl":"https://osv.dev/vulnerability/GHSA-w7rv-gfp4-j9j3","references":[{"url":"https://github.com/mixxorz/slippers/security/advisories/GHSA-w7rv-gfp4-j9j3"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34231"},{"url":"https://github.com/mixxorz/slippers/commit/16cc4ef4fa8ad2f7aee30798f16c3e7b653423b2"},{"url":"https://github.com/mixxorz/slippers"},{"url":"https://github.com/mixxorz/slippers/releases/tag/0.6.3"}],"tags":["osv","pip"],"epss":0.00227,"epssPercentile":0.13628,"ingestedAt":"2026-07-13T18:58:04.234Z","slug":"CVE-2026-34231","body":"## Overview\n\n## Summary\n\nA Cross-site Scripting (XSS) vulnerability exists in the `{% attrs %}` template tag of the `slippers` Django package. When a context variable containing untrusted data is passed to `{% attrs %}`, the value is interpolated into an HTML attribute string without escaping, allowing an attacker to break out of the attribute context and inject arbitrary HTML or JavaScript into the rendered page.\n\n## Vulnerability details\n\n### Root cause\n\n`AttrsNode` is a custom `Node` subclass registered via `register.tag()`. Unlike `register.simple_tag()`, which automatically applies `conditional_escape()` when autoescape is on, custom `Node.render()` methods receive no automatic escaping and are fully responsible for sanitising their output. `attr_string()` fails to do this:\n\n```python\ndef attr_string(key: str, value: Any):\n    if isinstance(value, bool):\n        return key if value else \"\"\n    key = key.replace(\"_\", \"-\")\n    return f'{key}=\"{value}\"'   # value is not escaped\n```\n\n### Attack scenario\n\nGiven a template that uses `{% attrs %}` with a user-supplied value:\n\n```django\n{% load slippers %}\n<input {% attrs type placeholder %}>\n```\n\n```python\nrender(request, \"search.html\", {\"placeholder\": request.GET.get(\"q\", \"\")})\n```\n\nAn attacker crafting a request with `q=\" onmouseover=\"alert(document.cookie)\" x=\"` produces:\n\n```html\n<input type=\"text\" placeholder=\"\" onmouseover=\"alert(document.cookie)\" x=\"\">\n```\n\n## Impact\n\nAny template that passes values derived from user input, database content, or other untrusted sources to `{% attrs %}` is vulnerable. Successful exploitation can lead to session hijacking, credential theft, arbitrary actions on behalf of the victim, and page defacement.\n\n## Remediation\n\nReplace the f-string in `attr_string()` with `format_html()`, which escapes both key and value:\n\n```python\nfrom django.utils.html import format_html\n\ndef attr_string(key: str, value: Any):\n    if isinstance(value, bool):\n        return key if value else \"\"\n    key = key.replace(\"_\", \"-\")\n    return format_html('{}=\"{}\"', key, value)\n```\n\nUntil a patch is available, sanitise untrusted values before passing them to `{% attrs %}`, for example with `django.utils.html.escape()` in the view layer.\n\n## Affected packages\n\n- `slippers < 0.6.3`\n\n## Remediation\n\nUpgrade to a patched release:\n\n- `slippers 0.6.3`","depth":"sunlit","depthScore":34,"depthScoreParts":{"impact":33.6,"likelihood":0,"exploitation":0,"ransomware":0},"changes":[]}