Skip to content

fix(desktop): refuse pointer and key input when the session's Xvfb was replaced - #411

Merged
ElbertePlinio merged 1 commit into
mainfrom
fix/219-pointer-owned-xvfb
Oct 28, 2026
Merged

ElbertePlinio merged 1 commit into
mainfrom
fix/219-pointer-owned-xvfb

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

Pointer input and key presses ran xdotool against the display in the session record without checking that it still belonged to the session's Xvfb. If that Xvfb died and another X server took the display number, the input could reach the other server. Typing already checked this.

Every xdotool dispatch for click, double click, drag, move, scroll and key now verifies the session's owned Xvfb first (pid, start ticks, lock file and listening socket), with the same bounded check typing uses. It never reads host DISPLAY, XAUTHORITY or home configuration. A mismatch refuses with DesktopInputTargetError, and CLI and MCP evidence record the action as not-attempted. xdotool connects by display number, so a server that replaces the owned Xvfb in the few milliseconds between the check and that connection can still receive the input; the code documents this window.

Key presses share the xdotool helper, so they are gated too, although #219 names only pointer input.

Proof: 13 new tests fail on main and pass here, and a CLI run against a real isolated Xvfb refused all six commands after another Xvfb took the display number, without moving its pointer.

Reviewed with sol-loop: 1 round with GPT-6.1 Sol (xhigh). Sol verdict: not approved, see below.

Closes #219

Requirement Verified by Scenario and edge cases Result Evidence
Pointer input verifies the owned Xvfb before dispatch and fails closed Unit tests, CLI QA Each of click, double click, drag, move, scroll, key with another lock owner, a dead server, a zombie, a recycled pid, a new server on the same display number Refused, xdotool never runs packages/desktop-linux/test/pointer-target.test.ts; ~/.pickforge/investigations/219/qa-output.txt J2, J3
Owned server still works Unit tests, CLI QA All six commands on the session's own Xvfb, host DISPLAY and XAUTHORITY set to other values Dispatched to the session display same files, J1
Window between check and dispatch handled or documented Code comment xdotool connects by display number after the check Documented in runXdotool diff
Check bounded and never reads host endpoints or home Existing tests Getter traps on DISPLAY, XAUTHORITY, HOME; expired 3 s budget Pass, unchanged check pointer-target.test.ts
Refusal reaches evidence as not-attempted Unit tests, CLI QA CLI click and drag; MCP click, double click, drag, scroll, key, captured and uncaptured not-attempted desktop-pointer-evidence.test.ts, desktop-input-captures.test.ts, QA evidence actions
Invalid input still fails as an argument error CLI QA desktop click -- -1 5 Argument error before verification QA J4
Release note Pending docs/releases/UNRELEASED.md still holds the tagged 0.7.1 notes until they are published and reset Text below, added after the reset this PR

Release note for the next version: "Desktop pointer input and key presses now verify that the display is still the session's own Xvfb before they send anything, as typing already did. If another X server took the display number, the action is refused and recorded as not attempted. (#219)"

Checks: bun run typecheck, bun run lint, cargo build --release -p pickforge-viewer, bun run test and bun run test:coverage with the CI environment variables, PickCheck (43 functions, no violations). Two tests failed locally only because this host's mise shim for bun rejects a changed HOME; they pass with the real bun first on PATH.

Pointer input and key presses ran xdotool against the session display without checking that it still belonged to the session's Xvfb. If that Xvfb died and another server took the display number, the input could reach it. Every xdotool dispatch now verifies the owned Xvfb first, with the check typing uses, and refuses with DesktopInputTargetError. CLI and MCP evidence record the refusal as not-attempted. Closes #219.
@ElbertePlinio
ElbertePlinio merged commit d299c61 into main Oct 28, 2026
14 of 15 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/219-pointer-owned-xvfb branch October 28, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop: verify the owned Xvfb before pointer input

1 participant