Skip to content

Harden static-event forwarding and DefaultMessageBus - #870

Draft
bingenito wants to merge 1 commit into
morganstanley:mainfrom
bingenito:security/event-messagebus-integrity
Draft

Harden static-event forwarding and DefaultMessageBus#870
bingenito wants to merge 1 commit into
morganstanley:mainfrom
bingenito:security/event-messagebus-integrity

Conversation

@bingenito

@bingenito bingenito commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

  • EventEmitter's ipc setter re-broadcast any inbound message.eventName/eventArgs from the shared MessageBus as a local static event, so anyone able to publish on that bus could forge events like container-layout-saved with attacker-controlled args (CHAIN-02's entry point). Container/ContainerWindow now register the static event names their scope actually emits via EventEmitter.registerStaticEventNames, and the ipc setter drops anything outside that allowlist and strips __proto__/constructor/prototype keys from what it does forward.
  • DefaultMessageBus.publish fell back to reading the windows list off window.opener when the current window hadn't yet had its own list set (trusting whatever the opener planted there), and forwarded a caller-supplied targetOrigin verbatim (so "*" would broadcast to whatever origin the target window later navigates to). publish now only uses the windows list the runtime tracks directly on the window, and never honors a wildcard target origin.

EventEmitter's ipc setter re-broadcast any inbound message.eventName/
eventArgs from the shared MessageBus as a local static event, so anyone
able to publish on that bus could forge events like "container-layout-
saved" with attacker-controlled args (CHAIN-02's entry point). Container
and ContainerWindow now register the static event names their scope
actually emits via EventEmitter.registerStaticEventNames, and the ipc
setter drops anything outside that allowlist and strips __proto__/
constructor/prototype keys from what it does forward (F#05).

DefaultMessageBus.publish had two related issues (F#15): it fell back to
reading the windows list off window.opener when the current window
hadn't yet had its own list set, which trusts whatever the opener (not
necessarily created by this container) planted there; and it forwarded
a caller-supplied targetOrigin verbatim, so a "*" would broadcast to
whatever origin the target window later navigates to. Publish now only
uses the windows list the runtime tracks directly on the window, and
never honors a wildcard target origin.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.44%. Comparing base (133c5f1) to head (ed2ffda).

Files with missing lines Patch % Lines
packages/desktopjs/src/Default/default.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #870      +/-   ##
==========================================
+ Coverage   74.03%   74.44%   +0.40%     
==========================================
  Files          16       16              
  Lines        1510     1530      +20     
  Branches      318      323       +5     
==========================================
+ Hits         1118     1139      +21     
+ Misses        392      391       -1     
Flag Coverage Δ
unittests 74.44% <96.42%> (+0.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/desktopjs/src/container.ts 92.19% <100.00%> (+0.05%) ⬆️
packages/desktopjs/src/events.ts 100.00% <100.00%> (ø)
packages/desktopjs/src/window.ts 79.03% <100.00%> (+0.09%) ⬆️
packages/desktopjs/src/Default/default.ts 99.53% <80.00%> (+0.46%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bingenito bingenito changed the title Harden static-event forwarding and DefaultMessageBus (F#05, F#15) Harden static-event forwarding and DefaultMessageBus Jul 31, 2026
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.

1 participant