GHSA-xjw9-38cr-6372: djust Cross-Site Scripting Vulnerability

HIGH
CWE-116 CWE-79
Published
Advisory Summary

GHSA-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

CVE Identifier N/A
GHSA Identifier GHSA-xjw9-38cr-6372
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product djust
Package Ecosystem PyPI
Published Date
Last Updated

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.

djust fixed: 1.1.2
pip install djust>=1.1.2
Verify Direct and Transitive Dependencies

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

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. djust's context safety channel is keyed by **name**, not by value. Every bind copied the value and left the grant in place: ``` view marks p = mark_safe('<b>trusted</b>') template {% with p=user_input %}{{ p }}{% endwith %} djust '<img src=x onerror=alert(1)>' <- executes django '&lt;img src=x onerror=alert(1)&gt;' ``` ## Affected binds Eight distinct shapes were live. All are fixed in 1.1.2: | shape | example | |---|---| | `{% with %}` rebinding a marked name | `{% with p=hostile %}{{ p }}{% endwith %}` | | `{% with %}` **descendant** of a rebound name | `{% with p=hostile %}{{ p.a }}{% endwith %}` | | `{% with %}` binding over a marked name | `{% with q=hostile %}{{ q }}{% endwith %}` | | `{% for %}` loop variable | `{% for p in hostiles %}{{ p }}{% endfor %}` | | `{% for %}` descendant | `{% for p in hostiles %}{{ p.a }}{% endfor %}` | | `{% for %}` tuple unpacking | `{% for k, v in rows %}{{ v }}{% endfor %}` | | `{% include … with %}` | `{% include "c.html" with q=hostile %}` | | assign tags | `{% … as x %}` | No 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`. ## Impact Stored 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. ## Patches Fixed in **1.1.2**, and in 1.2.0 (`main`). The 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. **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. ## Workarounds Before 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. ## Credit Found 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.

GHSA-xjw9-38cr-6372 Affected djust Versions

1 component(s)
Fixed Versions:
1.1.2
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?
GHSA-xjw9-38cr-6372 is a security vulnerability in djust involving A template binding inherits a context safety grant it never earned (XSS) under CWE-116: Improper Encoding or Escaping of Output.
Which djust versions are affected?
Affected versions include releases prior to 1.1.2 across affected packages: djust.
What version fixes GHSA-xjw9-38cr-6372?
Upgrading to 1.1.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is djust affected?
Yes, djust is affected in releases prior to 1.1.2. Upgrade your dependency to 1.1.2 or later.
What CWE is associated with GHSA-xjw9-38cr-6372?
GHSA-xjw9-38cr-6372 is classified under CWE-116: Improper Encoding or Escaping of Output (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.).
How can I check PyPI dependencies for GHSA-xjw9-38cr-6372?
Run the dependency tree command: 'pip show djust'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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  '&lt;img src=x onerror=alert(1)&gt;'\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
  }
}