CVE-2026-125112: djust: A template binding inherits a context safety grant it never earned (XSS)
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: Affected binds Eight distinct shapes were live.
Published Sep 17, 2026 · Updated Nov 9, 2026
Affected packages
djust
- Ecosystem
- PyPI
- Affected
- < 1.0.10
- Fixed in
- 1.0.10
- Check
pip show djust
djust
- Ecosystem
- PyPI
- Affected
- >= 1.1.0, < 1.1.2
- Fixed in
- 1.1.2
- Check
pip show djust
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
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('trusted')
template {% with p=user_input %}{{ p }}{% endwith %}
djust '' <- executes
django '<img src=x onerror=alert(1)>'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.
Credited to Michael-WhiteCapData.
References
- https://github.com/djust-org/djust/security/advisories/GHSA-xjw9-38cr-6372
- https://github.com/djust-org/djust/releases/tag/v1.1.2
- https://github.com/djust-org/djust/pull/2444
- https://github.com/djust-org/djust/commit/06d213dbdd82f5b1c2affe2f869ae88a71809e4a
- https://github.com/djust-org/djust/commit/5288e5dbc8d83d8aee8a22a0a7a3a478461c8965
- https://github.com/djust-org/djust/releases/tag/v1.0.10
- https://github.com/advisories/GHSA-xjw9-38cr-6372
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-113731
djust: Arbitrary absolute-path file read in the find_handlers_for_template MCP tool
low3.3Oct 21, 2026GHSA-9395-2g46-rj3f
djust: Six template-layer defects emit attacker-controlled markup unescaped (XSS)
highSep 17, 2026CVE-2026-61588
djust's Django model serialization has no sensitive-field denylist: password hashes, privilege flags, and PII on a public view attribute are sent to the client
medium6.5Sep 16, 2026CVE-2026-61589
djust: WebSocket/runtime reconstructed request omits the client Host, causing host/subdomain TenantResolvers to misresolve the tenant on the live path
medium6.3Sep 16, 2026CVE-2026-61590
djust's observability endpoints are network-exposed: the localhost gate is an opt-in middleware the docs omit, and the views enforce only DEBUG
high7.4Sep 16, 2026CVE-2026-61591
djust: Unsigned client state snapshot is restored as trusted view state (privilege escalation / state injection)
high8.1Sep 16, 2026
