Repository navigation
Only let projects call allowlisted Rotur methods - #98
Merged
Merged
Conversation
The community project page, the editor and packaged exports passed any dotted method path from a project to the Rotur SDK, so a custom extension next to the project could call _http.getToken and read the viewer's token, or call me.transfer without a confirmation. Hosts now dispatch only the methods the built-in Rotur blocks use, check the project's grant for each call, and build confirmations, grant keys and storage ids themselves.
Deploying scratch-gui with
|
| Latest commit: |
819114a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9a6f2f09.scratch-gui.pages.dev |
| Branch Preview URL: | https://rotur-bridge-allowlist.scratch-gui.pages.dev |
mc20000-01
pushed a commit
to mc20000-01/scratch-gui
that referenced
this pull request
Nov 7, 2026
Only let projects call allowlisted Rotur methods
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.
The Rotur bridge on the community project page ran any method path a project sent it, on the viewer's own Rotur client. A custom extension running in the player could read the viewer's Rotur token, or send their credits without a confirmation. This replaces the open dispatch with an allowlist in the project page, the editor and packaged exports.
How custom extension code reaches the bridge
The project page embeds the player at
/embed.htmlin an iframe sandboxed withoutallow-same-origin. It listens for{type: 'mw:rotur', kind: 'call', method, args, opts}messages whosesourceis that iframe's window, and passedmethodtocallRotur.callRotursplit the method on dots and walked the Rotur SDK client.Any extension that runs unsandboxed inside the player runs in that window, so it can post the message. These extensions run unsandboxed in the player:
Extensions in TurboWarp's own iframe sandbox are a nested frame, so they fail the
sourcecheck and could not use the bridge.What such an extension could do
method: '_http.getToken'returned the raw token. In the SDK,_http.getTokenis a closure, so the dotted walk found a function and called it. That token is the MistWarp sign-in token, which holds 31 permissions, includingcredits:transfer,credits:manage,account:settings,signing:privateandvalidators:generate. Whoever holds it can spend the viewer's credits, sign in to MistWarp and other Rotur apps as them, change account settings and sign with their key.setToken,tokens.createandme.deleteAccountwere reachable the same way.kind: 'call'never checked the project's grant. The confirmation dialog only appeared if the frame setopts.sensitive, and the dialog showed the frame's ownlabel. Some.transferran without asking, or behind a dialog that said something else.kind: 'consent'withmeta.authenticatedOnly: truegranted any scope without asking and widened the shared token.meta.namechose which stored grant was used.storage.*took the project id from the frame, so one project could read or write another project's storage.Unsandboxed extensions in the editor and in packaged exports could do the same through
vm.runtime.roturHost.call. In the editor they already share the origin with the token, so this is defence in depth there. #17 covers that case. In exports, the token is the export's own token and holds only the scopes the project asked for.The fix
src/lib/rotur/project-methods.jsis the single allowlist. It lists the 91 SDK methods the eight built-in Rotur extensions call. Each entry gives the scopes that cover the method, and spending or destructive methods also get a confirmation builder. All three hosts now:tokens:manageorsigning:privateare rejected. Read-only scopes, and scopes whose methods always confirm, are granted without asking, as before. Everything else asks.callRoturinextension-bridge.jsdispatches through the same table, so nothing else in the GUI can walk arbitrary paths either.Behaviour changes
The scratch-vm fallback host gets the same treatment in MistWarp/scratch-vm#23.
Testing
test/unit/rotur-project-methods.test.jsruns every block of every built-in Rotur extension from the pinned scratch-vm against a recording host. It checks that every method called is allowlisted with the block's scope, that every sensitive block is confirmed, and that the table has no extra entries. It also checks that private paths are rejected, that the token can't be reached through a realrotur-sdkclient, that grants are enforced, that storage is pinned to the host's project id and that unknown scopes are rejected.test/unit/community-project-rotur-bridge.test.jsxmounts the real project page and posts the messages a malicious extension would send from the player frame. All four tests fail ondevelopand pass here.rotur-extension-hostandpackager-accounttests cover the editor and export hosts.jest --ci test/unit: 321 suites, 1874 tests pass. eslint is clean on the changed files.The only visible change is the wording of the confirmation dialog for non-payment actions.