fix: remove messenger API exposure from window.__templateWingCompose#173
Open
JuliaKalder wants to merge 1 commit into
Open
fix: remove messenger API exposure from window.__templateWingCompose#173JuliaKalder wants to merge 1 commit into
JuliaKalder wants to merge 1 commit into
Conversation
Only expose the listener reference and a removeListener() helper on the compose window global. The full messenger/browser API namespace is no longer stored on window.__templateWingCompose.api, preventing injected HTML event handlers from calling extension APIs (storage, accounts, compose, runtime.sendMessage) with the extension's permissions. Fixes #163
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.
Summary
Remove the
api(messenger/browser WebExtension namespace) property fromwindow.__templateWingComposeon the compose window global. The compose script now only exposes thelistenerreference and aremoveListener()helper closure — the full extension API surface is no longer accessible from injected HTML event handlers in the compose window context.This closes a security gap where any JavaScript executing in the compose window (e.g., via cursor-mode template insertion with event-handler injection — see related issue #161) could call
window.__templateWingCompose.api.storage.local.get(),api.accounts.list(),api.compose.setComposeDetails(), and other privileged APIs with the extension's permissions.Changes
modules/compose-script.js(de-registration block, lines 38-45): Callprev.removeListener()instead ofprev.api.runtime.onMessage.removeListener(prev.listener)modules/compose-script.js(registration, line ~270): Replacewindow.__templateWingCompose = { listener: onMessageListener, api }with a version that exposes onlylistenerandremoveListener— theapinamespace is retained in closure scope forremoveListenerbut is no longer stored onwindowTesting
window.__templateWingCompose.apiis no longer setprev.removeListener()) is functionally equivalent to the prior directremoveListenercallFixes #163