Skip to content

feat(claude-desktop): add Cowork as an opt-in through flatpak overrides - #1562

Merged
jing2uo merged 1 commit into
flatpark:mainfrom
ajithakdev:fix/claude-desktop-cowork-opt-in
Nov 26, 2026
Merged

jing2uo merged 1 commit into
flatpark:mainfrom
ajithakdev:fix/claude-desktop-cowork-opt-in

Conversation

@ajithakdev

Copy link
Copy Markdown
Contributor

Follows up on #1405: Cowork as an opt-in for com.anthropic.ClaudeDesktop, as agreed there.

What

Claude (com.anthropic.ClaudeDesktop). Cowork stays off by default. A user who wants it adds three overrides; without them the package behaves exactly as it does today. The steps are in registry/com.anthropic.ClaudeDesktop/COWORK.md, next to the package.

Sandbox

Default finish-args are unchanged. The opt-in, documented in the metainfo and COWORK.md:

flatpak override --user --device=all --filesystem=host-os:ro \
  --talk-name=org.freedesktop.Flatpak com.anthropic.ClaudeDesktop
  • --device=all: /dev/kvm and /dev/vhost-vsock.
  • --filesystem=host-os:ro: the host's /usr at /run/host/usr, where QEMU, OVMF and virtiofsd are.
  • --talk-name=org.freedesktop.Flatpak: the Cowork helper has to run on the host. This lets the app run any host command, so once it's on the app is no longer really sandboxed. The metainfo and COWORK.md both say that in plain words.

Since none of this is granted by the manifest, dangerous_permissions stays empty. flatpark.yml declares injected-code and host-command under packaging:, and both entries say they only apply after the opt-in. node scripts/audit-descriptor.mjs passes.

How the launcher gets past the fixed-path checks

The app decides Cowork is available with plain fs.access calls in the main process, against fixed paths: /usr/bin/qemu-system-x86_64 (-aarch64 on arm64), /usr/share/OVMF/OVMF_CODE_4M.fd or OVMF_CODE.fd (/usr/share/AAVMF/AAVMF_CODE.fd on arm64), and /usr/libexec/virtiofsd or /usr/bin/virtiofsd. In the sandbox /usr is the runtime, and Flatpak won't mount over it. I checked 6.28899.6 for an override (environment variable or setting) and found none. Its fuses block NODE_OPTIONS and the inspector, and asar integrity is on, so there's no JS-side route either. The app tree stays unmodified, as before.

What's left is a small preload (cowork-shim.c, about 100 lines, built in its own module). The wrapper sets it through ZYPAK_LD_PRELOAD (zypak overwrites LD_PRELOAD), and only when all three overrides are present: /dev/kvm exists, /run/host/usr exists, and /.flatpak-info has org.freedesktop.Flatpak=talk. Otherwise it's never loaded. It hooks three things and leaves everything else alone:

  1. access/faccessat on those path prefixes go to /run/host + path. The host's real files answer the check. Fedora's relative OVMF links resolve there too.
  2. execve/execvp/execvpe of .../cowork-linux-helper start /app/bin/cowork-host-helper instead. That script runs the same, unmodified helper on the host with flatpak-spawn --host --watch-bus, inside a host bwrap that binds the host's top-level directories, the app at /app and /run/user/$UID/doc at /run/flatpak/doc. That way the paths the app passes to the helper (/app/extra/... and document-portal folders) still resolve. The firmware path the app passes is a real host path, so the helper uses it as it is.
  3. connect() to $XDG_RUNTIME_DIR/claude-cowork-vm.sock goes to $XDG_RUNTIME_DIR/app/$FLATPAK_ID/claude-cowork-vm.sock, the part of the runtime dir the sandbox and the host share. The host script rewrites the helper's -socket argument to the same path.

Tested

Fedora 45, x86_64, GNOME. Package built from this branch with flatpak-builder (app 6.28899.6), installed --user.

  • No overrides: the shim is in none of the app's 14 processes (checked /proc/<pid>/maps). The app logs workspace VM not supported (status=unsupported), same as the current package.
  • With the three overrides: the shim loads in the main process, the app passes its checks, starts the helper (it runs on the host and listens on the shared socket, and the app connects to it), downloads its VM image, and starts QEMU on the host. The guest reaches guest ready. A Cowork task on a folder picked through the portal (/run/flatpak/doc/.../Documents) mounted it (failedMounts=0) and ran ls -la in the VM, with owners and dates shown.
  • Not tried: Debian/Ubuntu hosts and arm64. COWORK.md says so. The paths come from the app's own checks.

On 2026-11-21 the same approach also ran end to end on 5.11492.5 (VM boot, folder mount, shell), with the overrides passed by hand.

Things to weigh

  • The .c file means the audit counts the package as injected-code, so I expect the site to show the "Modified" level for everyone, even though nothing loads without the opt-in. If you'd rather keep the default listing at its current level, the alternative is a docs-only recipe where users build the shim themselves. I'm happy to switch to that.
  • --reset removes every override for the app. COWORK.md also explains how to remove only these three.
  • The app needs about 16 GB free in ~/.var/app/com.anthropic.ClaudeDesktop before it unpacks the VM image. That's the app's own check, and COWORK.md mentions it.

Cowork needs QEMU, /dev/kvm and the host's OVMF and virtiofsd, which the
sandbox can't reach, so it stays off by default. With three overrides
(--device=all, --filesystem=host-os:ro, --talk-name=org.freedesktop.Flatpak)
the wrapper preloads a small shim that points the app's fixed-path checks
at /run/host, runs the app's own helper on the host through flatpak-spawn,
and connects the app to it. Without the overrides nothing is loaded and the
app starts as before. The app tree is not modified.

COWORK.md has the setup and says plainly that the last override ends the
sandbox. flatpark.yml declares injected-code and host-command.
@jing2uo

jing2uo commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Review: #1562 — Cowork opt-in for com.anthropic.ClaudeDesktop

Reviewed at 9fefbe67 against docs/reviewers/review-runbook.md. Static only: nothing from the PR or the vendor package was built or run.

Verdict: NEEDS-HUMAN. No hard-fail triggers. The code does what the description says. Default finish-args are unchanged, and the shim only loads after all three overrides are added. Two things need a maintainer: a decision on the site badge (below), and approval for the pr-checks run, which is waiting with action_required.

Checks

Legend: ✅ pass · ❌ fail · ⚠️ warn · 👤 needs-human · ➖ N/A

# Phase Check Tier Verdict Evidence
0 Safety Static-only, isolated dir ★ ✅ The .deb was fetched as bytes into a scratch dir. Only cowork-linux-helper was extracted (--no-same-owner --no-same-permissions) and read with file/readelf/strings. Nothing was executed.
1.1 Scope Classification ★ ✅ Change to an existing app. 7 files, all under registry/com.anthropic.ClaudeDesktop/
1.2 Scope High-scrutiny surface ★ ✅ No .github/, scripts/ or config/ changes. resolve-update.sh and the update: block are unchanged. The managed extra-data block is untouched.
1.3 Scope De-listed ★ ➖ Not a new app
2.1 Provenance Submitter ★ ✅ ajithakdev, account from 2022-06, 16 public repos, maintains claude-desktop-rpm (64★). Did the groundwork in #1405.
2.2 Provenance Source repo ★ ➖ Payload unchanged: same official downloads.claude.ai .deb as main
2.3 Provenance Commit identity ★ ✅ One commit. The author email is a normal address on the same login.
2.4 Provenance Timeline ★ ✅ The approach was agreed in #1405 before this PR was opened
2.5 Provenance Trust tier ★ ✅ Established / unknown-plausible
2.6 Provenance Artifact tier ★ ✅ Tier 2 (proprietary, policy.proprietary: true)
3.1 Manifest Source types ★ ✅ The new cowork module has two local type: file sources: cowork-shim.c and cowork-host-helper. Extra-data is unchanged: sha256 + size.
3.1b Manifest Remote bytes in /app ★ ✅ None. The shim is compiled from an in-repo .c file, like com.getupnote.UpNote/fake-getpid.c and com.schwab.thinkorswim/chromium-no-sandbox.c.
3.2 Manifest finish-args escape perms ★ ✅ No change to finish-args. The new --talk-name=org.freedesktop.Flatpak / --device=all / --filesystem=host-os:ro grants exist only as a user flatpak override, so dangerous_permissions: [] is correct.
3.3 Manifest policy: honest ★ ✅ proprietary: true is correct. dangerous_permissions matches what the manifest grants.
3.4 Manifest build-commands / injected code ★ ✅ cc -shared … cowork-shim.c -ldl plus two install lines. The vendor tree is not touched (apply_extra.sh is unchanged). The injected code is disclosed in plain words in the metainfo, as required for a proprietary app.
3.4b Manifest packaging: declared ★ 👤 injected-code + host-command, en + zh-Hans, accurate. node scripts/audit-descriptor.mjs registry/com.anthropic.ClaudeDesktop/flatpark.yml → exit 0. But see finding 1: the badge comes out as Reduced isolation, not Modified.
3.5 Manifest Source URLs genuine ★ ✅ Unchanged, downloads.claude.ai
3.6 Manifest app-id ★ ✅ Unchanged
3.7 Manifest update.command ★ ✅ Unchanged (./resolve-update.sh)
3.8 Manifest Download host ★ ✅ Vendor domain
3.9 Manifest Optional caps opt-in ★ ✅ This is the model case: the broad grants are documented as a flatpak override in the metainfo and COWORK.md, and none are pre-granted.
3.10 Manifest What was tested ★ ✅ Fedora 45 x86_64, built from the branch, checked with and without the overrides (/proc/<pid>/maps, VM boot, portal folder mount, shell). Debian/Ubuntu and arm64 are listed as untested.
3.11 Manifest Screenshot ★ ➖ Unchanged
4.1 Runtime Packaging fetch-and-exec ★ ✅ None added. The ~1.4 GB VM image is downloaded by the unmodified app into its own data dir, which is upstream behaviour.
4.2 Runtime Resolver reviewed ★ ➖ Unchanged
4.3 Runtime Endpoints / fs×net ★ ✅ No change by default. With the opt-in, the app can run any command on the host. COWORK.md, the metainfo and the host-command entry all say so plainly.
5.1 Artifact sha256 == pin ★ ✅ amd64: 7e381601…38cf8, size 191718584, matches the manifest
5.2 Artifact Inspected ★ ✅ 139 entries. Only one has ../: the symlink usr/bin/claude-desktop -> ../lib/claude-desktop/claude-desktop, which stays inside the tree and is dropped by apply_extra. Setuid chrome-sandbox (zypak replaces it; Flatpak strips setuid). postinst/postrm are never run.
5.3 Artifact Tier 1 only 1 ➖ Tier 2
5.4 Artifact Shipped == official ★ ✅ Payload and apply_extra.sh are unchanged from main, and the vendor tree is unmodified
5.5 Artifact Bundled runtimes ★ ✅ resources/cowork-linux-helper is a statically linked Go ELF (no NEEDED, no RPATH/RUNPATH), so it runs on any host without host libraries
5.6 Artifact IOC scan ★ ✅ The shim and host script contain no network calls, no persistence and no hard-coded IPs. The host script only builds a bwrap command line and execs the vendor helper.
6.1 Compliance Purpose ★ ✅ Official Anthropic client
6.2 Compliance Non-FOSS ok ★ ✅ —
7.1 Verdict Overall ★ 👤 NEEDS-HUMAN: the badge decision (finding 1) and CI approval
7.2 Verdict Hard-fail triggers ★ ✅ None
7.3 Verdict Reviewer recommends only ★ ✅ A maintainer merges

What was read, file by file

  • claude-desktop-wrapper: Before the app starts, it checks /dev/kvm, /run/host/usr and an exact line org.freedesktop.Flatpak=talk in /.flatpak-info. If any of the three is missing, ZYPAK_LD_PRELOAD stays unset, so a default install runs the same code path as today. Prepending to an existing ZYPAK_LD_PRELOAD is correct.
  • cowork-shim.c: Reviewed every hook.
    • access/faccessat: only for the five fixed prefixes, rewritten to /run/host<path>. A path too long for the buffer falls back to the original.
    • connect: only for an AF_UNIX path equal to $XDG_RUNTIME_DIR/claude-cowork-vm.sock, rewritten into the shared per-app runtime dir.
    • execve/execvp/execvpe: only for a basename of /cowork-linux-helper, swapped to /app/bin/cowork-host-helper.
    • Everything else passes through to RTLD_NEXT. No state, no I/O.
  • cowork-host-helper:
    • Rewrites only the exact -socket value.
    • Reads app-path from /.flatpak-info.
    • Runs flatpak-spawn --host --watch-bus → sh → bwrap. The bwrap root binds the host's top-level dirs and /run/*, plus /run/user/$UID/doc at /run/flatpak/doc and the deploy dir read-only at /app.
    • Nothing is written on the host outside the runtime dir. The rotation of the helper's arguments behind the bwrap options is correct.
    • Binding the root document view rather than by-app/<id> is wider, but on the host side the process is already unsandboxed, so it adds nothing.
  • com.anthropic.ClaudeDesktop.yml: The new cowork module comes before the app module. The comments match the code.
  • metainfo.xml / COWORK.md / flatpark.yml: Accurate and plain about what the overrides give up. The zh-Hans text matches the English.

Findings

  1. 👤 The site badge will be "Reduced isolation" for everyone, not "Modified". site/tools/enrich.mjs:455-465 maps host-command → reduced and takes the highest level. The audit requires that entry here, because cowork-host-helper contains flatpak-spawn (scripts/audit-descriptor.mjs:409). So a default install, which can't run host commands at all, gets the red badge. The packaging: texts do say "Only for Cowork, which is off by default", so the per-item list is honest, but the headline badge isn't. This is the maintainer's call:
    • (a) accept the badge as it is;
    • (b) go docs-only, as you offered;
    • (c) add an opt-in marker to packaging: entries so the badge shows the default level. That is a separate infra change on our side, not something for this PR.
  2. Link COWORK.md from the metainfo. "Setup steps … are in COWORK.md in FlatPark's registry" can't be followed from a software centre. Please use the full URL: https://github.com/flatpark/flatpark/blob/main/registry/com.anthropic.ClaudeDesktop/COWORK.md.
  3. Undo without --reset. Both COWORK.md and the metainfo use --reset and warn that it removes other overrides, then tell users to edit the override file by hand. The targeted form does the same job without either problem: flatpak override --user --nodevice=all --nofilesystem=host-os --no-talk-name=org.freedesktop.Flatpak com.anthropic.ClaudeDesktop. With that, the wrapper's check fails and the shim stops loading. --device=dri from the manifest is not affected.
  4. Observation: the helper's environment. flatpak-spawn --host doesn't pass the sandbox environment through, only --env= values. The helper reads XDG_RUNTIME_DIR, which has the same value on the host, and COWORK_VM_ACCEL (seen in strings). If the app or a user sets COWORK_VM_ACCEL for the helper, it is lost on the way. This doesn't block anything, since your test passed. A one-line --env=COWORK_VM_ACCEL=… pass-through when it is set would close the gap.
  5. Nit: bwrap on the host. COWORK.md says bwrap "comes with Flatpak". That's true where Flatpak depends on the bubblewrap package (Fedora, Debian, Arch). A Flatpak built with its bundled bwrap installs it as flatpak-bwrap under libexec, not as bwrap on PATH. A one-line command -v bwrap in the setup steps would catch that early. Hosts where AppArmor restricts unprivileged user namespaces (Ubuntu 24.04+) are untested too. The PR already says so.

Reproduce

git fetch origin pull/1562/head:pr-1562 && git worktree add ../pr1562 pr-1562
cd ../pr1562 && node scripts/audit-descriptor.mjs registry/com.anthropic.ClaudeDesktop/flatpark.yml   # exit 0
curl -sSfLO https://downloads.claude.ai/claude-desktop/apt/stable/pool/main/c/claude-desktop/claude-desktop_6.28899.6_amd64.deb
sha256sum claude-desktop_6.28899.6_amd64.deb; dpkg-deb -c claude-desktop_6.28899.6_amd64.deb | grep -E 'cowork|virtiofsd|^-..s'
dpkg-deb --fsys-tarfile claude-desktop_6.28899.6_amd64.deb | tar -x --no-same-owner --no-same-permissions ./usr/lib/claude-desktop/resources/cowork-linux-helper
file usr/lib/claude-desktop/resources/cowork-linux-helper   # statically linked
grep -n -A10 'PACKAGING_KINDS = {' site/tools/enrich.mjs

Not covered

  • Nothing was built or run, so the Fedora test record above is the evidence that it works.
  • The arm64 .deb was not re-hashed. Its pin is unchanged from main.
  • No host other than Fedora was tried.
  • The app's own Cowork code and the VM image it downloads were not audited.

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.

2 participants