Repository navigation
Harden OpenFin tray menu HTML and message bus sender identity - #871
Merged
bingenito merged 2 commits intoNov 3, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #871 +/- ##
==========================================
- Coverage 90.95% 90.88% -0.08%
==========================================
Files 15 15
Lines 1161 1174 +13
Branches 245 253 +8
==========================================
+ Hits 1056 1067 +11
- Misses 100 107 +7
+ Partials 5 0 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…F#10, F#17) getMenuItemHtml built the tray context menu's <li> markup by interpolating MenuItem.label and .icon directly into HTML with no escaping (F#08), and MenuItem.id directly into an inline onclick JS string with no escaping (F#10). A menu item sourced from untrusted content (eg. a remote page's title) could inject markup or break out of the onclick string to run arbitrary script when the tray menu renders. label/icon are now HTML-escaped, and the onclick handler's arguments are built with JSON.stringify and then HTML-attribute-escaped as a whole (JSON.stringify's own double quotes would otherwise collide with the onclick="..." attribute delimiter). OpenFinMessageBus.subscribe discarded the sender uuid/name that OpenFin's InterApplicationBus.subscribe callback provides, so listener code had no way to tell who sent a message and authorize accordingly (F#17, especially since the default senderUuid is "*"). subscribe now forwards uuid/name to the listener's event object. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
bingenito
force-pushed
the
security/openfin-hardening
branch
from
November 3, 2026 21:12
381302a to
c4cf816
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the tray-menu escaping and sender-identity changes.
No open issues 🎉
What changed in this PR
This PR hardens OpenFin tray menu rendering against HTML and inline-script injection and exposes message sender identity so listeners can authorize incoming messages.
Changes:
- Escape menu labels, icon URLs, and serialized inline-handler arguments.
- Forward OpenFin sender
uuidandnameto message bus listeners. - Add regression tests for menu escaping and sender identity forwarding.
| File | Description |
|---|---|
packages/desktopjs-openfin/tests/openfin.spec.ts |
Adds menu-injection regression tests and verifies sender identity forwarding. |
packages/desktopjs-openfin/src/openfin.ts |
Escapes tray menu HTML and handler arguments; includes sender identity in message events. |
Review effort: Balanced
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
getMenuItemHtmlbuilt the tray context menu's<li>markup by interpolatingMenuItem.label/.icondirectly into HTML with no escaping, andMenuItem.iddirectly into an inlineonclickJS string with no escaping. A menu item sourced from untrusted content (eg. a remote page's title) could inject markup or break out of theonclickstring to run arbitrary script when the tray menu renders.label/iconare now HTML-escaped, and theonclickhandler's arguments are built withJSON.stringifyand then HTML-attribute-escaped as a whole (JSON.stringify's own double quotes would otherwise collide with theonclick="..."attribute delimiter).OpenFinMessageBus.subscribediscarded the senderuuid/namethat OpenFin'sInterApplicationBus.subscribecallback provides, so listener code had no way to tell who sent a message and authorize accordingly (especially since the defaultsenderUuidis"*").subscribenow forwardsuuid/nameto the listener's event object.