Repository navigation
Security
MCWSLoader is usually deployed on a trusted machine or LAN. These layers keep the WebUI and the game bridge from being controlled by random network clients.
- Login is only
POST /api/loginwith{ "password": "..." }; passwords never appear in URLs or access logs - Passwords are hashed with scrypt and compared in constant time
- Failed attempts are counted per IP and locked out
- Sessions are random 32-byte tokens, sent as
X-Auth-Token -
POST /api/logoutdestroys the current session server-side - Changing the password invalidates all sessions
Output escaping, CSP and v-html usage are kept in mind: Mod README rendering
escapes text and only allows safe URL schemes.
The WebUI serves HTML with:
-
Content-Security-Policy(script-src 'self', no inline scripts) -
X-Frame-Options: DENYandframe-ancestors 'none' X-Content-Type-Options: nosniffReferrer-Policy: no-referrer-
Permissions-Policydisabling camera/microphone/geolocation -
Cache-Control: no-storefor API responses and HTML
Cross-origin API access is disabled by default. Add explicit origins in
web.ui.allowedOrigins if another origin must call the API.
Vanilla MCBE /connect host:port cannot send tokens, custom headers or query
parameters, so a real handshake authentication is impossible. MCWSLoader uses
practical substitutes:
-
Bind to loopback by default (
ws.host: "127.0.0.1") -
Browser Origin check — browser connections are rejected unless the origin
is listed in
web.ui.allowedOrigins; native game clients send no Origin -
IP / CIDR allowlist —
ws.connection.allowedIPs, e.g.["192.168.1.0/24"]. Connections outside the list are closed with 1008 -
Manual approval — with
ws.connection.requireApproval(defaulttrue), non-loopback clients start pending. Every incoming packet is dropped, SAPI polling is paused, and the client cannot become main until an authenticated admin clicks Approve on the WebUI Clients page. Loopback is auto-trusted - Transport limits — connection rate limit, max connections and an 8MB payload cap
The WebUI exposes:
-
GET /api/clients— includestrusted POST /api/clients/:id/approvePOST /api/clients/:id/revoke
- Mod archives are validated before extraction: absolute paths,
..entries (zip-slip) and excessive entry counts are rejected - Symlinks and extraction size/count limits are enforced after extraction
- Unpacked size is capped at 256MB and 5000 entries
-
manifest.jsonentrypaths must be relative and inside the Mod directory - npm dependencies are installed with
--ignore-scripts --no-package-lock, so a package postinstall script cannot run arbitrary code - Mods are still arbitrary Node.js code once loaded; only install trusted Mods
t:exec runs a server shell command and is disabled by default
(command.allowShellExec: false). Enable it only when the owner account is
fully trusted; it bypasses all other command sandboxing.
- Keep
ws.hostat127.0.0.1unless LAN clients are required - If the WebUI is exposed beyond localhost, use HTTPS (reverse proxy) or a VPN such as WireGuard/Tailscale; HTTP transmits the password and session token in clear text
- Never expose the WebSocket port 8080 to the public internet
- Keep
requireApprovalenabled and/or restrictallowedIPson shared LANs
MCWSLoader