ADR 035: Renderer Trust Boundary with Context Isolation Disabled
Status
✅ Implemented (v2.24.0 and v2.30.0)
The sender-pinning, emitter and webview fixes shipped in v2.24.0 (PR #3053, PR #3054, PR #3055). The preload hardening, credential-free config and session permission handlers shipped in v2.30.0 (PR #3184, PR #3185). A navigation lock in front of the preload is the one item from the reports still open. Rule 8, on unsandboxed popups, was added in November 2026 after the move to Electron 45.
Context
The Teams window runs with contextIsolation: false and sandbox: false because reactHandler reads Teams' React internals for presence, idle sync and custom backgrounds; nodeIntegration stays false. The security architecture has recorded that trade-off since 2025, together with the compensating controls: CSP headers, the IPC channel allowlist and payload sanitiser, domain checks on DOM access.
Three private reports in October and November 2026 showed that the allowlist alone did not bound what page script could do, because with context isolation off the page and the preload share one JavaScript world:
- GHSA-3vg9-cwq9-p773: the preload's listener helpers returned the result of
ipcRenderer.on, which is the rawipcRenderer, and passed Electron's IPC event (whosesenderis the same object) to page callbacks. The picker channels then answered any sender, so web content could capture the desktop without consent. - GHSA-6xpg-fhf9-chcr: the sticker importer wrote attacker-controlled bytes to disk and disclosed the path, and an unvetted
<webview>could load that file as an unsandboxed preload, which runs with Node.js. - GHSA-58j7-22f8-6xqp: even after the first fix, page script could patch the shared built-ins (
Object.prototype,Function.prototype,WeakMap.prototype, the array iterator), dispatch a syntheticDOMContentLoadedand have the preload re-initialise through code it controlled, recoveringipcRendererfrom the objects that stored it. The genericelectronAPI.sendthen reached every allowlisted channel,get-configreturned the full configuration including MQTT and certificate passwords, no session had a permission handler so any popup or in-app page got microphone and camera without a prompt, and nothing stopped a navigation away from Teams while the privileged preload stayed attached.
The precondition in every case is script running in the Teams window, through an XSS in Teams web or a page loaded there. The reports made explicit what the earlier controls assumed away: a channel allowlist is not a boundary when the caller is inside the same world as the code that calls it.
Decision
Treat the whole JavaScript world of the Teams window and of every profile view as page-controlled, and move trust to places page script cannot reach: preload closures, the sender frame as seen by the main process, and the session.
- Nothing Electron-native leaves the preload. Listener helpers return nothing and strip the IPC event before calling back. The generic
electronAPI.sendis gone; the page sees only namedelectronAPImethods, each bound to a fixed channel with shaped arguments. ipcRendererlives only in closures and private fields. Browser tools flaggedipc: truestill receive the fullipcRendererthroughinit(config, ipcRenderer); the restriction is on where they keep it, in#privatefields under strict mode, not on what they receive. The narrowing applies to the page-facingelectronAPI, not to the tools. Strict mode is a security requirement, not style:EventEmittercalls listeners withthisset to the rawipcRenderer, and V8'sCallSite.getThishands that receiver to any sloppy-mode frame;tests/unit/preloadIpcLeak.test.jsfails for any file that registers a listener without it.- Initialisation runs once, on the browser's own event. The
DOMContentLoadedhandler returns unlessevent.isTrustedand a module-level started flag is clear. The module list is walked with an indexed loop over own properties, notfor...oforSet.has, and every entry sets its ownipcflag, because page script runs first and can patch the shared array and set built-ins orObject.prototype. The modules that needipcRenderer(trayIconRendererandmqttStatusMonitoramong them, see AGENTS.md and #1902) still receive it at init, through that guarded path. - The main process trusts the sender frame, not the channel name.
ipcValidatorkeeps the allowlist and payload sanitiser, and adds sender pinning (appPageOnlyChannels): the screen-share picker channels, the profile channels and all seven Graph channels answer onlyfile:senders inside the app directory. The Teams page has noelectronAPI.graphApi: nothing in the app called its five methods, so they were removed and their channels pinned too. Profile URLs must behttps. The wrapper inipcSecuritymakes a pendingonce()listener removable so a rejected sender cannot consume the picker's handler. - The renderer gets a credential-free config.
get-configreturnstoRendererConfig(config)(app/config/rendererConfig.js), a copy without MQTT, basic-auth or client-certificate secrets, because anything that handler returns is readable by page script. - Webview attach is refused everywhere.
webviewTag: falsein the root window and every profile view, plus an app-widewill-attach-webviewrefusal for any webContents created later. The sticker importer additionally checks the declared image signature before saving. - Device permissions follow the requester, on every session.
app/security/permissions.jsinstalls request and check handlers on the default session and each profile partition. Teams, government Teams, the Microsoft sign-in hosts, the configured URL,httpsprofile URLs and the app's ownfile:pages get full access. A cross-origin frame inside a trusted page keeps only what Chromium already gates per frame with Permissions Policy (media, display capture, clipboard, fullscreen). Any other page may only openmailto:andtel:links. Denials are logged once per permission and origin, without the URL path. - A popup runs unsandboxed only as a locked blank document. Since Electron 45 a
window.openchild whose sandbox setting differs from its opener's gets its own process and the opener'swindow.open()returnsnull, so a popup the Teams page renders into must carry the opener'ssandbox: false. That setting belongs to the window, not to the document: navigated to a URL, the popup becomes an unsandboxed renderer for that site with a livewindow.openerback to Teams. The override is allowed only when all of these hold. The opener needs the returned handle to render into the child. The URL is exactlyabout:blankand the child is locked there, withwill-navigateprevented and its own window-open handler denying everything, applied fromdid-create-windowso that no later policy replaces it (the profile view manager rebinds the open handler on every descendant). The request is recognised by a per-launch frame name generated in the main process, behind a config option. The override pinscontextIsolation: trueandnodeIntegration: false, sets no preload, and a unit test asserts it. A popup that loads or will load a URL never gets the override: Electron 45 already isolates it, and the opener does not need its handle. The Document Picture-in-Picture popup prompted this rule: PR #3232 adds thesandbox: falseoverride and has to add the lock and the pinned preferences before it merges. A later popup reuses those helpers rather than copying the literal.
The rules above are the contract for every new browser tool: no return of Electron objects to the page, ipcRenderer in a private field, strict mode, a sender check on any new privileged channel, and no unsandboxed popup outside rule 8.
Consequences
Positive
Script in the Teams window is bounded to the allowlisted channels with the argument shaping the preload applies, and the pinned channels (picker, profiles, people search, chat send) answer only the app's own pages. It cannot capture the screen, read credentials, add a profile that loads another origin with the preload, or obtain device permissions for a page outside the trusted set. Unpinned channels still accept any sender, and a trusted-origin popup can still be granted the microphone, which is why the permission policy is requester-based rather than a blanket popup denial. Each rule is enforced by code or a unit test rather than by review memory, which matters for a surface that has regressed before (#1902).
Negative
The shared world remains. Context isolation is still off, so these are compensating controls around a missing boundary, not the boundary itself, and a future preload change can reopen a path by storing ipcRenderer on a reachable object or iterating with a patchable built-in. Every browser tool carries the extra discipline, and the trusted-requester list in permissions.js must be extended when Teams moves to a new host. The navigation lock from GHSA-58j7 item 4 is not in place yet: a top-level navigation out of Teams still carries the preload with it.
Neutral
Popups opened from a profile view do not inherit the preload (Electron gives them context isolation, a sandbox and no preload), so their reach was already limited to permissions and phishing; the permission handlers close that remaining gap. The permission policy and the sender pinning are described operationally in the security architecture; this record holds the reasoning.
Alternatives Considered
Enable contextIsolation and expose a contextBridge API
Rejected again, for the reason recorded in the security architecture: reactHandler needs the page's React internals, and a bridge cannot hand those across an isolated world. Presence, idle sync, custom backgrounds and parts of the authentication flow depend on it.
Enable the Electron sandbox for the Teams window
Rejected on compatibility, not on IPC: a sandboxed preload keeps ipcRenderer (the profile switcher's preload in app/profileSwitcher/preload.js runs with sandbox: true), but the Teams preload is assembled from local CommonJS modules and uses Node modules such as node:path (for example app/browser/tools/dockIconRenderer.js), which a sandboxed preload cannot require. It would also not by itself close the shared world. It is worth revisiting for a different reason: with the Teams window sandboxed, popups would match their opener by default and rule 8 would no longer be needed.
Keep the allowlist as the only control
What the project had. Reaching ipcRenderer does not bypass the main-process allowlist: installIpcSecurity still validates every call and validateIpcChannel rejects unknown channels. What it bypasses is the preload's narrow helpers, so every allowlisted channel becomes callable with attacker-chosen arguments. The allowlist decides which channels exist, not who may call them or with what, and with one world the caller was any page script willing to patch a prototype.
Related
- Security Architecture: implementation detail for each control
- ADR-013: log hygiene that the denial logging follows
- ADR-020: the profile views and partitions these handlers cover
- Advisories: GHSA-3vg9-cwq9-p773, GHSA-6xpg-fhf9-chcr, GHSA-58j7-22f8-6xqp
- PR #3053, PR #3054, PR #3055, PR #3184, PR #3185, PR #3232 (rule 8)
- Electron 45 breaking changes:
window.openchildren of unsandboxed windows - Tests:
tests/unit/preloadIpcLeak.test.js,tests/unit/preloadModules.test.js