Junglewise Threat Intelligence

djust template XSS via inherited context safety grant

Severity: high · CVSS 6.1 · Published 2026-09-17

Executive brief

djust is a Django-compatible template engine. A security mark applied by developers to trusted content (using mark_safe) was incorrectly inherited when a template later reused the same variable name with untrusted user input. This allows attackers to inject malicious HTML or JavaScript that executes in users' browsers, affecting any application that combines safe-marked content with template variable rebinding.

Technical details

djust's context safety model is keyed by variable name rather than value. When a template rebinds a name previously marked safe (via mark_safe or similar) to a new, attacker-controlled value, the safety grant is incorrectly inherited by the new value and rendered unescaped. The vulnerability affects eight template constructs: `{% with %}` rebinding, `{% for %}` loops, `{% include … with %}`, and assign tags. No filter chain or explicit `|safe` filter is required; exploitation requires only that a view marks some value safe under a name that the template later rebinds to untrusted input—a common pattern. Fixed in version 1.1.2 by ensuring binds replace rather than inherit safety grants.

Affected products

  • djust djust before 1.1.2

Timeline

  • 2026-09-17: disclosed: GHSA-xjw9-38cr-6372 published
  • 2026-09-17: patched: Fixed in djust 1.1.2 and 1.2.0

Related threats