Skip to content

fix: keep desktop commands inside lab sessions - #82

Merged
ElbertePlinio merged 11 commits into
mainfrom
fix/73-lab-isolation-escape
Sep 4, 2026
Merged

ElbertePlinio merged 11 commits into
mainfrom
fix/73-lab-isolation-escape

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Why

Commands started next to a desktop session could inherit Wayland variables and open on the developer's real desktop. PickLab then returned a plausible black screenshot with no explanation.

What

  • Adds one shared desktop environment contract that poisons WAYLAND_DISPLAY, removes other inherited WAYLAND_* variables, sets the session DISPLAY, and forces X11 backends for GTK, Qt, SDL, winit, and XDG_SESSION_TYPE.
  • Uses that contract from the existing desktop launch path.
  • Adds picklab desktop exec and MCP desktop_exec. They start an argv array in a dedicated process group, wait a bounded time for a new client window, and stop the group before reporting a possible real-desktop escape when none appears.
  • Adds picklab desktop env text and JSON recipes for parent shells.
  • Reports client-window counts and a shared zero-window warning from CLI and MCP screenshots, while still capturing with a missing-xdotool warning when counting is unavailable.
  • Documents the Flutter development workflow and release note.
  • Carries the exact planted-token allowlist from test(cli): add opt-in live Flutter end-to-end test #80 because gitleaks scans every remote branch and Lab isolation escapes when the app is started outside desktop launch (e.g. flutter run) #73 is scheduled to merge first. No rule or path is allowlisted.

Review follow-ups

  • Restored WAYLAND_DISPLAY=picklab-no-wayland while keeping all other inherited WAYLAND_* variables removed, so raw libwayland clients cannot fall back to wayland-0.
  • Made desktop exec fail closed by stopping and verifying the process group before reporting a possible real-desktop escape, with a --window-timeout hint for slow first builds.
  • Made screenshots succeed without xdotool, return a missing-tool warning, and skip the zero-window escape warning when the count is unavailable.

How it was verified

  • bun install --frozen-lockfile -> passed, 646 packages installed.
  • bun run typecheck -> passed.
  • bun run lint -> passed.
  • bun run build -> passed for all TypeScript packages.
  • bun run test packages/desktop-linux/test/environment.test.ts packages/desktop-linux/test/integration.test.ts -> 24 passed, 4 skipped. The real Xvfb/xdotool GTK test passed with inherited Wayland variables and confirmed the window belonged to the Xvfb display.
  • PATH="<temporary-xterm-shim>:$PATH" bun run test -> 91 files passed, 1,145 tests passed, 2 skipped. The temporary shim used installed Zenity, accepted the xterm title arguments exercised by the suite, and only received test-created Xvfb displays.
  • PATH="$PWD/.validation-bin:$PATH" bun run test:coverage -> passed, 82.47% statements/lines, 86.19% branches, 88.57% functions.
  • complexity-gate check --changed -> passed.

Not verified

  • A manual flutter run -d linux on the developer's real Wayland session was not run, to avoid touching the live display.
  • Native xterm was unavailable locally. The hosted checks install the repository's desktop prerequisites and will cover that path directly.

Closes #73

Security review follow-ups

  • Stops and verifies app process groups before propagating every post-spawn wait failure, including window-query errors, missing identity, and timeout.
  • Confines MCP desktop_launch and desktop_exec working directories to the real project path, rejecting absolute and relative escapes.
  • Warns that daemonising apps can leave the original process group and links follow-up Contain daemonising apps started through desktop exec #85 for stronger containment.
  • Forces Electron and GLFW onto X11 and links follow-up Isolate XDG_RUNTIME_DIR and D-Bus for desktop sessions #86 for XDG runtime and D-Bus isolation.

@ElbertePlinio
ElbertePlinio merged commit f9eb0f2 into main Sep 4, 2026
9 of 10 checks passed
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.

Lab isolation escapes when the app is started outside desktop launch (e.g. flutter run)

1 participant