GHSA-w7rv-gfp4-j9j3

Suggest an improvement
Source
https://github.com/advisories/GHSA-w7rv-gfp4-j9j3
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-w7rv-gfp4-j9j3/GHSA-w7rv-gfp4-j9j3.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-w7rv-gfp4-j9j3
Aliases
Published
2026-03-30T17:20:04Z
Modified
2026-03-31T19:01:32.748038Z
Severity
  • 6.1 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N CVSS Calculator
Summary
Slippers Vulnerable to Cross-Site Scripting (XSS) in `attrs` Template Tag
Details

Summary

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.

Database specific
{
    "github_reviewed": true,
    "github_reviewed_at": "2026-03-30T17:20:04Z",
    "severity": "MODERATE",
    "nvd_published_at": "2026-03-31T16:16:32Z",
    "cwe_ids": [
        "CWE-79"
    ]
}
References

Affected packages

PyPI / slippers

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
0.6.3

Affected versions

0.*
0.1.0
0.1.1
0.1.2
0.1.3
0.1.4
0.2.0
0.3.0
0.3.1
0.3.2
0.4.0
0.5.0a0
0.5.0
0.6.0a0
0.6.0
0.6.1a0
0.6.1
0.6.2

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-w7rv-gfp4-j9j3/GHSA-w7rv-gfp4-j9j3.json"
last_known_affected_version_range
"<= 0.6.2"