feat: run commands from the page, gated by trusted origins - #22
Merged
Conversation
A page can run a Minecraft command that executes as the player (client-side, via the new "command" bridge channel) — as if typed in chat, no privilege escalation. Commands are only accepted from the main frame of an origin the server declares trusted via trustedCommandOrigins in server.json; requests from any other origin (redirect, iframe) are dropped. The list is sent on join and cleared on disconnect, so trust never carries across servers. - add WebGUITrustedOrigins (client-side origin registry, normalization) - add WebviewTrustedOriginsS2CPayload + send on join + receive on client - add trustedCommandOrigins to server.json - handle the "command" channel in WebviewPageToClientBridge with frame/origin checks - bump to 1.6.0
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.
What
A page rendered in the webview can now run a Minecraft command, executed as the player — exactly as if they typed it in chat. No privilege escalation.
Trust model
Commands are accepted only from the main frame of an origin the server declares trusted, via
trustedCommandOriginsinconfig/webgui/server.json:{ "trustedCommandOrigins": ["https://ui.myserver.example", "http://localhost:3000"] }<iframe>) are dropped.Changes
WebGUITrustedOrigins— client-side registry of trusted origins (normalization, session-scoped).WebviewTrustedOriginsS2CPayload— sent on join, received on client (all targets).trustedCommandOriginsinserver.json.commandchannel inWebviewPageToClientBridge: main-frame + origin check → run as player (sendChatCommand/connection.sendCommand).Pairs with the
@webgui/reactPR addingrunCommand/useRunCommand.Verification