Block supervisor/hassio WebSocket command types in the HA proxy - #7123
Open
mdegat01 wants to merge 1 commit into
Open
Block supervisor/hassio WebSocket command types in the HA proxy#7123mdegat01 wants to merge 1 commit into
mdegat01 wants to merge 1 commit into
Conversation
mdegat01
requested review from
agners and
balloob
and
a lite review from Copilot
August 12, 2026 04:26
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Supervisor’s /core/websocket proxy to prevent add-ons/apps (with only homeassistant_api: true) from using the proxy as a confused deputy to invoke privileged supervisor/* or hassio/* WebSocket commands against Home Assistant Core, which would then call back into the Supervisor with Core’s fully privileged token.
Changes:
- Add a denylist for WebSocket command
typeprefixes (supervisor/,hassio/) and a small helper to detect them from TEXT frames. - Reject denied app→Core WebSocket commands with a Core-shaped
result/unauthorizedresponse while keeping the connection open. - Add targeted tests covering the
supervisor/apiexploit path, all denied namespaces, continued connection usability, and pass-through of malformed/non-JSON frames.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
supervisor/api/proxy.py |
Adds command-type filtering in the WebSocket proxy to block supervisor/* and hassio/* messages from apps while preserving normal proxy behavior. |
tests/api/test_proxy.py |
Adds regression and behavior tests validating the block, ensuring the upstream Core server doesn’t receive denied commands, and confirming other traffic still proxies correctly. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
An app with only homeassistant_api: true could send supervisor/api (or other supervisor/* / hassio/* command type) frames through the Supervisor's Core WebSocket proxy at /core/websocket. Core executes those via the hassio integration's websocket_supervisor_api handler, which calls back into the Supervisor using Core's own token. That token bypasses all role checks in security.py, giving the app unrestricted Supervisor API access regardless of its declared hassio_role or hassio_api flag. Fix: filter command types on the app-to-Core direction of _proxy_message. Any TEXT frame whose type field starts with 'supervisor/' or 'hassio/' is rejected with a Core-shaped result/unauthorized response instead of being forwarded. The connection stays open. Fail-open on unparseable frames (Core's own validation already rejects those). The Core-to-app direction is unfiltered.
mdegat01
force-pushed
the
fix/ws-proxy-block-core-only-commands
branch
from
August 12, 2026 18:17
44ba945 to
5a2c3f6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
The Supervisor's Core WebSocket proxy (
/core/websocket) accepts connections from any app withhomeassistant_api: true. It authenticates the app with its own token but then opens the upstream connection to Core as the Supervisor itself._proxy_messagewas forwarding frames verbatim with no content inspection.An app could exploit this by sending a
supervisor/apicommand (or othersupervisor/*/hassio/*type) through the proxy. Core'shassiointegration handles those commands by calling back into the Supervisor with Core's own token. That token bypasses all role checks insecurity.py— it is treated as the most privileged caller regardless of the app's declaredhassio_apiorhassio_role.Fix: in
_proxy_message, TEXT frames on the app-to-Core direction whosetypefield starts with"supervisor/"or"hassio/"are now rejected with a Core-shapedresult/unauthorizedresponse instead of being forwarded. The connection stays open so the app can continue making normal HA calls (e.g.call_service,subscribe_events). The Core-to-app direction is unfiltered. Fail-open on unparseable frames — Core's own validation already rejects those.Tests cover: the exact
supervisor/apiattack vector, all denied command-type namespaces, continued usability of the connection after a rejection, and pass-through of non-JSON frames.Type of change
Additional information
Checklist
ruff format supervisor tests)