Skip to content

fix: remove messenger API exposure from window.__templateWingCompose#173

Open
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-163
Open

fix: remove messenger API exposure from window.__templateWingCompose#173
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-163

Conversation

@JuliaKalder
Copy link
Copy Markdown
Owner

Summary

Remove the api (messenger/browser WebExtension namespace) property from window.__templateWingCompose on the compose window global. The compose script now only exposes the listener reference and a removeListener() 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): Call prev.removeListener() instead of prev.api.runtime.onMessage.removeListener(prev.listener)
  • modules/compose-script.js (registration, line ~270): Replace window.__templateWingCompose = { listener: onMessageListener, api } with a version that exposes only listener and removeListener — the api namespace is retained in closure scope for removeListener but is no longer stored on window

Testing

  • Code review confirms window.__templateWingCompose.api is no longer set
  • De-registration path (prev.removeListener()) is functionally equivalent to the prior direct removeListener call
  • Compose script continues to function: listener is registered on load, deregistered on reload before re-registration

Fixes #163

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MEDIUM] compose-script.js: messenger API reference exposed on window.__templateWingCompose.api — allows extension API abuse via compose-window XSS

1 participant