From 64b210fb016d1d9fcdde3bc9109f738ddc8fafe1 Mon Sep 17 00:00:00 2001 From: web3dev1337 <160291380+web3dev1337@users.noreply.github.com> Date: Tue, 3 Mar 2026 07:47:28 +1100 Subject: [PATCH 1/9] audit: add client systems audit (network, input, UI, entities, audio, particles, etc.) --- AUDIT_CLIENT_SYSTEMS.md | 444 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 444 insertions(+) create mode 100644 AUDIT_CLIENT_SYSTEMS.md diff --git a/AUDIT_CLIENT_SYSTEMS.md b/AUDIT_CLIENT_SYSTEMS.md new file mode 100644 index 00000000..ab9a951b --- /dev/null +++ b/AUDIT_CLIENT_SYSTEMS.md @@ -0,0 +1,444 @@ +# Client Systems Audit: Network, Input, UI, Entities, Audio, Particles, and More + +Auditor: client-systems-auditor +Date: 2026-03-03 +Scope: `client/src/network/`, `client/src/input/`, `client/src/mobile/`, `client/src/ui/`, `client/src/entities/`, `client/src/audio/`, `client/src/particles/`, `client/src/players/`, `client/src/settings/`, `client/src/bridge/`, `client/src/arrows/`, `client/src/services/hytopia/`, `client/src/textures/` + +--- + +## Findings + +### [BUG] BridgeManager postMessage uses wildcard origin -- security risk +**Benefit: 5/5 | Risk: 2/5 | Effort: 1/5 | Surgical: yes | Backwards Compatible: yes** + +File: `client/src/bridge/BridgeManager.ts:220` + +`_sendParentMessage` calls `window.parent.postMessage(message, '*')` with a wildcard `'*'` target origin. This means any parent page (including a malicious one that iframes the client) can receive all bridge messages: chat messages, player data, reconnect URLs, notification permission requests, and key-down events. + +Additionally, `_onParentMessage` at line 152 processes all incoming `message` events without checking `event.origin`. A malicious parent frame could inject: +- `SEND_CHAT_MESSAGE` to send arbitrary chat messages as the player +- `SET_QUALITY_PRESET` to force POWER_SAVING mode (griefing) +- `LOCK_POINTER` / `UNLOCK_POINTER` to disrupt gameplay +- `TOGGLE_DEBUG` to expose debug info + +**Fix:** Replace `'*'` with the known parent origin (e.g. `https://play.hytopia.com` or pass it via config). In `_onParentMessage`, validate `event.origin` against an allowlist before processing. + +--- + +### [BUG] UIManager innerHTML injection allows XSS from server-controlled HTML +**Benefit: 5/5 | Risk: 3/5 | Effort: 2/5 | Surgical: yes | Backwards Compatible: yes** + +File: `client/src/ui/UIManager.ts:164` + +`_onUIPacket` fetches HTML from `deserializedUI.htmlUri` and sets `this._uiDiv.innerHTML = html` directly. It then executes all `