Summary
A tenant-isolation flaw in djust affects live WebSocket and SSE requests, where tenant context was not reliably established and tenant-aware queries could return unfiltered data. A user holding a live connection may therefore view database rows belonging to other tenants when the affected live paths are used.
Affected context
The issue occurs in djust deployments using the djust.tenants isolation feature with LiveView-style WebSocket or SSE interactions. HTTP middleware established tenant context, but the live path did not consistently bind that context during mounts and event handling; thread-local storage could also be shared incorrectly across asynchronous executor work.
Exploit preconditions
- Attack surface: Live WebSocket or SSE endpoints that perform tenant-aware database queries
- Required access: A valid user or otherwise authorized party able to establish a live connection
- Trigger point: Component mount or event-handler dispatch on the live path
- Why exploitation is possible: Tenant context may be absent or incorrectly shared, causing the tenant-aware manager to return an unfiltered queryset instead of denying access
Why this happens
The underlying flaw is a missing authorization check caused by incomplete propagation of tenant context across request-processing paths. Tenant state was stored in threading.local() and initialized only by HTTP middleware, so asynchronous WebSocket and SSE handlers could evaluate queries without a resolved tenant. When the tenant was unavailable, the query layer failed open rather than restricting results, mapping primarily to CWE-862 (Missing Authorization) and also relating to CWE-636 (Not Properly Implemented Access Control).
Potential impact
- An authenticated user may view records belonging to other tenants
- Sensitive tenant data could be disclosed through live component updates
- Cross-tenant information could be exposed repeatedly through event handlers
- An attacker could use disclosed data to support further account or application compromise
General mitigation guidance
Mitigation generally focuses on treating tenant context as an authorization
boundary across every transport and execution model.
Common defensive patterns include:
- Binding tenant context per asynchronous task, connection, or request lifecycle
- Establishing and validating tenant identity before live mounts and every event dispatch
- Scoping the base queryset once using a trusted, resolved tenant
- Failing closed with an empty result or explicit authorization denial when tenant context is missing
- Avoiding mutable thread-global state for asynchronous request isolation
- Keeping strict isolation enabled by default and applying least privilege to database identities
- Adding automated checks that detect configurations which disable fail-closed behavior
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis identifying thread-local tenant state in asynchronous code
- Code review checks confirming tenant binding on HTTP, WebSocket, and SSE paths
- Tests that exercise missing, stale, and cross-connection tenant contexts
- Integration tests verifying that live handlers cannot return rows from another tenant
- Policy enforcement requiring fail-closed behavior for absent authorization context
- Automated review tools that flag unscoped querysets and authorization decisions based on nullable context

