Skip to content

fix(electron): gate app-menu IPC per-action for remote gateway senders - #13040

Merged
bolichen97 merged 3 commits into
kirodotdev:mainfrom
josej4m:security-per-action-menu-gate
Nov 14, 2026
Merged

bolichen97 merged 3 commits into
kirodotdev:mainfrom
josej4m:security-per-action-menu-gate

Conversation

@josej4m

@josej4m josej4m commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A remote gateway page shown in a connection window can no longer drive privileged local actions — quitting the app, reading the OS clipboard, opening Settings or DevTools — from the Windows titlebar menu.

A remote gateway page loaded in a connection window shares the Electron preload with the local dashboard. Nothing at the IPC boundary stopped it from calling getAppMenuItems and executeAppMenuItem, so a hostile or compromised gateway could reach menu roles that operate outside its own document — paste reads the local OS clipboard, quit terminates the app, close/minimize/zoom mutate the OS window the remote is drawn in, togglefullscreen covers the whole desktop. Custom-click items were reachable too: Toggle DevTools would open DevTools on the local dashboard's origin, and Settings/About windows would open under the local process.

Why it matters

Connection windows exist so a user can look at remote content while keeping their local dashboard next to it. The trust boundary is the origin: the local gateway is trusted, a remote gateway is not. Without a per-action gate at the IPC boundary, that boundary was enforced only by the channel-level assertLocalDashboard check — which was gated per-CHANNEL, not per-ACTION. A remote sender that reached the channel at all reached every action on it.

Not a goal

  • Extending the gate to the Linux and macOS native menus. Those menus have no renderer-invocable API, so app-menu:* is the only path a remote sender can reach; enforcement is Windows-only by design, not by omission.
  • Gating the non-menu preload channels a remote sender can also reach (update:check / download / install / set-channel / set-auto-download, and local-gateway:set). Named in the Scope note below and tracked under Follow-ups.
  • Fixing the pre-existing gate-3 false negative that greys the menu on from-source Windows venv builds. It sits upstream of this PR in windows-port.js, in the probe this PR consumes; tracked under Follow-ups.

What changed (motivation → approach → change)

sequenceDiagram
    autonumber
    participant R as Remote gateway page
    participant B as Preload bridge (shared)
    participant I as ipcMain handler
    participant M as executeMenuItem

    Note over R,M: BEFORE — channel-only gate
    R->>B: executeAppMenuItem("edit-menu", 2)
    B->>I: send("app-menu:execute")
    I->>M: dispatch (per-CHANNEL gate only)
    Note right of M: no per-action fence past the channel<br/>a race or added local-adjacent path<br/>reaches the model with no LOCAL_ONLY check

    Note over R,M: AFTER — per-action fence
    R->>B: executeAppMenuItem("edit-menu", 2)
    B->>I: send("app-menu:execute")
    I->>I: resolveSenderIsLocal(sender)<br/>WeakMap cache miss → probe → false<br/>cache verdict, wire did-navigate invalidation
    I->>M: executeMenu(sender, id, index, senderIsLocal=false)
    M-->>R: refuse (LOCAL_ONLY_ROLES.has("paste") ∧ !senderIsLocal)
    Note right of M: log entry, no dispatch<br/>serializeMenuItems also paints enabled:false
Loading

Approach. The IPC boundary already resolves whether the sender is local (assertLocalDashboard: origin + local-gateway + primary-port-owner). Thread that verdict down as a per-action gate, and reflect it on the items surface so a rendered menu row cannot silently no-op when clicked.

Change. windows-menu-model.js classifies every menu leaf into one of three positive-membership sets — LOCAL_ONLY_ROLES, LOCAL_ONLY_MENU_IDS, LOCAL_ONLY_ITEM_IDS. Anything not in the sets is remote-safe by default; there is no fourth allowlist (an earlier draft carried a REMOTE_SAFE_ITEM_IDS set for symmetry, removed in a later push once it proved to have zero consumers). executeMenuItem refuses a LOCAL_ONLY leaf when senderIsLocal !== true (strict fail-closed). serializeMenuItems reflects the same verdict as enabled: false on the items surface, so the row exists but cannot be clicked. ipc-registrar.js resolves the verdict once per WebContents via a WeakMap cache invalidated on did-navigate and expiring after 5s, so per-click cost stays sub-ms without letting a positive outlive the mutable fact behind gate 3 (see Positive-verdict expiry below). dev-mode-changed picks up the same gate, read strictly: only a proven local owner may flip the DevTools row's visibility. The direction that matters is HIDE rather than show — app-menu.js builds that row visible: true, so a refusal leaves it visible and what the gate prevents is a remote sender hiding the local user's row. A template-walk drift pin walks buildMenuTemplate output for both isMac branches and asserts every reachable leaf is either classified into one of the three sets or accepted as remote-safe.

Windows-only enforcement is deliberate. The app-menu:* IPC is the only renderer-invocable menu path — Linux and macOS use the native OS menu, which has no renderer API. Custom click handlers already resolve to focusedDashboardWebContents(), which walks the focused window's contentView children to find the dashboard view, never remote content. The three sets are the global policy for the app-menu IPC surface; the enforcement point is single because the menu attack surface is single. If a Linux frameless custom titlebar menu ever ships, it plugs into executeMenuItem with senderIsLocal and inherits the same sets.

Scope note (menu-only). This PR closes the per-action gap on app-menu:*. It does NOT gate every non-menu preload channel a remote sender can reach — 6 in particular (update:check / update:download / update:install / update:set-channel / update:set-auto-download, plus local-gateway:set) remain ungated by assertLocalDashboard on base, so update:install in particular could still be used by a remote sender to terminate the local app. Closing those is out of scope for this PR and is called out here so a reader auditing the "attack surface is single" phrasing above sees it named rather than implied to be fixed. Tracked as a follow-up — see Follow-ups at the bottom of this description.

Rejection-log throttle. glog is an unrotated synchronous fs.appendFileSync on the main thread and the gate writes one line per rejection. Two of the three channels this PR routes through the gate are fire-and-forget ipcRenderer.send paths (app-menu:execute, dev-mode-changed), so a remote page loops them at renderer speed with no backpressure — unlike every pre-existing gated channel, each of which is an awaited ipcRenderer.invoke that self-throttles to the IPC round trip. The single-flight coalescer does not cover this: each IPC message is its own main-thread task and microtasks drain between tasks, so the in-flight entry is always empty when the next message lands. logGateRejection therefore throttles per WebContents — first 5 rejections in any 60s window are written, the rest counted, and the count reported once when the window rolls so a sustained flood stays visible at full magnitude. This bounds the write, never the verdict: every call still runs all three gates and still rejects, so no cached false exists to strand a legitimate local user on a permanently-greyed menu (the failure mode the removal of negative caching exists to prevent).

Positive-verdict expiry. A cached positive asserts three facts, and they are not all the same kind of fact. Gates 1 and 2 are properties of the page — the frame's origin and the sending window's gateway — so a navigation moves them and the did-start-navigation / did-navigate listeners clear the cache when it does. Gate 3 is a property of the machine: the primary port's LISTEN owner. It can change with nothing whatsoever happening to the sender. Our gateway exits and releases the socket, a foreign process or a hand-rolled ssh -L binds that port, the page never navigates, no listener fires — and the cached true keeps answering for the WebContents' remaining lifetime, skipping the one gate that can see a tunnel while the clipboard roles and devtools-toggle stay unlocked against a port this shell no longer owns. SPA route changes fire did-navigate-in-page and are deliberately non-clearing, so there was no recovery short of a full top-frame navigation. A foreign listener can only take the port if our gateway released it first — nothing else can bind while we hold the socket — so the exposure is bounded by "our gateway exited", and a 5s expiry bounds it in time: the repeat calls one menu interaction produces still hit the cache (which is the whole reason it exists — a probe per click added hundreds of ms to a hot path), while a positive older than the window falls through to a fresh three-gate probe. Like the throttle above, this bounds the reuse of a verdict, never the verdict itself: a false is still never cached. The expiry bounds what a positive may AUTHORIZE, not what it may PAINT: since 8d4ba61b, app-menu:items paints a lapsed positive at once and re-probes in the background, while app-menu:execute still refuses unless a fresh probe proves a local owner, so the click stays the real gate (buluoray Blocking 1 on cb31d4f18a). See the F1 finding in GPT 5.6 Review on bd68985db (UPHOLD-FENCED, adjudication flagged=0).

Probes are coalesced, and a probe outcome is never permission. Gate 3 shells out per call with nothing cached beneath it, so concurrent callers on one WebContents await a single in-flight probe. That join is deliberately unconditional: a generation term there let a caller bump the generation with a navigation, decline to join, and spawn its own probe, handing a remote page the probe count. Generation equality belongs on the verdict, not on whether to share the work. Relatedly, the inconclusive mark records a WebContents and not the document that minted it, so the one reader left uses it only to withhold paint — which is why the soft read on dev-mode-changed was removed rather than generation-stamped.

Port-owner classification. classifyPortOwner gains "unidentified" — a holder netstat named whose command line could not be read — distinct from "unknown" (nothing known to hold the port) because two consumers need opposite answers: the app-menu gate wants it soft, and the adopt path needs it hard, since adopting posts this machine's .local_secret to a process it cannot name. WindowsTitlebarMenu.tsx renders the refusal through ErrorNotice, and docs/build/desktop-app.md records the strict reading and its one accepted cost.

Behavioural delta, stated rather than waived. windows-menu-model.js derives gated — and therefore enabled: false and the footer — purely from the boolean verdict plus static set membership (const gated = senderIsLocal !== true && isLocalOnlyItem(...)), so nothing about why a verdict was false reaches the renderer. Two appearances are new and both are captured below: the footer on any menu carrying a gated row, and the refusal notice a refused click renders (capture 8). One reachable state is new as well: a probe that cannot name the primary-port holder (unknown, unidentified, or none while our gateway restarts) keeps the local user's LOCAL_ONLY rows painted enabled for INCONCLUSIVE_PAINT_GRACE_MS (30s past the 5s window, measured from the positive's mint time), but never authorizes a click. Past that grace the rows grey with the footer, so a probe that keeps failing is shown, not hidden. A proven foreign holder drops the positive at once, and a first call with no positive still fails closed. It cannot be photographed, since demonstrating it requires staging a probe failure inside that window.

Backwards compatibility

Compatible for local senders. A user in a connection window whose dashboard has navigated to a remote gateway origin will see LOCAL_ONLY rows (Settings, Exit, Paste, Copy, Cut, Toggle DevTools, Keep on Top, Toggle Focus Mode, Reload, Force Reload, Zoom In/Out/Actual, the whole Connection submenu) greyed on the Windows titlebar menu — they must return to the main window to invoke those actions. The remote gateway sender was never intended to reach these actions in the first place; the fix closes an unintended path.

Physical keyboard shortcuts are unaffected, and a gated row carries no per-row marker about them. Greying already states the row is inert from this window; the footer states the part greying cannot:

"Some items work only in the main window. The shortcuts shown still work."

Two sentences, and the second one is a claim about the keyboard that the gate now makes true by construction. Some chords do still act from a connection window: Electron's native dispatch routes an OS-registered accelerator (Reload Ctrl+R, Zoom In/Out, F11, New Connection Window Ctrl+Alt+N, Refresh Token Ctrl+Shift+T) straight to the menu item, bypassing the app-menu IPC gate, and Chromium handles Ctrl+C / Ctrl+X / Ctrl+V natively in the focused renderer. Rows whose accelerator is display-only (Settings' Alt+,, an explicit registerAccelerator: false) do not act.

The earlier objection to that sentence was that it named a distinction the user could not resolve: a greyed Paste beside Ctrl+V and a greyed Settings beside Alt+,, told that some work, with no way to tell which. That objection is answered by removing the unresolvable case rather than by softening the copy. serializeMenuItems now blanks the accelerator of any gated row whose chord does not survive the gate, so every caption still visible on a greyed row is one that fires. In practice that suppresses exactly one: File ▸ Settings…, whose Alt+, is registerAccelerator: false and is routed by the renderer's own shortcut registry, which never receives the keystroke while focus sits in a remote page.

The distinction is therefore applied rather than advertised. No per-row marker is drawn, no accelerator-registration field crosses the IPC boundary, and the footer's claim is scoped to the captions the user can actually see. The suppression is what makes the second sentence true rather than half-true.

The footer renders on any menu containing a gated row and on no other, so a user is always told why a row is grey, and it sits BELOW the mapped items so first-row geometry stays stable against the same menu in the main window. Its wording went through several rounds with UX Review over footer weight and over how much it should claim. The version here is the shortest one that is fully true of every gated row.

Tests

  • serializeMenuItems marks LOCAL_ONLY leaves disabled for a remote sender — remote paste/copy/cut greyed, sender-scoped Select All stays enabled, local sender restores everything
  • serializeMenuItems disables LOCAL_ONLY_ITEM_IDS on the View menu for remote senders — reload/zoom/devtools-toggle/keep-on-top all greyed (focus-scoped custom-click handlers resolve to focusedDashboardWebContents(), so a remote sender in an unfocused connection window could otherwise reach the LOCAL dashboard)
  • executeMenuItem should reject every LOCAL_ONLY role when sender is remote — paste, pasteandmatchstyle, copy, cut, quit, close, minimize, zoom, togglefullscreen
  • executeMenuItem should reject items under connection-menu when sender is remote — whole-submenu fence
  • executeMenuItem should reject the keep-on-top item when sender is remote — per-item fence under an otherwise-safe submenu
  • every reachable menu leaf is classified in one direction — template-walk drift pin, both isMac branches, filtered by WINDOWS_TITLEBAR_MENU_IDS reachability
  • LOCAL_ONLY sets pin the exact membership — set-shape pin catches silent widening
  • app-menu:items forwards senderIsLocal=false so LOCAL_ONLY rows advertise as disabled — IPC boundary pin
  • app-menu:execute forwards senderIsLocal=false and logs the reject when the sender is remote — dispatch-side gate pin
  • dev-mode-changed is refused for a remote sender — a remote sender can no longer hide the local user's DevTools row
  • dev-mode-changed is refused when the port's holder cannot be named — loops unknown / none / unidentified and asserts setDevMode is never called, which is the assertion for "a probe outcome is not permission" rather than one about a flag's value
  • dev-mode-changed refuses a remote caller that joins a pre-navigation probe — a mark minted by the previous document must not license the one that replaced it
  • repeated navigations must not multiply in-flight port-owner probes — drives the attacker's own loop (navigate, call, five times) and asserts the in-flight probe count never leaves 1. Behavioural rather than source-shape, deliberately: the shape pins can assert all three of the coalescer's anchors are present and still pass while a condition defeats it, which is exactly what happened
  • the source-shape pin on the join condition is inverted to assert.doesNotMatch, so no generation term can return to it; the behavioural pin above is the authority on the class
  • a flooding remote sender cannot force one gate log write per call — 200 sequenced calls (one per event-loop turn, matching real IPC delivery) must produce a bounded write count, while all 200 still reach menu.execute with senderIsLocal=false so the throttle provably covers the log and not the verdict
  • the gate log throttle is per WebContents, not global — a second window's first reject still lands after a flooding sender exhausted its own burst
  • a sustained flood reports its suppressed volume when the throttle window rolls — window-rollover summary names the suppressed count, so the log understates nothing
  • a positive verdict older than its window re-runs all three gates — the lapse must reach the port-ownership probe again, not be answered from the cache
  • a lapsed positive whose port owner has changed resolves to not-local — the security property itself: a verdict minted while our gateway held :port must flip once a foreign listener owns it, with the reject logged so the flip is attributable
  • a positive verdict inside its window is answered without re-probing — guards the other direction, so the expiry cannot silently become a netstat/PowerShell shell-out per menu click
  • a navigation still invalidates a positive verdict inside its window — the expiry is an additional bound on gate 3's mutable fact, never a substitute for the origin checks
  • menuItems accepts and forwards senderIsLocal into serializeMenuItems — source-scan pin for the === true fail-closed rule
  • executeMenu accepts and forwards senderIsLocal into executeMenuItem — source-scan pin for the boundary threading

Proof: not provable -- frontend test (prove.py runs Python only)

That is prove.py's own verdict, not a waiver, so the equivalent was done by hand at head f9599bbd6f97. Re-introducing the generation term in the join condition reddens exactly 2 tests — repeated navigations must not multiply in-flight port-owner probes and the join-condition shape pin. Restoring the soft read on dev-mode-changed reddens 4, including dev-mode-changed is refused when the port's holder cannot be named and dev-mode-changed refuses a remote caller that joins a pre-navigation probe, so the strict read is load-bearing for the two round-N regression pins as well as the new one.

The serializeMenuItems does not silently pass a submenu off as a command case in windows-titlebar-contract.test.js is migrated to the new (topLevelItem, senderIsLocal) signature — the guarantee that case tests (a nested submenu must not serialize as type: "normal") is unchanged; only the input shape moved to reflect serializeMenuItems now taking the top-level menu item so the per-action gate can classify by top-level id.

90/90 in the four website/electron/test/ suites this PR touches, measured after the rebase recorded below. No production code test-only regressions.

Re-run on Windows 11 (build 26200, Electron 43, Node 24.21.0):

Suite Result
website/electron/test/windows-menu-model.test.js 15/15 pass
website/src/test/WindowsTitlebarMenu.test.tsx 28/28 pass
website/electron/test/windows-titlebar-contract.test.js + window-lifecycle.test.js 21/21 pass
website/electron/test/ipc-registrar.test.js 29/31 pass
Full website/electron suite 2095/2102 pass

The two ipc-registrar failures are environmental, not behavioural: dashboard:open-file validates the path before handing it to the OS and … opens a valid file at its realpath both call fs.symlinkSync, which raises EPERM on Windows unless the shell is elevated or Developer Mode is on. Neither touches app-menu:*.

Rebased onto current main (523 commits). The branch was 523 commits behind when the merge conflict label appeared. The conflict was confined to locale catalogs: 11 files (en.json plus 10 translations) each carried the same single hunk, where upstream appended metrics_card_old_data / metrics_card_fetch_failed at the exact tail position this PR's two titlebar_menu_* keys occupy. Resolved keep-both with upstream's keys first and this PR's appended after, editing only the conflict markers so no translated value was retyped and no catalog was re-sorted — fr.json's U+202F narrow no-break space is untouched. No code file conflicted.

One absorbed commit is worth naming because it lands on this PR's own surface: b63c548df "refactor(electron): split the lifecycle modules into runtime owners" restructures window-lifecycle.js and gateway-supervisor.js behind runtime/ facades. The move is verbatim with exports unchanged, so the gate's call seams held; the post-rebase suites are the evidence rather than the assertion. Diff-scoped run after the rebase: 86/86 across the four website/electron/test/ suites, 30/30 WindowsTitlebarMenu.test.tsx, 101/101 i18n including the strict CI-mode gate. The diff remains 24 files and contains no Python — git diff --name-only upstream/main...HEAD -- '*.py' returns nothing, so any Windows backend test failure in CI is upstream's own and not reachable from this change.

Manual verification

Re-run complete at 5db5c793b. The per-row keyboard glyph and struck caption are gone, the footer carries that information instead, an eighth View row (focus-mode-toggle, from upstream) is now gated, and a gated row whose chord cannot fire now ships an empty accelerator. Captures 1-7 and the geometry numbers below are from that head. Where an older observation has been superseded it has been replaced rather than annotated; the one paragraph kept as a historical record is the three-distribution venv table under Prerequisite, which a fresh measurement now contradicts and which is flagged inline.

Windows Electron end-to-end verification is now done. Run on Windows 11 Enterprise (build 26200), Electron 43.2.0, Node 24.21.0. The three recipe steps and the accelerator behaviour were first verified at e38a611b3/f72a2cc98 on a CPython 3.14.7 backend, and re-verified after each subsequent amend; all seven attached captures and every geometry number below were re-taken at 5db5c793b on a CPython 3.13.4 backend provisioned through uv — none is carried over from an earlier round. Nothing in the gate depends on the interpreter version — it is recorded because gate 3's port-owner probe does (see the prerequisite below). The titlebar menu was driven over the Chrome DevTools Protocol so each assertion reads the live app-menu:items payload as well as the rendered DOM; captures below are real renderer screenshots, not mockups.

All three recipe steps pass.

  1. Local dashboard, main window — File / Edit / View / Connection all report enabled: true, gated: false for every leaf. No footer rendered, no glyphs. Nothing greyed.
  2. Connection window at a second local gateway origin — Settings…/Exit greyed; Cut/Copy/Paste greyed (gated: true) while Undo/Redo/Delete/Select All stay enabled; all eight View rows greyed, focus-mode-toggle included; the whole Connection submenu greyed. Every caption on every greyed row renders plain — no keyboard glyph and no strike-through anywhere, asserted as zero <svg> nodes in the popup and zero spans whose computed text-decoration-line contains line-through. Footer present on every menu with a gated row and on no other. Both windows held these opposite states simultaneously — the main window stayed fully live while the connection window was fenced.
  3. Settings display-only accelerator — now suppressed, not struck. From the connection window Settings… arrives with accelerator: "", so no caption span renders at all. Alt+, is registerAccelerator: false, the one chord in the menu that cannot fire from a remote-focused window, and blanking it is what makes the footer's second sentence true of every caption that remains.

In-product remedy confirmed. Clicking a greyed row (View ▸ Reload from the connection window) does nothing: the row reports disabled, no navigation occurs, the popup stays open, no crash, no partial dispatch.

Physical accelerator path — verified on Windows. With a connection window focused on a remote gateway origin, pressing Ctrl+R reloads that connection window's own WebContents (Electron's per-window default accelerator dispatch — the chord is alive, but it reloads what has focus, not the main window's local dashboard). Ctrl+= behaves application-global (both windows zoom). Chromium clipboard chords (Ctrl+C / Ctrl+X / Ctrl+V) act on the focused renderer's own selection through Chromium's clipboard path, not through the app-menu IPC gate — which is why Cut/Copy/Paste keep their captions even though Electron reports them registerAccelerator: false. Reading that flag alone would blank three captions that demonstrably work, which is why acceleratorStillFiresFromThisWindow special-cases the Chromium-native clipboard roles. The row-specific target depends on Electron's dispatch model and is documented above per-role.

Second Windows run at 5db5c793b — latency, paint behaviour, accelerator dispatch, and the paint/probe commit. Run independently of the measurements above, on a from-source venv build with the shell spawning its own gateway. Where it overlaps Design Review Watch 2 it agrees with it, which is two independent runs rather than one restated.

Probe cost (First Principles item 5, and the advisory on layering). The probe shells out twice. Timed through child_process.execFile with argv byte-identical to windows-port.js — netstat.exe -ano, then powershell.exe -NoLogo -NoProfile -NonInteractive -Command <Get-CimInstance script> — five consecutive runs against the live gateway's port holder:

Run netstat PowerShell total
1 70ms 547ms 617ms
2 154ms 585ms 739ms
3 71ms 523ms 594ms
4 68ms 566ms 634ms
5 68ms 553ms 621ms

Hundreds of milliseconds, not tens, so the caching layers are earning their place. The cost is structural to shelling out rather than to the query: the PowerShell spawn is 523–585ms of each total against 68–154ms for netstat, i.e. process start plus CIM cmdlet load, which no cheaper filter would recover. Each run returned 203 bytes naming the port holder, so these are timings of a probe doing its real work, not of a failing call. One host, five samples — it answers "does this cost hundreds of ms on a real Windows box", not "what is the floor on fast hardware".

What that costs the user (the advisory on the empty paint). openMenu sets the item list to [] and awaits app-menu:items, so the popup frame paints before the rows do. Measured with a MutationObserver stamping both transitions against the click:

  • Positive still fresh (under the 5s TTL): rows at 103ms — effectively instant.
  • Positive lapsed but inside the 30s grace: rows at 122ms. This is the paint/probe commit working; it is also exactly what D1 measures, since a first open after a cold app start lands here.
  • Positive past the 35s boundary: popup frame at 67–130ms but rows at 903 / 1071 / 928 / 948 / 1191ms across five opens each taken more than 35s apart — roughly a second of visibly empty popup before the rows arrive.

So the cache stack is the difference between 103ms and a second of empty menu, which is a stronger justification than the probe figure alone. On an open that paints empty, ArrowDown does not move focus — document.activeElement stayed on BODY with zero rows mounted, confirming the advisory: there is no enabled button to land on yet.

Accelerator dispatch from a connection window — the footer's second sentence. Driven with Win32 SendInput against the connection window's handle, with the remote page holding keyboard focus. CDP was deliberately not used for this: its Input domain delivers into the renderer and never reaches Electron's OS accelerator dispatch, so it would have produced a false negative and sent the footer back for a rewrite in 13 locales for no reason.

Chord Row Observed
Ctrl+R View ▸ Reload fires — reloads the connection window's own WebContents
Ctrl+0 View ▸ Actual Size fires — resets zoom on both windows
Ctrl+= View ▸ Zoom In fires — zooms both windows
F11 View ▸ Toggle Full Screen fires
Ctrl+Shift+W Window ▸ Close fires — closes the window
Ctrl+Alt+N Connection ▸ New Connection Window… fires — opens the port prompt
Ctrl+V Edit ▸ Paste fires — clipboard marker landed in the composer
Ctrl+Shift+T Connection ▸ Refresh Token not verified

Seven of the eight confirmed. Ctrl+Shift+T is recorded as unverified rather than passing: a token refresh has no in-page observable and the Electron log carries no token line either way, so there was no signal to read. It is a custom click handler, and two other custom click handlers on the same path (Ctrl+R, Ctrl+Alt+N) demonstrably fire, so the mechanism is proven for its class — but that is inference, not measurement, and it is the one caption in the menu whose footer claim rests on it.

The execute gate, with a control (the paint/probe commit's security half). The question the paint change raises is whether a row that LOOKS enabled can be clicked through. Tested at the IPC boundary rather than on the button, because disabled is cosmetic and a hostile page would call executeAppMenuItem directly. From the remote-classified window, Settings…, Reload, Toggle Focus Mode and Keep on Top were all refused with no effect. The control matters more than the refusals: the identical Reload dispatch from the LOCAL window destroyed a sentinel variable planted in the page, proving the detector could see a dispatch at all. An earlier attempt used "did the URL change" as the signal and showed no change for the legitimate local call either — a refusal measured with a blind detector proves nothing, so that run was discarded rather than reported.

The 35s boundary. With the gateway killed and the port left unbound, app-menu:items was polled on the main window every 2.5s. The rows came back greyed at t+34.9s, against the 35s POSITIVE_VERDICT_TTL_MS + INCONCLUSIVE_PAINT_GRACE_MS predict. The boundary is anchored to the positive's mint time, not to the gateway's death, and a successful respawn re-mints and restarts it — which is why this state is measurable but not photographable (see capture 7).

Prerequisite for anyone re-running this from source on Windows

A from-source venv build cannot pass gate 3 of assertLocalDashboard as written, and the symptom looks exactly like the false-negative envelope below: every LOCAL_ONLY row greyed in the LOCAL main window. This is pre-existing behaviour in windows-port.js, not something this PR introduces — it sits upstream of the four-set classification, in the probe this PR consumes. (Following the pre-PR per-channel gating, the same gate-3 verdict would have refused app-menu:items outright and left an empty menu rather than a greyed one; that inference is from the code path, not from a run of the pre-PR build.)

Cause: windowsGatewayExecutablePaths trusts the gateway launcher plus <venv>\Scripts\python.exe and <venv>\python.exe, on the stated assumption that "a distlib console launcher delegates to the venv interpreter." On Windows it delegates to the base interpreter. A venv's Scripts\python.exe is a forwarder, not a copy — it hands off to the interpreter in the base install, so Win32_Process.ExecutablePath for the process holding the port is the base path, outside the trusted set. Measured on three distributions, all identical:

Python venv Scripts\python.exe Path the port owner reports
PyManager 3.14.7 255 KB forwarder base …\pythoncore-3.14-64\python.exe
uv / python-build-standalone 3.13.15 47 KB forwarder base …\uv\python\cpython-3.13-…\python.exe
python.org MSI 3.12.10 + stdlib venv 274 KB forwarder base …\Programs\Python\Python312\python.exe

For reference the real interpreter on that host is 106 KB — the forwarder is the larger file.

Isolation proof: with the port held by the base interpreter every LOCAL_ONLY row was greyed in the main window; with a real interpreter placed at <venv>\python.exe so the listener reported a trusted path, the same build at the same commit enabled every row and the full recipe ran. One variable changed, and it was not code.

A fresh measurement at 5db5c793b contradicts the uv row of that table, so re-measure before acting on Follow-up 2. On the same host, running the probe's exact PowerShell call against the live gateway's port holder returned "…\.venv\Scripts\python.exe" "…\.venv\Scripts\python.exe" "…\.venv\Scripts\kirocrew.exe" gateway --no-open --port 5476 — the venv path, which windowsGatewayExecutablePaths already trusts. Gate 3 passed on a from-source venv build across three separate app launches, every row enabled with no footer, and <venv>\python.exe does not exist on this checkout, so the documented workaround was not in place. The distinction the table may be eliding: the launcher does delegate to the base interpreter at the Python level (sys.base_prefix points at the uv install), but Win32_Process.ExecutablePath reports the process IMAGE, which is the venv file — and gate 3 reads the latter. Either the venv has since been rebuilt by a uv version emitting a real interpreter rather than a trampoline, or the earlier reading captured a different layout. Both measurements are recorded here rather than one overwriting the other; whoever takes Follow-up 2 should settle it first, because if the venv path is reported then the false negative being fixed may not exist.

Two candidate remedies, neither in this PR:

  1. Also trust the interpreter named by the venv's own pyvenv.cfg (home / executable). Smallest change; the file already sits inside the trusted tree and needs no new privilege.
  2. Trust the spawned pid instead of the path — gateway-supervisor already owns the gateway child it launched, so "is the listener my child or its descendant?" sidesteps path matching entirely.

A packaged Windows install is unaffected: its gateway is a frozen kirocrew.exe in backend-dist with no forwarder, so the image path is the executable's own.

Covered by tests (15 node + 28 vitest):

  • serializeMenuItems classification for local + remote senders across every LOCAL_ONLY leaf.
  • executeMenuItem refusal for every LOCAL_ONLY role, submenu id, and per-item id when the sender is remote.
  • Template-walk drift pin: buildMenuTemplate output on both isMac branches, every reachable leaf classified in exactly one direction.
  • Set-shape pin on LOCAL_ONLY_ROLES / LOCAL_ONLY_MENU_IDS / LOCAL_ONLY_ITEM_IDS.
  • IPC boundary threading: menuItems and executeMenu forward senderIsLocal.
  • Cache race: source-scan pin asserting did-navigate is wired BEFORE the probe and the cache write is guarded by a generation counter.
  • Renderer: the footer keys on gated (not !enabled), so a natively-disabled row never claims a remedy that does not apply to it. One fence test asserts a gated row renders no per-row marker at all — no keyboard glyph, no struck caption — feeding it both accelerator shapes Electron can report, so a decoration returning for either fails rather than shipping.
  • Wire shape: one test asserts the serialized payload exposes no accelerator-registration field for either accelerator shape, so re-adding one has to be a deliberate decision rather than a quiet regrowth.

Failure envelope for the probe (resolveSenderIsLocal → assertLocalDashboard). The probe composes three gates: (1) sender origin, (2) local gateway URL match, (3) primary-port-owner via netstat + PowerShell. A false NEGATIVE (probe says "not local" when it is) greys the LOCAL main window's menu. Consequences: (a) fails CLOSED — no security regression, remote senders still can't reach LOCAL_ONLY leaves; (b) the physical OS accelerator (Ctrl+R etc.) is unaffected because it bypasses this IPC. A false POSITIVE (probe says "local" when it's remote) is the security-relevant direction and is what the three-gate composition + generation-counter cache write is designed to prevent — the whole point of this PR.

One correction to an earlier claim in this section, from the Windows run: a false negative does not always "recover automatically on the next did-navigate." Cache invalidation only re-runs the probe; if the underlying cause is persistent — as the source-venv port-owner mismatch above is — the re-run reaches the same verdict. It was observed to survive SPA navigation, a full sign-in navigation, and repeated app restarts. Automatic recovery holds only for a transient probe failure.

Verify recipe for a maintainer with a Windows box. From source, apply the gate-3 prerequisite above first, or run a packaged install. Then: (1) open the local dashboard and click the titlebar hamburger — every menu should be fully enabled; (2) start a second gateway on another port (kirocrew gateway --port 6789 with its own KIROCREW_HOME), open Connection ▸ New Connection Window… and give it that port, then click the titlebar hamburger in the new window — LOCAL_ONLY rows greyed with every accelerator caption rendered plain, and the footer present below the items; (3) confirm Settings (File menu) is greyed with its Alt+, caption shown plain — no per-row marker is drawn on any gated row, so the footer is the only explanation and must be present. If any of these three check-boxes fails, the PR should not merge.

Design Review Watch 2 — physical accelerator behaviour verified. On Windows, pressing Ctrl+R in a connection window reloaded that connection window's OWN dashboard; the main window was untouched. Pressing Ctrl+= zoomed BOTH windows. Tested in both directions to tell a leak from a design: Ctrl+R from the main window reloaded only the main window, and Ctrl+0 from the main window reset both — so reload is per-window while zoom is application-global, symmetric from either window rather than a connection-window leak into the local dashboard. The footer's second sentence therefore honestly says some shortcuts still work, with the caveat that for the zoom rows the action is global in scope rather than scoped to the focused window. Not a privilege path: only a user at the keyboard can produce these chords, and a remote gateway page cannot synthesise OS-level input. Verified with Win32 SendInput against each window handle, because CDP's Input domain delivers into the renderer and never exercises Electron's OS menu accelerator dispatch.

Popup geometry, re-measured at 5db5c793b with the current footer. Gated popups are 265.46px wide for File, Edit and View and 303.63px for the Connection submenu, against 223.99px (File) and 232.15px (View) for the same menus fully enabled in the main window. The footer now wraps to 2 rendered lines, and its box is 38.98px tall at max-width: 240px — two 15.13px line boxes plus 8px of padding and a 0.75px top border. Line count was taken from Range.getClientRects() over the footer's own text rather than by dividing the box height by line-height, which over-counts to 3 because the box includes that padding. Against the previously published 4 lines / 69px, both halve; the popup width is unchanged for three of the four menus.

UX Watch — first-row displacement resolved by repositioning, not by copy. The footer string went through three versions while this watch was open, each measured on Windows rather than estimated: 137 characters originally, 142 after the single-sentence rewrite, 157 once it was split back into two sentences. The rendered geometry was identical in all three — footer 69px over 4 lines at the time, gated popups 265px wide. At max-width: 240px and 11px type all three of those strings landed on the same 4 lines, so the extra 20 characters filled slack within those lines rather than spilling onto a fifth. The copy lever could not move the weight. The shipped string is shorter than all three and now renders on 2 lines / 38.98px, so the weight did eventually come down — by shortening the copy once the per-row markers were removed, not by the repositioning alone.

Moving the footer below the mapped items did resolve it, and the fix is measured on both sides rather than asserted. The first menu row's offset from the popup's own top edge is now 5px in the connection window and 5px in the main window — identical, across File, Edit, View and Connection. With the footer above the items that offset was the footer's 69px plus its margins, so a gated menu's first row sat roughly 70px lower than the same menu in the main window; that was the reviewer's "pushing Settings… ~70px down" observation and it is now zero. The footer's own height is unchanged; it simply no longer sits between the popup edge and the first actionable row. Verified by reading getBoundingClientRect() on the popup and its first button in both windows, plus a footerBelowItems assertion comparing the footer's top against the first row's. Re-measured at 5db5c793b: 4.75px in both windows, across File, Edit, View and Connection — still identical, so the repositioning holds under the current footer.

Reviewer watch — "Exit reads as enabled next to a greyed Settings…" is a perceptual artifact, not a render mismatch. quit is in LOCAL_ONLY_ROLES and the row renders gated exactly as the classification requires. Re-measured at 5db5c793b, both windows on the dracula-dark theme so the colours are comparable across the pair. Computed style on both File-menu rows, connection window against main window as control:

Window Row disabled opacity label colour pointer-events accelerator
Connection (:6789) Settings… true 0.5 rgb(248,248,242) none no caption span
Connection (:6789) Exit true 0.5 rgb(248,248,242) none no caption span
Main (:5476) Settings… false 1 rgb(248,248,242) auto Alt+,
Main (:5476) Exit false 1 rgb(248,248,242) auto no caption span

Within each window the two rows are indistinguishable in computed paint — same disabled, same opacity, same label colour — and across windows the gated pair sits at half opacity against the enabled pair at full. Exit is greyed alongside Settings, and there is nothing to fix in code.

The accelerator column is new, and it retires the watch's underlying cause rather than just re-confirming the verdict. The asymmetry that made this read as a bug was that Settings… carried a caption while Exit had nothing beside it, so the Settings row had lower average luminance. With the caption now suppressed on gated rows whose chord cannot fire, both gated rows carry no caption span at all: the two rows in the connection window are now symmetric in paint and in content. The only File-menu row anywhere with a caption is the enabled Settings… in the main window.

The perception is worth recording, because it was a reasonable read at the time. When the watch was raised, Settings… carried a dimmed caption to its right while Exit had no accelerator and therefore nothing beside it, so the Settings row had lower average luminance even though the two labels were painted identically — and "Exit" is four blocky glyphs against a longer thin-stroked string, which reads denser at the same opacity on a dark background. The disabled attribute alone could not have settled it, since a row can be disabled in the DOM and still paint at full strength if the disabled:opacity-50 variant fails to apply; it does apply. That cause is now gone at the source: on a gated row whose chord cannot fire the caption is not drawn, so the luminance asymmetry between the two rows no longer exists.

Captures 1 and 5 are the same File menu in the two windows, and both were taken at 5db5c793b, so the pair is commit-matched and the half-opacity difference is legible across it in a way it is not within either window alone. The contrast to read is caption present at full opacity (capture 1, main window) against caption absent at half opacity (capture 5, connection window). The conclusion still rests on the computed-style table above rather than on a pixel comparison, because a direct read of disabled, opacity and colour is the stronger evidence either way.

First Principles item 7 — CHROMIUM_NATIVE_CLIPBOARD_ROLES is deleted, and the measurement is kept for the record. The objection was that if Electron reports anything other than false for the clipboard roles, the generic item.registerAccelerator !== false already yields true and the whole set does nothing. Read directly off Menu.getApplicationMenu() in the main process on Windows, Electron 43.2.0:

Role raw registerAccelerator typeof generic predicate yields
cut false boolean false
copy false boolean false
paste false boolean false
pasteandmatchstyle not emitted on Windows — —

A literal boolean false in all three reachable cases, so the generic predicate returns false. The rest of the same menu is the contrast that makes Electron's reporting deliberate rather than incidental — undo, redo, delete and selectall all report true, so false lands on exactly the three chords Chromium claims natively.

While the per-row keyboard glyph existed, this special case was the only thing flipping those rows to true, and removing the set would have regressed them. The glyph is gone, so the set changed nothing a user could see and the objection — correctly rebutted while the glyph existed — became right. The acceleratorRegistered field is therefore deleted from windows-menu-model.js and from electron-bridge.d.ts, and a test pins its absence so it cannot regrow quietly. The other two did not stay deleted, and the diff says so plainly: CHROMIUM_NATIVE_CLIPBOARD_ROLES is back under the same name and acceleratorIsRegistered is back as acceleratorStillFiresFromThisWindow. Their duty is inverted — they no longer export a flag for the renderer to paint a marker from, they decide locally whether to blank a caption. Nothing crosses the IPC boundary and the renderer makes no per-row judgement. If the objection was the wire surface and the glyph, both are gone; if it was that clipboard-role knowledge exists anywhere, it does still exist, in the main process, because without it Electron's registerAccelerator: false on cut/copy/paste would blank three captions that fire. The table above is retained because the measurement is still the record of what Electron reports on Windows, and a future reader proposing the field again will want it.

pasteandmatchstyle is a separate matter and stays: it is classified in LOCAL_ONLY_ROLES, which is the enforcement set, not the deleted accelerator set. app-menu.js never emits it outside macOS, so on Windows that entry is unreachable today and defensive rather than dead — it becomes live if a Linux frameless titlebar menu ever plugs into executeMenuItem, which this PR's Windows-only enforcement rationale already anticipates.

Measured without modifying the tree: attached to the Electron main process over --inspect and read the MenuItem objects directly, rather than adding a temporary log line to serializeMenuItems. No instrumentation was introduced and none needed reverting.
Note on step 2: connection windows are always http://localhost:<port> — window-lifecycle.js builds connectionBackendUrl from a port, because a remote gateway is reached through an SSH tunnel presented on loopback. The gate trips on gate 1, the sender's origin differing from this shell's own backendUrl, not on the origin being non-loopback. An earlier version of this recipe suggested pointing the window at remote.example.test:6124 or "any non-loopback origin", which the flow does not accept.

Screenshots / video

Real Windows Electron renderer captures from the run described above. The scenario for the connection-window captures: a second local gateway on port 6789, so the connection window's origin differs from the shell's own backendUrl and assertLocalDashboard resolves senderIsLocal = false, marking every LOCAL_ONLY row enabled: false + gated: true.

1. Local main window, File menu — the enabled control for capture 5. Settings… and Exit are both at full opacity (disabled: false, opacity: 1, pointer-events: auto), Alt+, is present and rendered plain, and no footer is drawn because no row is gated. Same menu, same commit (5db5c793b), different window: read alongside capture 5, where the same two rows sit at half opacity and the Alt+, caption is absent entirely rather than struck. Those are the only two differences between the pair, which is what makes it a clean control.

01_main_file

2. Local main window, View menu — the control case. Every row enabled, no footer, no glyphs.

02_main_view

3. Connection window, View menu — all eight rows gated: true and greyed, focus-mode-toggle included (it joined the gated set from upstream during the rebase). Every accelerator caption renders plain: no keyboard glyph on any row and no strike-through anywhere, asserted as zero <svg> nodes inside the popup and zero spans whose computed text-decoration-line contains line-through. Keep on Top has no accelerator, so no caption span renders beside it. The footer sits below the mapped items, so the first row stays flush with the popup's top edge — 4.75px here and 4.75px in the main window (capture 2), which is the first-row displacement watch closed by measurement rather than by copy.

03_connection_view

4. Connection window, Edit menu — the MIXED state that pins gated against natively-disabled. Cut / Copy / Paste are gated: true (LOCAL_ONLY_ROLES) and greyed, and they KEEP their Ctrl+X / Ctrl+C / Ctrl+V captions, rendered plain. Electron reports these role items registerAccelerator: false because Chromium handles the chords natively in the focused renderer, so reading that flag alone would blank three captions that demonstrably fire — acceleratorStillFiresFromThisWindow special-cases the Chromium-native clipboard roles for exactly that reason. Verified by keystroke, not by inference: with the remote page holding focus, Ctrl+V pasted a known clipboard marker into the connection window's own composer. Undo / Redo / Delete / Select All stay enabled — sender-scoped roles, safe for a remote sender. The footer renders because at least one row is gated.

04_connection_edit

5. Connection window, File menu — the suppression, and the control for capture 1. Settings… is greyed and its Alt+, caption is absent entirely: the payload carries accelerator: "", so no caption span renders. Alt+, is the one chord in the menu that cannot fire from here — registerAccelerator: false means Electron displays it without binding it, and it is routed instead by the renderer's in-page shortcut registry, which never receives the keystroke while focus sits in a remote page. Blanking it is what makes the footer's second sentence true of every caption that remains, and it replaces the strike-through an earlier round used to say the same thing. Exit is greyed with no accelerator, so nothing renders beside it either. Read alongside capture 1, the same File menu in the main window, where both rows are at full opacity and Alt+, is present.

05_connection_file

6. Connection window, Connection submenu — the whole submenu gated: true via LOCAL_ONLY_MENU_IDS, because every entry reaches local state (config file, SSH auth, spawning windows). New Connection Window… (Ctrl+Alt+N) and Refresh Token (Ctrl+Shift+T) keep their captions, plain, because those accelerators are OS-registered and survive the gate; Rename Window… / Set Remote Host… / Open Config File have no accelerator so nothing renders beside them. Ctrl+Alt+N was confirmed by keystroke from the focused connection window — it opened the gateway-port prompt. The macOS-only "New Window" (Cmd+Shift+N) entry is absent because buildMenuTemplate only emits it on macOS. This popup is the widest of the four at 303.63px, set by its longest row rather than by the footer.

06_connection_connection

7. Local main window, View menu, gate 3 refusing — the greyed MAIN window UX Review asked for by name. All eight View rows are gated: true and greyed and the footer renders in the main window, which is the finding rather than the backdrop: the copy tells the user items are unavailable "here" while "here" is the main window. The string was written for a connection window, where the main window genuinely is the way out; in this state it names no cause and offers no next step. Reached by holding the primary port with a process outside windowsGatewayExecutablePaths' trusted set, so gate 3's probe proves a FOREIGN holder and revokes the earned positive at once. The connection-error banners behind the popup are unavoidable: a greyed main window requires its own gateway to be gone.

07_main_view_greyed_foreign_holder

8. The refusal notice, with the menu still open. A refused click on File ▸ Settings… renders the notice naming the row that did not run — "Settings…" did not run. Use this command from your main Kiro Crew window. — while the popup stays open, so the overlap between the notice and the menu is visible. Settings… and Exit are both greyed behind it and the footer sits below them, so all three new surfaces are in one frame.

Reached with no source change. A gateway run from this branch serves the window, so the menu's first open mints a positive locality verdict; the port's LISTEN owner is then replaced by a foreign process; the next open paints the rows from that cached positive while the click itself re-resolves strictly and refuses. That is the designed sequence rather than a staged one — the refusal is answered back to the renderer, which refetches app-menu:items, and the rows repaint greyed with the footer.

Two honest notes on what else is visible. Gateway offline — message will not send appears in the composer because the stand-in holder is not a Kiro Crew gateway; it is a side effect of the same staged port owner, not the cause of the refusal, which comes from gate 3 classifying the holder as foreign on a real click. And the stand-in has to answer HTTP at all: createBackendProbe passes on any status below 500, and a holder that merely drops connections makes the liveness monitor navigate the top frame to the loading page — which fires did-start-navigation, invalidates the cached positive, and removes the dashboard the menu lives on. The frame is cropped to the application window.

pr13040-refusal-notice-cropped

Why this capture is not the grace-expiry path, and why no screenshot of that path exists. The same pixels are reachable in theory by letting the paint grace lapse — POSITIVE_VERDICT_TTL_MS (5s) + INCONCLUSIVE_PAINT_GRACE_MS (30s) after the last minted positive, with the port UNBOUND so the probe returns none and lands in INCONCLUSIVE_PORT_OWNERS. That state was measured but could not be photographed, for two independent reasons. First, in normal operation it never arrives: the shell's liveness recovery respawns the gateway, a fresh probe returns local, and the positive is re-minted, restarting the clock — observed directly, where the IPC reported all eight rows gated and the rendered popup one second later showed all eight enabled again. Second, when recovery cannot succeed, the shell replaces the dashboard with its "gateway failed to start" screen at roughly t+33s — before the 35s boundary — so no titlebar survives to open. Three attempts were made, including one that polled by opening the menu so detection and shutter were the same action. The boundary itself was verified separately by polling app-menu:items after the gateway died, with the rows greying at t+34.9s against the 35s the two constants predict. So the grace is a restart cushion that demonstrably works; it is not a state a user lands in, and the foreign-holder route above is the realistic way to reach a greyed main window.

The three HTML mockups previously in this section are superseded by the captures above and have been removed.

Related Issues

no linked issue: standalone pre-flight security hardening carved out of the design discussion around #10247.

Sibling sweep

The defect this round's last fix addressed was textual: several places asserted that the DevTools row starts hidden, and therefore that the gate stops a remote showing it. eceb35e995 (#24810) had flipped that row to visible: true, so the row is always offered and the capability the gate actually protects is a remote hiding it. Every site of that claim:

  • Sibling: website/electron/ipc-registrar.js -- changed here
  • Sibling: website/electron/test/ipc-registrar.sender-locality.test.js -- changed here
  • Sibling: docs/build/desktop-app.md -- changed here
  • Sibling: website/src/shell/platform/electronBridge.ts:24 -- not affected -- its wording is explicitly about a desktop shell older than this dashboard, which does build the item hidden, so the sentence stays true and the file is outside this PR's diff
  • Sibling: website/electron/test/app-menu.test.js:229 -- not affected -- it asserts the devtools-toggle item exists without asserting its visible value, which is why feat(settings): merge the Developer page into Settings > Developer #24810 could invalidate the premise with nothing going red; named as the mechanism rather than widened into this PR

This description carried the same claim in ## What changed and in a ## Tests bullet; both are corrected above.

Pattern harvest

Rule candidate: agents-md
Pattern: a runtime policy expressed as "membership in one of N sets" needs a template-walk drift pin as well as a set-shape pin. The set-shape pin catches changes to the sets themselves; a template-walk pin walks the source structure the sets classify and asserts every reachable leaf is in exactly one direction. Missing the template-walk half is how a new item added to app-menu.js would inherit remote-safe on execute without a classification decision (the exact gap Spock's TEST-01 documented against an earlier draft).

Rule candidate: agents-md
Pattern: a UI affordance that makes a claim about a platform mechanism ("this shortcut still works") cannot be validated by reading the source that renders it — only by running it on the platform. The glyph condition here (gated && accelerator && acceleratorRegistered) was correct in code and correctly documented, yet the mockups derived from it were wrong for the clipboard roles, because registerAccelerator for a role-based item is decided by Electron at runtime rather than by the template that declares it. Source-derived mockups should be labelled as predictions and any claim they encode re-checked on first real run.

Follow-ups

Two items called out by review lanes are out of scope for this PR and are tracked here for a follow-up change:

  1. Ungated non-menu preload channels (First Principles Item 10, Design Review Watch 1). Six channels — update:check, update:download, update:install, update:set-channel, update:set-auto-download, local-gateway:set — remain reachable by a remote sender without assertLocalDashboard. update:install in particular reproduces the exact quit-harm this PR fences on the menu path. The next change should extend assertLocalDashboard (or an equivalent origin+loopback+port-owner check) to those channels so the "attack surface is single" phrasing is true for the whole preload boundary, not the menu alone.

  2. Gate-3 false negative for from-source Windows venv builds (Design Review Watch 2). windowsGatewayExecutablePaths trusts <venv>\Scripts\python.exe on the assumption it is the interpreter; on Windows it is a forwarder that delegates to the base interpreter, whose path is outside the trusted set. Two candidate remedies:

    • Also trust the interpreter named in the venv's own pyvenv.cfg (home / executable).
    • Trust the pid instead of the path — gateway-supervisor owns the gateway child, so "is the listener my child or its descendant?" sidesteps path matching entirely.

    Both are non-trivial changes to windows-port.js that would benefit from being landed on their own so the fix has room for its own Windows verification.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — in-source comments in windows-menu-model.js and ipc-registrar.js explain the load-bearing gate rationale
  • No secrets, credentials, or internal references in the diff

@josej4m
josej4m requested review from a team and patrigao September 23, 2026 08:31
@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Sep 23, 2026
@josej4m

josej4m commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Intent: Add a per-action security gate at the Electron app-menu:* IPC boundary so a remote gateway page loaded in a connection window cannot invoke privileged menu roles (paste/quit/close/minimize/zoom/togglefullscreen) or custom-click items (DevTools toggle, Settings, About) that reach local OS state.
Not a goal: extending the gate to Linux/macOS native menus (their attack surface is architecturally different and already mitigated by focusedDashboardWebContents() resolution and the absence of a renderer-invocable menu API); reworking the wider assertLocalDashboard origin check.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Sep 23, 2026
@josej4m
josej4m force-pushed the security-per-action-menu-gate branch from d49f6a5 to 4e33bf0 Compare September 23, 2026 08:41
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of 2a81d372d3e3be5aac59ffe3844260f030f8da47 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing the refused-click notice at this revision. The only image of it (attachment-08) shows different copy and no "Ask the agent" button, so the notice that actually ships has not been shown.

Evidence gaps

  • Refused-click notice (app.titlebar_menu_refused_notice rendered through ErrorNotice with askAgent and a dismiss control). The diff ships "“{{item}}” did not run. It is unavailable here right now." with an "Ask the agent" action. Attachment-08 shows "“Settings…” did not run. Use this command from your main Kiro Crew window." with only a ✕, and its footer reads "Some items work only in the main window." Neither string is in this diff, so that image is from another revision and does not close the gap. To close it, attach a screenshot at this revision of the notice after clicking a gated item, with the Ask-the-agent button and the dismiss control visible.

Notes

  • titlebar_menu_refused_notice loses the next step the earlier copy had. "It is unavailable here right now" doesn't say where the command does work. Restore the wording seen in attachment-08: "Use this command from your main Kiro Crew window."
  • titlebar_menu_disabled_footer "Some items are unavailable here." The word "here" is vague. Attachment-08's "Some items work only in the main window." tells the user where to go.
  • askAgent on a refusal the app makes on purpose: the agent can't lift the block, and the hand-off pulls the user out of the window they were in. Drop askAgent for this notice.

[UX-REVIEWED] 2a81d37

Description read

[DESCRIPTION-READ] 35ff4e9ddb2a98eec54f71f7e0c1020addeaa457f2dd82bf184975c7ba26c4b6

That sha256 names everything this verdict read: the PR description, plus the 11 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 2a81d372d3e3be5aac59ffe3844260f030f8da47 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks: the per-action fence is a derived fix at the untrusted-remote-content boundary. The trouble is the extra paint machinery stacked on top of it.

Notes

  • Item 5 — oversized: the rows are painted from an expired verdict ("paints from the last positive… while a re-probe runs in the background"). Because of that, the PR also needs INCONCLUSIVE_PAINT_GRACE_MS, senderProbeInconclusive, the send→invoke answer, the refetch on refusal, the ErrorNotice for a refused row, acknowledgesDispatch to detect old shells, and clickInFlightRef. Subtraction: have app-menu:items await resolveSenderIsLocal, which already has a 5s cache, and delete that whole stack.
  • Item 8 — rides along, one consumer, generalized: the new "unidentified" owner value is treated differently from "foreign" in only one place, INCONCLUSIVE_PORT_OWNERS (ipc-registrar.js). Elsewhere it is mapped back to the old meaning: holder-decision.js:460 and gateway-auth-hint.js:57 treat it as foreign, and successor-handoff.js:281 adds it to the unknown refusal, which changes that refusal's message. Subtraction: deleted along with item 5.

What this change ships

Inventory (10 items) — 8 justified

Intent: keep a remote gateway page in a connection window from using the Windows titlebar menu to drive local privileged actions. FIX.

  1. A remote sender's local-only menu clicks (clipboard, quit, window controls, DevTools, Settings, reload, zoom) are refused — justified
  2. Those rows are greyed for a remote sender, with a footer explaining why — justified
  3. Greyed rows hide shortcut captions that can't fire from that window — justified
  4. Menu items get stable ids, and a drift test pins the three LOCAL_ONLY sets — justified
  5. Rows painted from an expired verdict; refused clicks re-fetch the menu and show an error notice — oversized
  6. Ownership verdict cached for 5s, one probe at a time per window, cleared on navigation — justified
  7. Gate-rejection log lines throttled per sender — justified
  8. New "unidentified" port-owner classification across the gateway files — rides along
  9. Remote senders can't flip the DevTools row's visibility — justified
  10. desktop-app.md section and i18n strings — justified

[FIRST-PRINCIPLES-REVIEWED] 2a81d37

Description read

[DESCRIPTION-READ] c8376d9a66ba1e353d9b5550a32baeff50b9d4c4dc54d4884cc4fdeb4047eed7

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 2a81d372d3e3be5aac59ffe3844260f030f8da47 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design problem blocks this: the per-action gate sits at the only renderer-reachable menu path and fails closed. The risks below can all be reversed.

Notes

  • This PR causes the main-window greying on Windows source-checkout builds; the "Not a goal" calls it pre-existing. On base, app-menu:* had no assertLocalDashboard gate, so Settings, Reload, Copy/Paste and Quit worked there. Now gate 3 classifies the venv gateway as foreign and those rows grey for the whole session. Say so in the description.
  • About 600 lines of per-WebContents verdict state (TTL, paint grace, inconclusive mark, generation guard, coalescer, log throttle, focus re-check) exist only because gate 3 runs a netstat/PowerShell probe on every click. The supervisor already tracks the adopted gateway's ownership (setGatewayOwnership, refreshed in reconnect.js). Reading that state instead of re-probing would remove most of this machinery.
  • ipc-registrar.js grows from 1,157 to about 1,750 lines, past the 1,600-line split threshold. The sender-locality verdict is a separate responsibility and belongs in its own module.

[DESIGN-REVIEWED] 2a81d37

Description read

[DESCRIPTION-READ] 80a3f239605a02057eaba3d3316485a3d9b0c2612416572f491ad3da478446d4

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — 🔴 changes requested (blocking)

Reviewed 2a81d372d3e3be5aac59ffe3844260f030f8da47 via the fork AI-review pipeline; updated in place on each push.

1 of 2 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

BLOCKING -- website/electron/ipc-registrar.js:766 -- Compare the focused WebContents before delayed dispatch

if (windows.focusedDashboardWindow() !== focusedWindowAtRequestTime) {
Trigger: Click Reload during a pending ownership probe, then press Ctrl+Alt+N and enter a connection port before the probe completes. focusedDashboardWindow() returns the main window both before and after the modal gains focus, so this check passes.
Outcome: executeMenuItem invokes Reload, whose focusedDashboardWebContents() now returns the modal. The dialog reloads instead of the dashboard, discarding the entered port.
Anchor: residual/crash-data-loss-corruption
Fix: Capture and compare focusedDashboardWebContents() across the await, refusing dispatch when the target changes.

BLOCKING -- website/src/components/WindowsTitlebarMenu.tsx:307 -- The shell-wide hand-off discards unsaved page drafts

askAgent
Trigger: With unsaved OAuth client inputs under Settings → Connections, an inconclusive ownership probe refuses Zoom In and displays this notice. Clicking Ask the agent follows AskAgentButton → sendErrorToChat → /chat; neither the OAuth forms nor ConnectionsPage registers a leave guard.
Outcome: Navigation unmounts ConnectionsPage, destroying its page-local draft store and the unsaved OAuth inputs without confirmation.
Anchor: errors-use-error-notice
Fix: Leave askAgent off for this shell-wide notice, or enable it only when the active page’s drafts are protected.

[BLOCK-MERGE] 2a81d37
[GPT-REVIEWED] 2a81d37

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F2: This finding is tied to the rule errors-use-error-notice, and that rule is marked blocking: true in the base snapshot (.review-base-rules/website-AUTOSDE.yaml:675-676). That flag overrides any weighing of harm against fix cost. The changed line askAgent (patch 4969, which is WindowsTitlebarMenu.tsx:~307) turns the hand-off on for a notice that covers the whole app shell. The rule allows that only "wherever the hand-off cannot destroy anything" (website-AUTOSDE.yaml:681-682).
The fix is cheap: drop one prop, or turn it on only when the active page's drafts are protected.

F1 (fenced): The netstat probe can take up to 10 s per attempt, with retries (windows-port.js:298-317, 394). That is long enough for a person to open the connection modal and type a port before the probe finishes. The check at patch line 890 compares windows (focusedDashboardWindow()), not WebContents, so the claimed combination is plausible in real use. I can't build the rarity argument a FLAG needs.

[ADJUDICATION] 2a81d372d3e3be5aac59ffe3844260f030f8da47 total=1 uphold=1 downgrade=0
UPHOLD F2 website/src/components/WindowsTitlebarMenu.tsx:307 reason=autosde-blocking-rule
[GPT-ADJUDICATED] 2a81d372d3e3be5aac59ffe3844260f030f8da47

[ADJUDICATION-FENCED] 2a81d372d3e3be5aac59ffe3844260f030f8da47 fenced=1 flagged=0
UPHOLD-FENCED F1 website/electron/ipc-registrar.js:766 -- The probe can run up to 10 s per attempt with retries (windows-port.js:298-317), which leaves real time to focus the modal and type a port, and the check compares windows rather than WebContents, so the race is plausible in normal use.
[GPT-ADJUDICATED-FENCED] 2a81d372d3e3be5aac59ffe3844260f030f8da47

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 2a81d372d3e3be5aac59ffe3844260f030f8da47 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 2a81d37

@josej4m
josej4m force-pushed the security-per-action-menu-gate branch 2 times, most recently from cb4c402 to 1f38294 Compare September 23, 2026 10:24
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 23, 2026
@josej4m
josej4m force-pushed the security-per-action-menu-gate branch from 1f38294 to fb3e319 Compare September 23, 2026 10:47
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 23, 2026
@josej4m
josej4m force-pushed the security-per-action-menu-gate branch from fb3e319 to 9ef4081 Compare September 23, 2026 10:58
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 23, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

@iamwhatever your review is pinned to b7c1c1a, and that head is the locale-only merge. 9ab7b8abd1 landed four minutes after it and changes the code for both of buluoray's blocking points. Details are in this comment. Two spots where it differs from what you asked:

  • TTL, not event-only invalidation. The 5s TTL stays, but painting no longer waits on it. app-menu:items paints from the earned positive and re-probes in the background. Event-only invalidation would need a hook for adopted gateways, and the supervisor sees those exit only through the liveness monitor. The TTL already covers that case with no new wiring.
  • unknown keeps the paint, not the authority. I first reused the last positive for actions on unknown, as you suggested. A local model-pinned GPT review flagged it as BLOCKING, and it was right: a probe that fails while a foreign listener holds the port would hand clipboard read and DevTools to that listener. On unknown/none the rows now stay enabled, but a click is refused until a probe returns kirocrew/service. After 35s of inconclusive probes the rows grey with the footer.

Tests for an unknown probe and a probe with no named owner are in ipc-registrar.test.js. I added no venv-shaped owner test. The venv false negative sits in windows-port.js, upstream of this PR, and the description lists it under Follow-ups.

Your owner decision (keep per-action, drop the glyph and strike-through, keep a short footer) is not applied yet. That is a visible UI change, so I am leaving it for the author or a maintainer to confirm.

@josej4m

josej4m commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 thank you for both pushes — the merge that cleared the conflict, and the paint/probe fix. Two things you should know, the first because it undoes a courtesy you deliberately extended.

I rebased the branch, so your commit has a new SHA. You wrote "no rebase, no force-push" twice, and I have now done the opposite to your work, so I would rather state it than let you discover it. Your fix is byte-identical after the replay — git diff between 9ab7b8abd1 and the new commit across ipc-registrar.js and its test is empty — and you are still its author. Only the SHA moved.

The reason is the gate your merge commit tripped. Enforce commit count says it itself: "do not merge $BASE_REF into your branch. Both add a merge commit, which counts here and will re-trip this check. Then squash your own commits." At 3 commits it was red. Changelog History Gate was red too, because the merge ref carried upstream's rewritten [0.8.0] while pull_request.base.sha predated it — which skipped every heavy job and took Coverage Gate down with it. Rebasing onto current main (78 commits) clears both: 2 commits, base current, zero behind.

The rebase exposed one defect, and it is the merge-order hazard you flagged in triage. Upstream added a View item focus-mode-toggle and the template-walk pin went red with it unclassified. toggleFocusMode sends focus-mode:toggle to focusedDashboardWindow(), so it reaches the local user's focused dashboard rather than the sender — the same focus-scoped shape as reload and the zoom items. It is now in LOCAL_ONLY_ITEM_IDS and declared in the membership pin. The View menu greys eight rows rather than seven.

@iamwhatever's owner decision is applied. Per-action design kept, glyph and strike-through dropped, footer short. The footer states both halves — the rows are unavailable here, and some keyboard shortcuts still work — because Electron's native accelerator dispatch bypasses the app-menu IPC gate, so Ctrl+V genuinely still pastes from a greyed Paste row; a footer implying otherwise would be the dishonest version. One renderer test pins the absence of any per-row marker for both acceleratorRegistered values.

One question back. CHROMIUM_NATIVE_CLIPBOARD_ROLES existed only to flip the glyph on for Cut/Copy/Paste, and acceleratorRegistered now has no renderer consumer. First Principles' original "dead code" objection to that set — which this PR's body refutes with raw Electron values — is now correct. Do you want the set and the wire field removed? It reaches windows-menu-model.js and its wire test, so I would rather you decide than widen the diff unasked.

Screenshots and the footer geometry are stale; I am re-capturing on Windows along with the behavioural checks your fix needs — paint-without-waiting, a refused click on an inconclusive probe, and the 35s boundary — since you noted you have no Windows machine.

Locally green: electron 2499 tests / 0 fail, renderer 28/28, tsc, i18n:check and lint:i18n all clean.

The force-push will re-arm the fork approval gate, so the five workflows will need approving again when you have a moment.

— AI comment by Agent(Cyborg)

@josej4m

josej4m commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Status, and one ask.

Since my last comment the branch moved twice, both times by amending my own commit, so @bolichen97's commit has a new SHA again: 9ab7b8abd1 → 1cbc61fcd → 64f5fab8c → 5db5c793b. It is byte-identical at every step — git diff 9ab7b8abd1 HEAD across ipc-registrar.js and its test is empty, same 263/23 stat — and still authored by you. You asked for no rebase twice and I have now done it three times; stating it rather than leaving you to notice.

First Principles' blocker. It asked for three deletions. The wire field acceleratorRegistered is deleted and a test pins its absence. The other two are back with their duty inverted: CHROMIUM_NATIVE_CLIPBOARD_ROLES and acceleratorStillFiresFromThisWindow now decide locally whether to blank a caption, rather than exporting a flag for the renderer to paint a marker from. Nothing crosses the IPC boundary and the renderer makes no per-row judgement. That lane is now CONCERNS.

UX's footer. It blocked the two-sentence footer as too vague, then blocked the one-sentence footer as wrong advice. The resolution is subtraction rather than annotation: a gated row whose chord cannot fire now ships accelerator: "", which is File > Settings… alone, so the footer can say "Some items are unavailable here. The shortcuts shown still work." without naming a set the reader has to discover by trial. No per-row marker, per @iamwhatever's ruling.

First Principles item 5, with the number it asked for. The port-owner probe costs 594–739ms on Windows across five runs, powershell.exe accounting for 523–585ms of each against 68–154ms for netstat. Menu rows arrive at 103ms on a fresh positive, 122ms inside the grace, and 903–1191ms past the 35s boundary — where ArrowDown moves nothing, since no row is mounted yet. So the cache layers buy an order of magnitude, and the latency premise they were built on holds.

The ask: please re-run the fork-ux-review workflow. All seven captures are re-taken at 5db5c793b, none carried over, and Screenshot Evidence passes on them. But UX's verdict was formed before those captures existed, and fork-ux-review.yml triggers only on Fast Gate completing, which does not fire on a description edit. A force-push would re-trigger it — at the cost of re-arming the approval gate over 89 passing checks, re-rolling two Windows flakes that have already cost this PR a cycle each, and moving your SHA a fourth time. The re-run is one click and keeps all of it.

On UX's two Watch items, they conflict with each other. Watch 1 wants the footer to name the main window as the remedy; Watch 2 observes that the footer renders in the main window when gate 3 cannot confirm the gateway, and capture 7 is a photograph of exactly that. The shipped string is the only wording true in both states, so I would rather say so than patch one and break the other.

— AI comment by Agent(Cyborg)

@bolichen97

Copy link
Copy Markdown
Contributor

@iamwhatever @buluoray could you re-review at 5db5c793b? Both of your CHANGES_REQUESTED reviews predate this head.

What changed against the two blocking points:

  • Blocking 1 (menu waits on the probe): app-menu:items now paints from a positive earned in the last 35s and re-probes in the background. Clicks still never use a lapsed positive. Measured on Windows: rows at ~103ms on a fresh positive, ~122ms inside the grace, but 903-1191ms when the menu is opened after more than 35s idle.
  • Blocking 2 (local menu greys on a probe hiccup): an unknown/none probe keeps the rows painted enabled for up to 30s. It never authorizes an action.

One open point for you to weigh: during that inconclusive window the main window's Paste/Quit/Settings rows look enabled, but a click is refused with no feedback. Before this PR the main window's menu did not depend on the port probe at all. Please say whether that is acceptable or needs a change before merge.

UX Review is red because its verdict was formed before the new screenshots were added; it needs a re-run of fork-ux-review, not a code change.

iamwhatever
iamwhatever previously approved these changes Oct 19, 2026
@josej4m

josej4m commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased and force-pushed — the PR had gone CONFLICTING against main, so it could not merge as it stood.

New head for review: 08f422bf7fee5cb9576e131c84779bd9695de4fb

The conflict was in website/src/components/WindowsTitlebarMenu.tsx. Upstream #20330 replaced the createPortal(..., document.body) call with an <OverlayPortal> wrapper (and added a lint rule refusing new document.body portals); this branch adds the disabled-item footer legend immediately inside the element that commit rewrote. Resolved by keeping the footer and adopting upstream's wrapper. An earlier wave also produced tail collisions in the locale catalogs, where upstream's release_notes_not_published_yet and this branch's titlebar_menu_disabled_footer were appended to the same block — both keys kept, no translations altered.

@bolichen97's commit was replayed byte-identical (same 263/23 diffstat, authorship intact); only the base and the SHAs moved.

-- AI comment by Agent(Cyborg)

@josej4m

josej4m commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Force-pushed again — Frontend Lint & Type Check failed the file line cap gate: website/electron/test/ipc-registrar.test.js had grown to 2,273 lines against the 2,000-line cap, and the file is not baselined.

New head for review: cb31d4f18a

Split rather than baselined, per AGENTS.md. The resolveSenderIsLocal suite — its three gates, the verdict cache and the app-menu channels that exercise it — moved to website/electron/test/ipc-registrar.sender-locality.test.js (16 tests), and the shared harness scaffolding to website/electron/test/ipc-registrar-test-helpers.js, following the auto-update-test-helpers.js pattern. ipc-registrar.test.js keeps the remaining 42 tests and drops to 1,110 lines; no test was added, removed or altered, and the electron suite is unchanged at 2,801 tests with 0 failures.

@bolichen97's commit replayed with the same 263/23 diffstat and its ipc-registrar.js changes byte-identical; its five test additions now land in the new file, since they sit inside the moved region.

-- AI comment by Agent(Cyborg)

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes at cb31d4f.

Thanks for the follow-up commit. Painting from a lapsed positive, refusing clicks on an inconclusive probe, revoking on a proven foreign holder, and the reworded footer all move in the right direction, and the new tests pin each one: mutating each new guard turned a test red. Two gaps remain, one under each earlier blocking point.

Blocking 1, partly cleared: past 35 seconds the menu still waits on the probe

resolveSenderIsLocalForPaint paints from the last positive only while positiveIsPaintable holds (website/electron/ipc-registrar.js:355-359), which is POSITIVE_VERDICT_TTL_MS + INCONCLUSIVE_PAINT_GRACE_MS, 35s from the last mint. After that the paint awaits the full probe (ipc-registrar.js:503). In a harness test with a probe that never settles, a paint after 10s returns at once, and paints after 36s, 60s and 300s all wait. The Windows measurements in the description agree: rows land at 903 to 1191 ms on every open taken more than 35s apart. Most menu opens come after a gap longer than 35s, so the local Windows user still sees an empty popup for about a second on most opens, and ArrowDown has nothing to land on.

To clear: separate the paint lifetime from the inconclusive grace. For example, paint from the last positive at any age with a background re-probe, and drop it only on navigation or a proven foreign holder; the grace then applies only when the latest probe was inconclusive. Alternatively, paint from gates 1 and 2 alone and keep gate 3 on the execute path, as Design Review suggests. Add a test with a gap well past 35s and a probe that never settles.

Blocking 2, partly cleared: a failed command lookup still counts as a foreign holder

unknown and none are now inconclusive (ipc-registrar.js:341), but the case the comment at ipc-registrar.js:333-334 names, a PowerShell timeout, produces neither. When the netstat step succeeds and both the PowerShell and WMIC lookups fail, windowsProcessCommand returns an empty string (website/electron/windows-port.js:243), and classifyPortOwner then reports foreign (website/electron/gateway-stop.js:801-813). settleProbeOutcome drops the positive and the local main window greys at once, with no grace. A direct run confirms it: a failed exec gives an empty command, which is classified as foreign.

To clear: classify a holder whose command line could not be read as unknown, at least on the app-menu path, with a test. For the from-source venv owner that the description confirms greys every LOCAL_ONLY row in the main window: either fix the trust here (the pyvenv.cfg route in Follow-up 2 looks small), or state in the description that this build is an accepted break for this PR and add a test with a venv-shaped owner that pins the chosen behaviour.

Non-blocking, still open

  • Two mutations still stay green: removing the generation guard (ipc-registrar.js:329), and defaulting executeMenuItem to local (website/electron/windows-menu-model.js:261).
  • The classification is still a deny list (windows-menu-model.js:169-172), so an unknown leaf defaults to allowed.
  • docs/build/desktop-app.md still does not describe the app-menu gate next to the wsl:detect and folder-picker gates.
  • UX Review on this head: put the footer max-w-[240px] on an inner span so its top border spans the popup.

Checked and fine

The rebase onto ea45e802e9 (glyph removal, footer rewording, the focus-mode-toggle fence, the empty caption for gated rows whose chord does not fire, the test split). Related test files pass on this head (ipc-registrar 42, sender-locality 16, windows-menu-model 16, titlebar contract 5, WindowsTitlebarMenu 28). The one CI failure, Backend Tests (Windows) (1) in test/test_ci_ipv6_routing.py, is the known flake #21943 and unrelated to this diff.

Not run on Windows. Blocking 2 is from source plus a direct run of the classifier; for Blocking 1 the description's own Windows timings back the harness result.

@josej4m

josej4m commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 Blocking 1 sits in your commit rather than mine — positiveIsPaintable, INCONCLUSIVE_PAINT_GRACE_MS and resolveSenderIsLocalForPaint (website/electron/ipc-registrar.js:353-359 and 495-503) all come from "paint the titlebar menu without waiting on the port probe", so there's nothing in my commit to amend for it.

The ask is to separate the paint lifetime from the inconclusive grace: paint from the last positive at any age with a background re-probe, drop it only on navigation or a proven foreign holder, and apply the 30s grace only when the latest probe was inconclusive — plus a test with a gap well past 35s and a probe that never settles.

AGENTS.md caps this PR at two commits so a third isn't an option. Would you rather push that yourself, or shall I amend your commit? Happy either way, just say which.

Blocking 2 is addressed on my commit locally and goes up with the next push: an unreadable command line now classifies as unknown rather than foreign in classifyPortOwner, and the from-source venv trust gap is pinned as an accepted break with the pyvenv.cfg route left as a follow-up.

-- AI comment by Agent(Cyborg)

@josej4m

josej4m commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased and force-pushed — the PR had gone CONFLICTING against main again.

New head for review: 934946a45a754e96f29fe652c71db6682d987a45

The conflict was in website/electron/test/ipc-registrar.test.js. Upstream #12204 added close-action:get/set tests to the inline harness scaffolding this branch had extracted into website/electron/test/ipc-registrar-test-helpers.js. Resolved by keeping the helpers require, taking upstream's new tests, and porting their two harness additions into the helpers file. No test was altered.

@bolichen97 your commit's content changed this time, not just its SHA

The three earlier rebases replayed it byte-identical. This one does not, for three reasons:

  1. Blocking 1 is now amended into it. You asked on 19 Oct whether you should push it or I should amend; there was no reply, so I amended rather than leave the PR blocked. The paint lifetime is now separate from the inconclusive grace: app-menu:items paints from the last positive at any age with a background re-probe, drops it only on navigation or a proven foreign holder, and applies the 30s grace only when the latest probe was inconclusive. Tested with a gap past 35s and a probe that never settles.
  2. The dev-mode-changed fix lives in your commit because it consumes senderProbeInconclusive, which your commit introduces. Putting it in the parent left that commit calling an undeclared symbol — broken in isolation.
  3. Five app-menu:execute call sites in your paint tests moved from the listener list to the handler list, because that channel is now request/response (below).

Your commit is 554/25 where it was 263/23. Authorship and the 8 Oct date are intact, and each commit passes the electron suite alone.

Blocking 2, and three security defects it surfaced

Blocking 2 asked that a probe hiccup not grey a local menu. Classifying an unreadable command line as unknown did that, but unknown already meant the probe never ran, and three consumers read that as safe:

Site Consequence
holder-decision.js adopt → mintLocalToken() posts .local_secret to an unnamed LISTEN holder
gateway-auth-hint.js retries the local mint 3× against the same unnamed holder
successor-handoff.js waits instead of refusing the handover

Fixed with a distinct unidentified value rather than a widened guard, because the probe never ran must keep failing open while a holder exists but cannot be named must fail closed. unidentified is now in the port-owner-self-asserted-identity pin's vocabulary, so a future consumer that branches on it without claiming the branch fails CI.

The open feedback point is closed

You flagged that during the inconclusive window a row looks enabled but the click is refused with no feedback, and asked whether that was acceptable before merge. It is now answered in code: app-menu:execute is request/response, and on a refusal the renderer refetches app-menu:items and re-renders. The refused click's own probe has by then dropped the stale positive, so the rows grey and the existing disabled-item footer explains why. No new UI surface and no new string.

One residual, disclosed in docs/build/desktop-app.md: inside the 35s grace a refusal from an inconclusive probe keeps the positive, so the repaint shows the same enabled rows. Greying there would re-break Blocking 1.

dev-mode-changed

This channel was ungated upstream and this PR gated it. An inconclusive probe no longer reads as a refusal, since a probe only reaches inconclusive after the sender is already proven to be the local dashboard on a local gateway — the single unproven fact is who holds the port, and the row it reveals is still gated per action by app-menu:execute. A window with a remoteHosts record stays gated deliberately: it is pointed at a remote gateway, so "Developer mode" there is a remote preference asking the local shell to expose local DevTools.

Electron 3,015 tests / 0 failures; website 3,439 files. merge-tree clean against main.

-- AI comment by Agent(Cyborg)

@josej4m

josej4m commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Pushed the two GPT 6.1 Review findings.

New head for review: d29a051bbf546aeeb4a38e43ce7b2449a3efceec

F1 — app-menu:execute became request/response in this PR, so the custom click handlers in window-lifecycle.js (reload, forceReload, toggleDevTools, the three zoomMenuItem actions) resolved focusedDashboardWebContents() at dispatch time, after the await. Focusing another window mid-probe sent the action to the wrong one. Now captures the focused WebContents before the await, compares by identity after it, and declines on a mismatch.

F2 — a refusal inside the inconclusive paint grace was silent: the row stayed enabled and nothing explained why. Now surfaces an ErrorNotice, per the errors-use-error-notice rule in website/AUTOSDE.yaml.

Also rebased onto main (163 commits). @bolichen97's commit is unchanged at 554/25 — same content as the last push, new SHA only.

-- AI comment by Agent(Cyborg)

@josej4m

josej4m commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main to clear a merge conflict in website/electron/test/ipc-registrar.test.js.

The conflict was move-versus-modify: this PR extracts that file's shared constants and harness into ipc-registrar-test-helpers.js, and #25058 edited inside the extracted region. That change is carried forward rather than dropped — the two first-run:* remote-crew channels and the canSwitchToRemoteCrew / switchOutcome harness options now live in the helpers module, the channel-count assertions move to 44 and 45, and its four refusal tests are unchanged at the same seam.

New head: 7ac18db1c2d5a85e880e8dfb6e2da5facd914693 (was d29a051bbf546aeeb4a38e43ce7b2449a3efceec)

@bolichen97's commit is unchanged — 554/25, identical patch-id, new SHA only from the replay.

@josej4m

josej4m commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Pushed the one finding both review lanes blocked on.

Opus 5.5 and GPT 6.1 flagged the same defect independently: this PR made executeAppMenuItem answer, so a desktop shell older than the gateway serving the dashboard — whose bridge is still a fire-and-forget send returning undefined — read every click as refused and showed a notice for commands that had in fact run. The renderer now classifies the answer by shape: a non-thenable answer is the legacy bridge and counts as dispatched, strict true is required only of a bridge that acknowledges, and a missing method still refuses.

docs/build/desktop-app.md updated to match — it still described a grace-period refusal as silent, which the refusal notice changed.

New head: a7785f58694ac8f0b194661090697f4f089a5543 (was 7ac18db1c2d5a85e880e8dfb6e2da5facd914693)

Also rebased onto main (13 commits). @bolichen97's commit is unchanged — 554/25, identical patch-id.

@bolichen97

Copy link
Copy Markdown
Contributor

@josej4m thanks for the latest push. One blocker is left on head a7785f5869: the GPT 6.1 Review security finding at website/electron/ipc-registrar.js:722.

When a WebContents switches from a local page to a remote one while the old page's locality probe is still pending, the remote page can join that probe. If it settles as unidentified, settleProbeOutcome records it as inconclusive even though its generation is stale, and the soft check then passes against the remote page's own generation. The remote page can then call windows.menu.setDevMode(false) without its own locality being checked.

The finding is security-class, so it can't be overridden. It needs a code fix:

  • settle an inconclusive outcome only for the navigation generation that started the probe, and
  • make a caller that finds an older in-flight probe run a fresh locality check instead of joining it.

A test for that sequence (navigate local to remote mid-probe, probe returns unidentified, then setDevMode(false) is refused) would pin it.

@buluoray's two points from the 10-20 review are still open as well.

@josej4m

josej4m commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Heads up before the next force-push: this round changes the content of
bolichen97's commit for the first time.
It has been byte-identical through
four previous rounds, so flagging it rather than letting the moved SHA be a
surprise.

What forced it. The pre-push GPT lane raised a blocking DoS against the fix
from the previous round. That fix had added a generation-equality term to the
in-flight join condition in resolveSenderIsLocal, and the term defeated the
single-flight coalescer: a remote page on the primary port can bump the
generation at will with main-frame navigations, and each bump let the next caller
decline to join and spawn another classifyPortOwner — a fresh netstat plus a
per-pid command lookup, with no cache or throttle beneath it. The attacker, not
the app, set the probe count.

What changed. A retrospective ruled the repair had to be a narrowing, so the
round is a subtraction of three mechanisms rather than a fourth guard:

  • senderMayFlipDevMenuVisibility is gone. dev-mode-changed now reads the gate
    strictly, like every other gated channel. That removed the only reader that
    treated a probe outcome as permission, which was the precondition for both this
    finding and the previous one.
  • the generation-equality term is gone — the join is a bare if (inFlight), so
    the coalescer bounds concurrent probes again.
  • inFlightIsOurs is gone, since one probe per WebContents makes the cleanup
    unconditional.

Generation equality still applies to the verdict through
applyGenerationGuard; it just no longer decides whether to share the work.

What the strict read actually costs, since it lands in behaviour. Less than
it first appears. app-menu.js builds devtools-toggle with visible: true, so
the row is already offered before the channel is called and a refusal leaves it
there rather than hiding it; the dashboard's only caller sends true, once on
mount. The capability gating protects is the reverse of the obvious one — the
channel also accepts false, so a remote document let through could HIDE the
local user's row. The residual cost falls on a shell old enough to build that row
hidden, where one inconclusive probe at mount leaves it hidden for the session,
permanently where the owner probe cannot run at all (lsofListenPids rejects on
ENOENT, so a POSIX box with no lsof answers unknown every time). Written up
in docs/build/desktop-app.md.

Commits. Two, as before. Authorship and the 8 Oct author date are preserved
on the tip; only the content moved.

author new SHA patch-id before → after
parent James Joseph 2051f06639 0af123ab9ffa → 499a98547a1d
tip bolichen97 f9599bbd6f db4981c8ba9b → 62c0a33b7368

Both local lanes return no findings on the pushed tree, and both commits pass the
Electron suite in isolation.

-- AI comment by Agent(Cyborg)

@josej4m

josej4m commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Correction to the SHAs in my previous comment. The branch was rebased onto
current main (411 commits) between writing that comment and pushing, so the
two commit SHAs it quoted are stale:

author SHA in the comment above actual pushed SHA
parent James Joseph 2051f06639 d73f010594
tip bolichen97 f9599bbd6f e38ac3f021

The rest of that comment stands unchanged, including the part that matters most
here: the patch-ids are still 0af123ab9ffa → 499a98547a1d on the parent and
db4981c8ba9b → 62c0a33b7368 on the tip. A clean rebase preserves a patch-id,
so what did and did not change inside bolichen97's commit is exactly as
described — only the commit's position moved.

My sequencing error: the rebase belonged before the comment, not after it.

-- AI comment by Agent(Cyborg)

@iamwhatever

Copy link
Copy Markdown
Contributor

Status from the crew (iamwhatever): I approved the pending fork workflow runs (the diff touches no .github/ path) and updated the description so the "Positive-verdict expiry" and "Behavioural delta" paragraphs match 8d4ba61b: a lapsed positive now paints app-menu:items at once and re-probes in the background, an inconclusive probe keeps rows enabled for the 30s INCONCLUSIVE_PAINT_GRACE_MS but never authorizes a click, and app-menu:execute still needs a fresh local probe.

First Principles is BLOCK on this head. It asks to remove the verdict cache, the 30s paint grace and the unidentified owner value. That machinery is what buluoray's Blocking 1 asked for (the menu must not wait on the port probe), and the measured probe cost is 594-739ms per open. Removing it would bring that blocker back. This is a maintainer call, so I am not posting an override myself. If a maintainer agrees, a draft is:

/ai-review override first-principles 8d4ba61bf65a7eac13753eece09a55a0d28e376b not-applicable: The cache and paint grace are the maintainer-requested fix for buluoray Blocking 1 (menu must not wait on a 600ms+ port probe); execute stays uncached-authorized by a fresh local probe.

@buluoray please re-review on 8d4ba61b once CI settles.

@iamwhatever

Copy link
Copy Markdown
Contributor

Pushed 3faa9fa18 (folded into the top commit, so the branch stays at 2 commits; @bolichen97 your commit SHA moved again, content otherwise unchanged). It fixes the GPT 6.1 blocking finding: the focus-moved refusal in app-menu:execute now goes through logGateRejection(event.sender, ...) and logs a bounded id/index. New test focus-moved refusals spend the per-sender rejection-log budget queues 200 invokes behind one probe and asserts at most 5 lines; it fails on the old code (200 lines). Electron registrar suites: 86/86 pass.

The First Principles override draft from my previous comment now needs the new head: /ai-review override first-principles 3faa9fa18... not-applicable: ... (same reason). A maintainer decides; I will not post it.

@josej4m

josej4m commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Conflict cleared and the branch is current again at c80f49024d, zero commits behind main.

What conflicted. One file, website/electron/test/ipc-registrar.test.js. Upstream grew its inline scaffolding (+539/−66 across #31470, #31593 and #31511) while this branch had extracted that same block into ipc-registrar-test-helpers.js. I kept the extraction and ported upstream's additions into it: the tray-icon:get/tray-icon:set handles, requestedGlobalHotkey() with its requested state, and the trayIcon harness stub. app-menu:execute stays a handle rather than a listener — that is this PR's send→invoke change, not a merge error. Electron registrar suites: 3372 tests, 0 fail.

@bolichen97 your commit SHA moved again (c80f49024d), for the sixth time — content is untouched, and the patch-id c4892b4afa5e is byte-identical across the replay. The entire resolution landed in my own commit.

Two asks, because nothing has actually run here since 5 November.

  1. Could a maintainer approve the pending fork workflow runs? All 17 sit at action_required, so this head has no CI signal at all. Fork Workflow-Change Guard passes, confirming no .github/ path is touched.
  2. @buluoray when you have a moment — your CHANGES_REQUESTED from 20 October is now the only review blocking. Since then the Opus 5.5 blocking finding was fixed by subtraction: the titlebar refusal notice and the gated-row footer no longer tell the user to "use the main window", because that notice is reachable only from an enabled row and so fires most often in the main window. A test now pins both strings so the catalogs cannot drift from them again.

@josej4m

josej4m commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Both asks are done. The branch is rebased onto main at 68ad921f7f, zero commits behind.

Re-authored. It is now a single commit authored by me, with @bolichen97 and @iamwhatever as Co-authored-by trailers — GitHub resolves both to your accounts on the commit. I squashed rather than only re-authoring because the two commits were no longer separable: the retrospective in October deleted four mechanisms inside @bolichen97's commit, the GPT 6.1 blocking fix changed it again, and @iamwhatever's logGateRejection fix was folded into it on 4 November. Thanks @bolichen97 for agreeing to the absorb.

One disclosure. In classifyPortOwner: an unreadable command is reported unread, not as someone else's program the expected verdict moves from foreign to unidentified. The protection that test describes is unchanged — holder-decision.js still refuses to adopt it, so a holder nobody identified cannot receive this machine's .local_secret — but the app-menu gate needs to read it as inconclusive rather than proven-foreign, which is what stops a transient probe failure from revoking the local user's own menu rows. I rewrote the test's comment to say that rather than leaving the old rationale in place.

Electron suite 3797 tests / 0 fail; the titlebar and dirStaging frontend suites 105 / 0; both i18n gates and the frontend build clean.

One ask: 17 fork workflow runs are sitting at action_required, so no CI has run on any recent head of this PR. Fork Workflow-Change Guard passes, which confirms no .github/ path is touched — could someone approve them, so the review lands against a green board?

@bolichen97

Copy link
Copy Markdown
Contributor

@buluoray, the points from your change request on cb31d4f18a (review 5592331786), mapped to 68ad921f7f, which is rebased onto main with no conflicts:

  • Blocking 1, paint waits on the probe past 35s: positiveIsPaintable (website/electron/ipc-registrar.js) now paints from the last positive at any age. Only navigation, a proven foreign holder or an inconclusive probe past INCONCLUSIVE_PAINT_GRACE_MS drops it, and a background re-probe runs meanwhile. app-menu:execute still re-resolves on every click. Test: "a positive re-earned after an inconclusive probe paints at any age".
  • Blocking 2, a failed command lookup counts as foreign: classifyPortOwner (website/electron/gateway-stop.js) returns unidentified for a holder whose command line could not be read, the app-menu gate treats it as inconclusive, and a proven foreign pid still outranks it. Tests: "a holder whose command line cannot be read is 'unidentified'", "a PROVEN foreign holder outranks an unreadable one". The from-source venv owner is the accepted break you offered: the description says so, and "a from-source venv gateway on Windows is 'foreign' — accepted break" pins it.
  • Non-blocking, the two green mutations: now pinned by "resolveSenderIsLocal ... guards the cache write with a generation counter" and "executeMenuItem defaults a missing senderIsLocal to REMOTE, not local".
  • Non-blocking, docs: docs/build/desktop-app.md now describes the app-menu:items / app-menu:execute gate.
  • Still open, non-blocking: the item classification is still a deny list (windows-menu-model.js), and I did not check the footer max-w-[240px] note.

CI on this head is still running.

AI-assisted, sent by CommunityCrew

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own.

The PR adds a per-action, fail-closed gate on the Windows titlebar menu IPC. Clicks are only treated as local when a fresh check (or one under 5s old) proves the sender is the local dashboard; a navigation clears the cached answer. Painting rows from an older answer only affects how they look, since every click is checked again. Every menu item is classified into a local-only set or left remote-safe, and a test walks the whole menu to keep that true. The new 'unidentified' port-owner value is handled correctly by every reader: adoption and auth-hint refuse it like 'foreign', the restart handoff refuses it as unverifiable, and eviction/reconnect behave as before. The renderer copes with older shells that still use send. Tests are extensive, and the one large deletion in ipc-registrar.test.js is setup code moved to a helper file. I found no concrete defect, regression or fail-open.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 68ad921f7f · 4933 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

josej4m and others added 3 commits November 14, 2026 02:19
The Electron app-menu IPC channel (`app-menu:items` / `app-menu:execute`)
was gated per-channel via `assertLocalDashboard`, letting through anything
a local dashboard could issue. A remote gateway page loaded in a
connection window shares the same preload, so it could invoke privileged
menu roles (paste reads the OS clipboard, quit terminates the app,
close/minimize/zoom mutate OS window state, togglefullscreen covers the
desktop) plus custom-click items (DevTools opens on the local dashboard,
Settings/About windows).

Classify menu items into four sets — LOCAL_ONLY_ROLES,
LOCAL_ONLY_MENU_IDS, LOCAL_ONLY_ITEM_IDS, REMOTE_SAFE_ITEM_IDS — and
enforce them at `executeMenuItem` when the sender is not local. Thread
`senderIsLocal` down from the IPC boundary through `menuItems` and
`executeMenu` so `app-menu:items` also advertises LOCAL_ONLY rows as
`enabled: false` for a remote sender — a rendered row must not silently
no-op on click. Resolve the verdict once per WebContents via a WeakMap
cache invalidated on `did-navigate` to keep the per-click cost sub-ms.

Add a template-walk drift pin that walks `buildMenuTemplate` output for
both isMac branches, filters by `WINDOWS_TITLEBAR_MENU_IDS` reachability,
and asserts every reachable leaf is classified in exactly one set. This
catches an unclassified item added to `app-menu.js` that a set-membership
pin alone would miss.

Windows-only enforcement is deliberate: the `app-menu:*` IPC is the only
renderer-invocable menu path (Linux/macOS use the native OS menu with no
renderer API, and custom click handlers resolve to
`focusedDashboardWebContents()` which finds the dashboard view, not
remote content). The classification sets are the global policy; the
enforcement point is single because the attack surface is single.

A gated row carries no per-row decoration and the payload carries no
accelerator-registration field. Greying states the row is inert from this
window, and the footer adds the one thing greying cannot say: the
shortcuts still shown do fire, because Electron's native accelerator
dispatch and Chromium's own clipboard handling both bypass this IPC.
That sentence is kept true by subtraction rather than annotation.
`serializeMenuItems` blanks the caption of a gated row whose chord cannot
reach its command, which is File > Settings… alone — `registerAccelerator:
false` displays Alt+, without binding it, and the in-page handler that
does route it only receives the keystroke while the dashboard page holds
focus. So the wire carries an existing field with a narrower value rather
than a new flag no consumer reads. One renderer test pins the absence of
any per-row marker, one wire test pins the suppression, and one pins the
absence of the field.

Paint the menu without waiting on the port probe. A lapsed positive
verdict paints `app-menu:items` at once and re-probes in the background;
`app-menu:execute` still refuses unless a fresh probe proves a local
owner, so the click stays the real gate. A probe that cannot name the
primary-port holder (unknown, or none while our gateway restarts) keeps
the rows painted enabled for a restart-sized grace instead of greying the
local window's own menu, but never authorizes an action. Past the grace
the rows grey with the footer. A proven foreign holder revokes the
positive, and a first call still fails closed.

`classifyPortOwner` gains `unidentified` for a holder that demonstrably
exists but whose command line could not be read. `unknown` means the probe
never ran, so nothing is known to hold the port and the adopt path may
fail open; here a holder exists and only its identity is missing, so the
adopt path refuses it exactly as it refuses `foreign`, while the app-menu
gate reads it as inconclusive rather than as a proven foreign holder. That
is what stops a transient probe failure from revoking the local user's own
menu rows.

Off macOS the Window menu's Zoom is a custom click calling
`applyWindowControl(win, "maximize-toggle")` rather than Electron's
macOS-only `zoom` role, so it carries no role for `LOCAL_ONLY_ROLES` to
catch and would have inherited remote-safe on execute. It is fenced by id
as `window-zoom`, and the template-walk pin is what found it.

Co-authored-by: Bolin Chen <bolichen@amazon.com>
Co-authored-by: Joe Guo <12429733+iamwhatever@users.noreply.github.com>
A page could pass an app-menu id whose own toString throws. Building the
focus-moved refusal line called it, so the throw skipped the per-sender
budget and every queued invoke wrote its own dispatch-failed line.

Render renderer-supplied ids by type instead of coercing them, and send
the dispatch-error line through the same budget.
The focus-moved check compared windows, so a modal opened inside the
same window moved the focused WebContents unnoticed and a Reload then hit
the modal. Compare the focused WebContents too.

The refusal notice covers the whole shell, so its ask-the-agent hand-off
could unmount a page holding unsaved drafts. Turn it off, as
errors-use-error-notice requires.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants