djust: A template binding inherits a context safety grant it never earned (XSS)
djust versions prior to 1.1.2 contain a vulnerability where a template binding inherits a context safety grant it never earned, leading to stored or reflected cross-site scripting (XSS). This occurs when a view marks a value safe (e.g., using mark_safe) and a template later rebinds that name to attacker-controlled input, causing the safety mark to be incorrectly retained. The issue affects multiple template binding constructs such as {% with %}, {% for %}, {% include … with %}, and assign tags. The vulnerability is fixed in version 1.1.2 and later.
AI Analysis
Technical Summary
The vulnerability in djust arises because the context safety channel is keyed by variable name rather than by value. When a template rebinding occurs (e.g., {% with p=user_input %}), the safety grant associated with the original safe value is incorrectly inherited by the new, potentially unsafe value. This leads to XSS when the template outputs attacker-controlled input marked as safe. Eight distinct binding shapes are affected, including rebinding in {% with %}, loop variables in {% for %}, tuple unpacking, and includes with context overrides. The fix in 1.1.2 changes the behavior so that a bind replaces the safety grant rather than inheriting it, preventing unsafe values from being treated as safe. Some over-escaping issues remain and are tracked for 1.2.0 but do not cause leaks.
Potential Impact
This vulnerability allows stored or reflected XSS in any djust application that uses mark_safe (or equivalent safety grants) combined with templates that rebind those safe names to attacker-controlled input. Exploitation requires no unusual template constructs and can lead to execution of arbitrary JavaScript in the context of the vulnerable application, potentially compromising user sessions or data.
Mitigation Recommendations
A fix is available in djust version 1.1.2 and later. Users should upgrade to at least version 1.1.2 to remediate this vulnerability. Until upgrading, avoid reusing context variable names for both mark_safe'd content and untrusted input, and avoid rebinding such names in template constructs like {% with %}, {% for %}, {% include … with %}, or assign tags.
djust: A template binding inherits a context safety grant it never earned (XSS)
Description
djust versions prior to 1.1.2 contain a vulnerability where a template binding inherits a context safety grant it never earned, leading to stored or reflected cross-site scripting (XSS). This occurs when a view marks a value safe (e.g., using mark_safe) and a template later rebinds that name to attacker-controlled input, causing the safety mark to be incorrectly retained. The issue affects multiple template binding constructs such as {% with %}, {% for %}, {% include … with %}, and assign tags. The vulnerability is fixed in version 1.1.2 and later.
CVSS v4.0
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability in djust arises because the context safety channel is keyed by variable name rather than by value. When a template rebinding occurs (e.g., {% with p=user_input %}), the safety grant associated with the original safe value is incorrectly inherited by the new, potentially unsafe value. This leads to XSS when the template outputs attacker-controlled input marked as safe. Eight distinct binding shapes are affected, including rebinding in {% with %}, loop variables in {% for %}, tuple unpacking, and includes with context overrides. The fix in 1.1.2 changes the behavior so that a bind replaces the safety grant rather than inheriting it, preventing unsafe values from being treated as safe. Some over-escaping issues remain and are tracked for 1.2.0 but do not cause leaks.
Potential Impact
This vulnerability allows stored or reflected XSS in any djust application that uses mark_safe (or equivalent safety grants) combined with templates that rebind those safe names to attacker-controlled input. Exploitation requires no unusual template constructs and can lead to execution of arbitrary JavaScript in the context of the vulnerable application, potentially compromising user sessions or data.
Mitigation Recommendations
A fix is available in djust version 1.1.2 and later. Users should upgrade to at least version 1.1.2 to remediate this vulnerability. Until upgrading, avoid reusing context variable names for both mark_safe'd content and untrusted input, and avoid rebinding such names in template constructs like {% with %}, {% for %}, {% include … with %}, or assign tags.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-xjw9-38cr-6372
- Osv Schema Version
- 1.4.0
- Ecosystems
- ["PyPI"]
- Database Specific Severity
- HIGH
- Cvss Version
- 4.0
Threat ID: 6aac8dee55bf5e2cf54900ee
Added to database: 09/18/2026, 01:03:42 UTC
Last enriched: 09/18/2026, 01:27:01 UTC
Last updated: 09/18/2026, 01:27:01 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.