Skip to content

Harden OpenFin tray menu HTML and message bus sender identity - #871

Draft
bingenito wants to merge 1 commit into
morganstanley:mainfrom
bingenito:security/openfin-hardening
Draft

bingenito wants to merge 1 commit into
morganstanley:mainfrom
bingenito:security/openfin-hardening

Conversation

@bingenito

@bingenito bingenito commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

  • getMenuItemHtml built the tray context menu's <li> markup by interpolating MenuItem.label/.icon directly into HTML with no escaping, and MenuItem.id directly into an inline onclick JS string with no escaping. 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 (especially since the default senderUuid is "*"). subscribe now forwards uuid/name to the listener's event object.

…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>
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.13%. Comparing base (133c5f1) to head (381302a).

Files with missing lines Patch % Lines
packages/desktopjs-openfin/src/openfin.ts 81.25% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #871      +/-   ##
==========================================
+ Coverage   74.03%   74.13%   +0.09%     
==========================================
  Files          16       16              
  Lines        1510     1523      +13     
  Branches      318      309       -9     
==========================================
+ Hits         1118     1129      +11     
- Misses        392      394       +2     
Flag Coverage Δ
unittests 74.13% <81.25%> (+0.09%) ⬆️

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

Files with missing lines Coverage Δ
packages/desktopjs-openfin/src/openfin.ts 87.78% <81.25%> (-0.11%) ⬇️
🚀 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 OpenFin tray menu HTML and message bus sender identity (F#08, F#10, F#17) Harden OpenFin tray menu HTML and message bus sender identity 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