Skip to content

macOS engine: held activation entries keyed by serving pid let one bound app's pointer, activation and focus hold run under another app's identity #546

Backlog

Description

@SSFSKIM

Problem

HeldActivations keys its entries by serving pid alone (held: [pid_t: Entry], native/engine/Sources/Engine/MenuSpan.swift:222; the join is at :329). When elements of two bound apps A and B are served by the same process, B's work joins A's entry. B then inherits A's appPid, window, arm and activation point. This was there before #538; #538's fix round (ruling 1174) found it while making the key-focus-only check judge the pointer's own bound app.

Affected sites (found by reading the code, not probed live)

  • Guarded branch with an activation standing. deliver reads the entry's appPid in three places: the front test (Activation.swift:685), the sample loop (:730) and the after-action watch (:808, which checks at :1011). For B's pointer joining A's activated entry:
    • With A frontmost, B's click is treated as going to the front target and is posted with no guard.
    • With B frontmost, B is treated as the person's app: the guard repairs against B's own window and may re-activate B.
  • activate(). Its guard sample (Activation.swift:582) and its user-identity test belong to the entry, so a joiner is judged by A's window and activation.
  • Arm and activation point. rearms, activatedWithoutActivationPointClick (MenuSpan.swift:337) and consumeArm (:347, :384) judge B's pointer by A's activation-point click and arm.
  • Focus holds. holdFocus acquires by owner (FocusHold.swift:89, reached from holdElementFocus at :127–134), so a focus hold or element action for B runs under A's activation and window. Callers are at SecondaryAction.swift:110, TextSelection.swift:204, ValueSetting.swift:205, Input.swift:751 and ElementInput.swift:803.
  • Lower exposure. The menu record (MenuSpan.swift:469–471), the paste (Paste.swift:891) and forced key activations key by the app's own pid with appPid == pid. They collide only if another app's elements are served by that app's process.

Unknown

How often one serving process serves several bound apps hasn't been measured; shared XPC or system services are the likely case. A design should first decide whether entries are keyed by (serving pid, bound app pid) or whether a cross-app joiner is refused. It should also say how the #538 path (which already judges the pointer's own bound app) stays consistent with that choice.

Acceptance

  • Seam tests: a cross-app joiner on a shared serving pid, in both front orders, for the guarded branch, activate() and a focus hold. Each is red on main before the fix.
  • No change for single-app entries (the existing guard tests stay unchanged).

Activity

  1. added
    bug
    status:ready-for-architect
    priority:P2
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:P2status:ready-for-architect

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions