GHSA-W7RV-GFP4-J9J3
Vulnerability from github – Published: 2026-03-30 17:20 – Updated: 2026-03-31 18:55Summary
A 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.
Vulnerability details
Root cause
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:
def attr_string(key: str, value: Any):
if isinstance(value, bool):
return key if value else ""
key = key.replace("_", "-")
return f'{key}="{value}"' # value is not escaped
Attack scenario
Given a template that uses {% attrs %} with a user-supplied value:
{% load slippers %}
<input {% attrs type placeholder %}>
render(request, "search.html", {"placeholder": request.GET.get("q", "")})
An attacker crafting a request with q=" onmouseover="alert(document.cookie)" x=" produces:
<input type="text" placeholder="" onmouseover="alert(document.cookie)" x="">
Impact
Any 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.
Remediation
Replace the f-string in attr_string() with format_html(), which escapes both key and value:
from django.utils.html import format_html
def attr_string(key: str, value: Any):
if isinstance(value, bool):
return key if value else ""
key = key.replace("_", "-")
return format_html('{}="{}"', key, value)
Until a patch is available, sanitise untrusted values before passing them to {% attrs %}, for example with django.utils.html.escape() in the view layer.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.6.2"
},
"package": {
"ecosystem": "PyPI",
"name": "slippers"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.6.3"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-34231"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": true,
"github_reviewed_at": "2026-03-30T17:20:04Z",
"nvd_published_at": "2026-03-31T16:16:32Z",
"severity": "MODERATE"
},
"details": "## 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\u0027{key}=\"{value}\"\u0027 # 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\u003cinput {% attrs type placeholder %}\u003e\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\u003cinput type=\"text\" placeholder=\"\" onmouseover=\"alert(document.cookie)\" x=\"\"\u003e\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(\u0027{}=\"{}\"\u0027, 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.",
"id": "GHSA-w7rv-gfp4-j9j3",
"modified": "2026-03-31T18:55:30Z",
"published": "2026-03-30T17:20:04Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/mixxorz/slippers/security/advisories/GHSA-w7rv-gfp4-j9j3"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-34231"
},
{
"type": "WEB",
"url": "https://github.com/mixxorz/slippers/commit/16cc4ef4fa8ad2f7aee30798f16c3e7b653423b2"
},
{
"type": "PACKAGE",
"url": "https://github.com/mixxorz/slippers"
},
{
"type": "WEB",
"url": "https://github.com/mixxorz/slippers/releases/tag/0.6.3"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
}
],
"summary": "Slippers Vulnerable to Cross-Site Scripting (XSS) in `attrs` Template Tag"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.