Files
coredesktop/.claude/skills/coredesktop-security-checks/SKILL.md
T
davidandClaude Opus 5.5 e991264ddc Let Hermes' gateway reach only a Matrix server you've allowed
sandbox/setup.sh allowed Hermes' gateway the host in MATRIX_HOMESERVER
from ~/.hermes/.env, which Hermes can write from inside its sandbox. On
the next update, Hermes could have opened the way out to any host it
chose.

The allowed server is now in ~/.config/coredesktop/sandbox/hermes.json,
which no sandbox can write. configure hermes is to do while Hermes names
a server you haven't allowed, and asks about only that; update says so.
Only a plain host name counts, so it can't be a wildcard or carry escape
codes into the question. A migration carries over the server the
gateway's systemd drop-in allows now, so a working gateway keeps
working. sandbox/agent no longer takes domains from
COREDESKTOP_SANDBOX_DOMAINS, which nothing else used.

The security checks skill now records step 3 as done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 16:13:32 -07:00

8.8 KiB

name, description
name description
coredesktop-security-checks Plan and progress for CoreDesktop's security test suite. The report receiver, report's redaction and the agent sandbox are tested; the checks still to write run in the smoketest VM (network exposure, what root runs, the install path). Use when resuming, continuing, checking the status of, or changing CoreDesktop's security or penetration tests.

CoreDesktop's security checks

Written on 2026-11-16, updated the same day after step 3. Work out the current state before doing anything:

git -C ~/Projects/coredesktop fetch && git -C ~/Projects/coredesktop log --oneline origin/main -15
ls ~/Projects/coredesktop/smoketest/scenarios/ ~/Projects/coredesktop/server/report-receiver/

Tell the user which step is next and confirm before starting it.

Scope

The suite covers what CoreDesktop itself adds. It doesn't test Arch or GNOME, which upstream looks after. It goes after the places where a mistake would leak data or give away control, in this order:

  1. The report receiver, the only part on the public internet. Done.
  2. report's redaction, which decides what leaves a user's computer. Done.
  3. The agent sandbox: the one place that runs code CoreDesktop doesn't trust. Done.
  4. Network exposure from outside.
  5. Files root runs, and secrets only root may read.
  6. The install path (federated.sh, the [federated] repo).

The pacman guard (system/pacman-guard) is a safety net against mistakes, not a security control: anyone with sudo gets past it by design. Don't test it as a boundary.

Done: steps 1 and 2 (the commit "Test the report receiver and redaction against attacks")

  • server/report-receiver/test_security.py sends the receiver what an attacker could. It found, and the commit fixed:

    • a negative Content-Length (read without limit)
    • parts nested thousands deep (RecursionError, connection dropped)
    • thousands of parts (8 s of CPU for 5.7 MB)
    • a rate limit per IPv6 address instead of per /64
    • Markdown in report fields reaching the Gitea issue: @mentions, issue references, links, tracking images
    • no guard against filling the disk
  • tests/report.bats (the "Redaction" section) found report sending:

    • passwords in URLs
    • tokens, API keys, Nextcloud app passwords and private keys
    • IPv6 and MAC addresses
    • the Core's domain and the user's name
    • user and host names with regex characters, unredacted

    All fixed. A test also checks it doesn't over-redact (pacman's ::, times, epoch versions, std::string).

  • Each test was checked to fail against the code before the fix.

Still open from these steps:

  • Deploy the new receiver.py on federated.sh (server/report-receiver/README.md, "To update it later").
  • Slow uploads. Caddy streams them to the receiver, one thread each. Try request_buffers 11MB in Caddyfile.example's reverse_proxy, and check that caddy validate accepts it.
  • Gitea attachments. Check on the real server that Gitea serves attached .log files as text or as downloads, never as HTML (a log can contain <script>).
  • The daily limit. The 500-a-day limit for everyone lets one sender block reports for a day. That was left as a design trade-off; ask before changing it.

Done: step 3 (the commits "Test the agent sandbox from inside..." and the Hermes homeserver fix)

smoketest/scenarios/60-security.sh runs a script as opencode, Hermes and Cline Desktop would, through sandbox/bin's wrappers with a fake agent first on PATH, so it gets the real config, srt and proxy. About 130 checks; each runs outside the sandbox too, where it must work. It checks that agents can't:

  • read ~/.ssh, ~/.gnupg, the keyring, Bitwarden (package and Flatpak), ~/.config/coredesktop, ~/.winboat, or /etc/coredesktop/smb via sudo
  • write home, another project, ~/.bashrc, ~/.local/bin, systemd user units, autostart, either sandbox config, srt's settings file, or the project's .git/hooks and .git/config
  • reach domains, LAN addresses or this machine's loopback servers that aren't allowed, or anything without the proxy; an allowed LAN host:port works and another port on that host doesn't
  • see root's processes or GNOME Shell, or talk to the D-Bus session bus or systemctl --user

What it found, all fixed:

  • every sandbox could read ~/.config/coredesktop (the Core's domain and user name); sandbox/config/base.json now hides it
  • found by reading the code, not the scenario: Hermes could write MATRIX_HOMESERVER in ~/.hermes/.env, and sandbox/setup.sh then allowed that host for the gateway. The allowed homeserver now lives in ~/.config/coredesktop/sandbox/hermes.json, which configure hermes asks about (sandbox/hermes-homeserver.sh); a migration carried over the one allowed before. Tested in tests/sandbox.bats.
  • edit_json (configure.d/lib/json.sh) wrote nothing back to an empty file, so configure ai-servers could report a server added that wasn't.

Lessons for the next scenarios:

  • A write check must look at the real file from outside. srt hides a denied folder by mounting an empty, writable tmpfs over it, so a write in the sandbox can "work" and go nowhere. See write_blocked.
  • Every in-sandbox check prints a marker first, so a wrapper that fails to start isn't counted as the sandbox blocking something.
  • The scenario's check records a failure and goes on, and fails at the end, so one run shows every gap. Keep that for steps 4 to 6.
  • Outside checks can leave state behind (an empty config file broke a later check once); make them look, not change.

Running the smoketest

  • coredesktop-dev smoketest run 60-security, outside Claude Code's sandbox (it needs KVM). The first run builds the installed image (an hour or more); later runs take about five minutes.
  • It tests a commit. To test uncommitted changes, including new files, make a throwaway commit without touching the branch: write a tree from a temporary index (GIT_INDEX_FILE=... git add -A; git write-tree; git commit-tree) and pass it with --ref. The scenario files themselves are read from the working copy.
  • The user's global git config has no name or email. Commits so far used git -c user.name="David Young" -c user.email=... from the repo's history.

Next: steps 4 to 6 in the smoketest VM

Add them to smoketest/scenarios/60-security.sh (or a sibling scenario if it grows too long), with the same check style. Where a check needs a second machine, say so in the scenario and skip it, rather than faking it. The VM comes from the coredesktop-dev sibling project (see smoketest/README.md); it isn't in this repository.

4. Network exposure

system/firewall.sh allows only 22/tcp (SSH), 5353/udp (mDNS), 53317 (LocalSend) and anything on tailscale0. Check:

  • a scan from another machine finds only those
  • SSH refuses passwords (system/sshd.sh, PasswordAuthentication no)
  • a port a Docker container publishes isn't reachable from outside, which is what ufw-docker is for: Docker otherwise goes around ufw

Open question: the scan has to come from outside the VM. With QEMU's user networking, the host reaches only forwarded ports, and a scan from inside the VM against itself goes through loopback, which ufw allows. Find out from coredesktop-dev whether the VM can get a bridged or tap network, or a second VM, before writing this one.

5. What root runs, and root-only secrets

Every file root runs must be owned by root and not writable by the user, and so must every folder above it. Check it with stat, walking up to /. As of 2026-11-16:

  • /etc/coredesktop/smb (mode 600, root), sshd's 10-coredesktop-keys-only.conf, the ufw rules, and the systemd drop-ins in system/defaults.sh.
  • Added with the Omarchy features (commit 9dc5eb1):
    • the pacman hook /etc/pacman.d/hooks/00-coredesktop-guard.hook and /usr/local/lib/coredesktop/pacman-guard
    • /etc/NetworkManager/dispatcher.d/90-coredesktop-captive-portal
    • after configure security-key and configure fingerprint: /usr/local/lib/coredesktop/lid-closed, /etc/pam.d/sudo, /etc/pam.d/polkit-1 and /etc/u2f_mappings

Also check that nothing root runs reads a path in a user's home. That's why the pacman guard and the lid check are copies in /usr/local, not run from ~/.local/share/coredesktop.

For /etc/pam.d/sudo: after the fingerprint or security-key item, a wrong password must still fail, and sudo -k; sudo true without the key must still ask for the password.

6. The install path

  • https://federated.sh sends wget (User-Agent not starting with Mozilla) to the HTTPS URL of install.sh on Gitea, never to plain HTTP.
  • The [federated] repo's signing key in pacman is the one utils.sh pins (FEDERATED_REPO_KEY), and the repo is SigLevel = Required DatabaseRequired.
  • pacman refuses a package from [federated] that isn't signed by that key. Serve one from the VM's own stand-in repo to check.