GHSA-xjw9-38cr-6372: djust Cross-Site Scripting Vulnerability
HIGHGHSA-xjw9-38cr-6372 is a HIGH cross-site scripting vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting djust libraries in the PyPI ecosystem. The issue involves a template binding inherits a context safety grant it never earned (xss). Remediation is available by upgrading affected packages to version 1.1.2.
GHSA-xjw9-38cr-6372 at a Glance
How to Fix GHSA-xjw9-38cr-6372
To remediate this vulnerability, upgrade all affected djust dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install djust>=1.1.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show djust
How to Check if You Are Affected
To determine whether your Python environment is affected by GHSA-xjw9-38cr-6372, inspect your installed packages using pip:
pip show djust
Analyze the terminal output to locate any version of djust in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.2), your application is affected.
Note: The pip show djust command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In djust, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-xjw9-38cr-6372 Affected djust Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
djust
|
PyPI |
< 1.1.2
|
1.1.2
|
References
Frequently Asked Questions
What is GHSA-xjw9-38cr-6372?
Which djust versions are affected?
What version fixes GHSA-xjw9-38cr-6372?
Is djust affected?
What CWE is associated with GHSA-xjw9-38cr-6372?
How can I check PyPI dependencies for GHSA-xjw9-38cr-6372?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xjw9-38cr-6372",
"modified" : "2026-09-17T20:31:48Z",
"published" : "2026-09-17T20:31:48Z",
"aliases" : [ ],
"summary" : "djust: A template binding inherits a context safety grant it never earned (XSS)",
"details" : "A context safety grant was inherited by a template **binding** that never earned it, so rebinding a name the view had marked safe left the mark attached to the new, attacker-controlled value.\n\ndjust's context safety channel is keyed by **name**, not by value. Every bind copied the value and left the grant in place:\n\n```\nview marks p = mark_safe('<b>trusted</b>')\ntemplate {% with p=user_input %}{{ p }}{% endwith %}\n\n djust '<img src=x onerror=alert(1)>' <- executes\n django '<img src=x onerror=alert(1)>'\n```\n\n## Affected binds\n\nEight distinct shapes were live. All are fixed in 1.1.2:\n\n| shape | example |\n|---|---|\n| `{% with %}` rebinding a marked name | `{% with p=hostile %}{{ p }}{% endwith %}` |\n| `{% with %}` **descendant** of a rebound name | `{% with p=hostile %}{{ p.a }}{% endwith %}` |\n| `{% with %}` binding over a marked name | `{% with q=hostile %}{{ q }}{% endwith %}` |\n| `{% for %}` loop variable | `{% for p in hostiles %}{{ p }}{% endfor %}` |\n| `{% for %}` descendant | `{% for p in hostiles %}{{ p.a }}{% endfor %}` |\n| `{% for %}` tuple unpacking | `{% for k, v in rows %}{{ v }}{% endfor %}` |\n| `{% include … with %}` | `{% include \"c.html\" with q=hostile %}` |\n| assign tags | `{% … as x %}` |\n\nNo filter chain and no `|safe` anywhere in the template is required. The precondition is that the application marked *some* value safe under a name that a template later rebinds — an ordinary pattern, since a view commonly marks trusted markup safe and templates commonly reuse short names such as `p`, `item` or `row`.\n\n## Impact\n\nStored or reflected XSS in any djust application that combines `mark_safe` (or any framework path that grants a context key safety) with a template that rebinds that name. Exploitation requires no unusual template construct.\n\n## Patches\n\nFixed in **1.1.2**, and in 1.2.0 (`main`).\n\nThe rule is that a bind **replaces** the grant rather than inheriting one. It is stated that way deliberately: the originally reported defects pointed the *opposite* direction — a grant being **lost** across some binds, causing over-escaping — and fixing only the reported direction would have left this leak in place. Both directions are the same rule.\n\n**Not fixed in 1.1.2**, and tracked for 1.2.0: two over-escaping cases where a grant fails to travel with a value that legitimately carries one (`{% with body=post.text|linebreaks %}`, and `mark_safe` reaching a template through `dict.values` / `dict.items`). Both escape *more* than Django rather than less, so neither is a leak.\n\n## Workarounds\n\nBefore upgrading, avoid reusing a context name for both `mark_safe`'d content and untrusted input, and avoid rebinding such a name in `{% with %}`, `{% for %}`, `{% include … with %}` or an assign tag.\n\n## Credit\n\nFound while preparing the 1.1.1 security release: the reproducer published in GHSA-9395-2g46-rj3f was run against the built 1.1.1 artifact before that advisory was published, and proved the class was still live. Publishing the original text would have reported this class as patched when it was not.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "djust"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.1.2"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.1.1"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/djust-org/djust/security/advisories/GHSA-xjw9-38cr-6372"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/djust-org/djust"
}, {
"type" : "WEB",
"url" : "https://github.com/djust-org/djust/releases/tag/v1.1.2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-116", "CWE-79" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-09-17T20:31:48Z",
"nvd_published_at" : null
}
}