GHSA-xx4j-w367-7247: High severity pip/djust vulnerability
Impact
djust's LiveViewConsumer mounts a LiveView over a WebSocket. When a view is gated (loginrequired / permissionrequired, or an onmount hook that returns a redirect) and the connecting user is not authorized, the consumer sent the client a {"type":"navigate","to":...} redirect frame and then returned — without closing the socket and without clearing self.viewinstance. Only the PermissionDenied branch closed the connection (close(4403)).
A real browser obeys the navigate frame and leaves, hiding the problem. A raw WebSocket client that ignores the redirect keeps an open, mounted socket. Because handleevent did not re-check authentication/authorization after mount, that client could then send {"type":"event", ...} frames and invoke any @eventhandler method on the gated view with no authenticated session — an authentication bypass on the live mutation path.
Who is affected: apps that expose LiveViews gated by loginrequired / permissionrequired / a redirecting onmount hook, where the gated view's event handlers perform sensitive reads or mutations and do not independently re-verify the user. Exploitation requires a non-browser WebSocket client and knowledge (or enumeration) of the view path and event names.
Patches
Fixed in djust 1.0.4 (commit 1ae8aa9, PR #1780). Both the auth-redirect and onmount-hook-redirect branches of handlemount now send the navigate frame and then close(code=4403) and clear self.viewinstance, mirroring the existing PermissionDenied branch. Public / authorized mounts are unchanged. The same path is reachable via handleliveredirectmount (which delegates to handlemount) and is covered by the same fix.
1.0.4 also adds an opt-in defense-in-depth control, LIVEVIEWCONFIG['reauthonevent'] = True (default OFF), which re-resolves the user from the session and re-runs the view's auth check on every event for gated views.
Workarounds
Upgrade to 1.0.4. If you cannot upgrade immediately, on affected versions ensure that every @eventhandler on a gated LiveView independently verifies the request user is authenticated and authorized (e.g. check request.user.isauthenticated / permissions at the top of each handler), since the framework does not re-check after mount on < 1.0.4. Alternatively, override the consumer's handlemount to await self.close(code=4403) after emitting an auth redirect.
Proof of concept
Using Channels' WebsocketCommunicator against LiveViewConsumer.asasgi() with an anonymous scope, mount a loginrequired view: the server emits a navigate frame but the socket stays open. Sending a subsequent {"type":"event", "handler":"<mutatinghandler>", ...} frame reaches the handler and executes it without an authenticated session. On 1.0.4 the socket is closed with code 4403 immediately after the redirect and the event frame is rejected. (Regression test: tests/testwsauthclosesocket.py.)
Credits
Discovered internally during the djust v1.1.0 WebSocket-auth security review.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/djustto a version that resolves this vulnerability.Fixed in 1.0.4 - Upgrade
Upgrade
djustto a version that resolves this vulnerability.Fixed in 1.0.4Patch 1ae8aa9 - Configuration
Enable defense-in-depth by setting LIVEVIEW_CONFIG['reauth_on_event'] = True (default OFF) so the user is re-resolved from the session and the view's auth check is re-run on every event for gated views.
djust LiveViewConsumer LIVEVIEW_CONFIG['reauth_on_event'] = True - Configuration
For versions < 1.0.4, ensure every @event_handler on a gated LiveView independently verifies the request user is authenticated and authorized at the top of the handler (e.g., check request.user.is_authenticated and required permissions), since the framework does not re-check after mount on < 1.0.4.
djust LiveView (gated LiveView event handlers) @event_handler authentication/authorization checks = independent re-verification - Compensating control
If you cannot upgrade, override the consumer's handle_mount to await self.close(code=4403) after emitting an auth redirect, to close the socket for unauthorized gated mounts (per the described workaround).
- Operational
After applying the 1.0.4 fix, regression-test that tests/test_ws_auth_close_socket.py passes (ensures the socket is closed with code 4403 after redirect and the event frame is rejected).
Event History
Frequently Asked Questions
Which applications are exposed to meaningful impact?
Applications are affected when they expose LiveViews gated by login_required, permission_required, or an on_mount hook that redirects unauthorized users. Impact is greatest where those views have event handlers that perform sensitive reads or mutations without independently verifying the user.
What does an attacker need to exploit the issue?
An attacker needs to connect using a raw WebSocket client that ignores the navigation redirect sent to an unauthorized client. They can then send event frames to invoke event-handler methods on the still-mounted gated view without an authenticated session.
Does a normal browser prevent exploitation?
A normal browser follows the navigation frame and leaves the view, which hides the issue in ordinary browser behavior. The vulnerable condition remains exploitable by a client that keeps the WebSocket open after receiving that redirect.