CVE-2024-10465
Overview
Background
- `ClipboardContextMenu`
- A Firefox toolkit module (
toolkit/modules/ClipboardContextMenu.sys.mjs) that builds the small context menu offering a “paste” action when web content requests clipboard access. - `menupopup`
- The XUL element that hosts the paste
menuitem, created viacreateXULElementand identified bythis.MENU_POPUP_ID. - `tabspecific`
- A XUL popup attribute that ties a popup’s lifetime to the tab that opened it, causing the browser to auto-dismiss the popup when the user switches tabs.
Root Cause Analysis
The vulnerable code path is in ClipboardContextMenu’s popup-construction routine, where the menupopup element carrying the “paste” menuitem was created and appended to the chrome document without any binding to the originating tab. Because the popup lacked the tabspecific attribute, the browser’s popup-management logic had no signal to close it on a tab switch, violating the invariant that content-triggered UI should remain scoped to the tab that produced it.
As a result, a paste button spawned by one tab’s page could remain visible after the user navigated to a different tab, letting the button appear to belong to the newly focused (potentially attacker-unrelated) page.
The fix sets menupopup.setAttribute("tabspecific", "true"), so the popup is now automatically dismissed when the active tab changes. This restores the scoping invariant and removes the window in which a stale button could be misattributed to another tab’s content.
tabspecific marker on the paste menupopup, which left a content-initiated popup untethered from its originating tab; adding tabspecific="true" lets the browser tear the popup down on tab switches, eliminating the cross-tab persistence that enabled spoofing.Attack Path
- Trigger the paste UI
A malicious page invokes a clipboard read that causes
ClipboardContextMenuto build and show the pastemenupopupin the current tab. - Leave the popup open The attacker’s page arranges for the popup to remain displayed rather than being immediately consumed by the user.
- Induce a tab switch
The user (or a script-driven interaction) moves focus to a different tab while the untethered
menupopupis still on screen. - Spoof context The stale paste button now overlays or appears alongside the newly focused tab’s content, so the user perceives it as belonging to that unrelated page.
- Capture the interaction The user clicks the misattributed button, performing a clipboard action they believe is scoped to the current tab rather than the attacker’s original context.
Impact Assessment
Files Changed
toolkit/modules/ClipboardContextMenu.sys.mjs
Audit Directions
- Untethered content popupsReview other modules that create
menupopupor similar XUL popups in response to web content and confirm each setstabspecificor otherwise binds its lifetime to the originating tab. - Tab-switch cleanupAudit content-triggered chrome UI for missing dismissal handlers on tab or window focus changes, since state that survives a context switch can be misattributed to another tab.
- Attribute-driven scopingLook for places relying on XUL attributes like
tabspecificwhere the attribute is conditionally or never applied, as omitted scoping markers are a recurring source of cross-context persistence bugs.
Patch
diff --git a/toolkit/modules/ClipboardContextMenu.sys.mjs b/toolkit/modules/ClipboardContextMenu.sys.mjs
index d68e89c2530..2175da37eb5 100644
--- a/toolkit/modules/ClipboardContextMenu.sys.mjs
+++ b/toolkit/modules/ClipboardContextMenu.sys.mjs
@@ -163,6 +163,7 @@ export var ClipboardContextMenu = {
let menupopup = aChromeDoc.createXULElement("menupopup");
menupopup.id = this.MENU_POPUP_ID;
+ menupopup.setAttribute("tabspecific", "true");
menupopup.appendChild(menuitem);
return menupopup;
},