60-security.sh now also checks, in the smoketest VM, that each file CoreDesktop installs for root (the pacman guard and hook, the captive portal script, sshd, ufw and systemd settings, and after configure security-key and fingerprint, the PAM files, the lid check and the key list), and every folder above it, is root's and not writable by the user; that nothing in /etc, /usr, /boot or /opt is the user's to write; and that nothing root runs names a path in a home folder. pam_env gives logins ~/.local/bin on PATH, so it checks that root's PATH under sudo, sudo -i and systemd has only root's folders, also for a user who types a password: tester's sudo needs none, and then PAM's auth step, where Arch runs pam_env, never runs. With a security key registered but not plugged in and fingerprints turned on, the password still works for sudo and a wrong or missing one doesn't. It found nothing to fix. Each check was shown to fail on a machine broken the way it looks for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9.1 KiB
name, description
| name | description |
|---|---|
| coredesktop-security-checks | Plan and progress for CoreDesktop's security test suite. The report receiver, report's redaction, the agent sandbox and what root runs are tested; the checks still to write run in the smoketest VM (network exposure, 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:
- The report receiver, the only part on the public internet. Done.
report's redaction, which decides what leaves a user's computer. Done.- The agent sandbox: the one place that runs code CoreDesktop doesn't trust. Done.
- Network exposure from outside.
- Files root runs, and secrets only root may read. Done.
- 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.pysends 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) foundreportsending:- 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.pyon 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 11MBin Caddyfile.example'sreverse_proxy, and check thatcaddy validateaccepts it. - Gitea attachments. Check on the real server that Gitea serves attached
.logfiles 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/smbvia sudo - write home, another project,
~/.bashrc,~/.local/bin, systemd user units, autostart, either sandbox config, srt's settings file, or the project's.git/hooksand.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:portworks 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.jsonnow hides it - found by reading the code, not the scenario: Hermes could write
MATRIX_HOMESERVERin~/.hermes/.env, andsandbox/setup.shthen allowed that host for the gateway. The allowed homeserver now lives in~/.config/coredesktop/sandbox/hermes.json, whichconfigure hermesasks about (sandbox/hermes-homeserver.sh); a migration carried over the one allowed before. Tested intests/sandbox.bats. edit_json(configure.d/lib/json.sh) wrote nothing back to an empty file, soconfigure ai-serverscould 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
checkrecords 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.
Done: step 5 (the commit "Test that what root runs is root's alone")
root_checks in 60-security.sh. It found nothing to fix. It checks:
ROOT_FILESandPAM_FILES(keep them up to date when CoreDesktop installs something root runs): each, and every folder above it, is root's and not writable by the user, following links too (root_only)- nothing in /etc, /usr, /boot or /opt is the user's or writable by them
- no
/home,~/,$HOMEor@{HOME}in what root runs: system units, pacman hooks, NetworkManager dispatcher, PAM, sudoers, udev and polkit rules, /usr/local - root's PATH under sudo, sudo -i and systemd has only root's folders.
pam_env.confgives logins@{HOME}/.local/bin; sudo's secure_path keeps it from root. Checked aspamtest, who types a password:tester's sudo needs none, so PAM's auth step, where Arch runs pam_env, never runs for it. - the real
use_keysanduse_fingerprint, with a key registered but not plugged in: the password still works, a wrong or empty one doesn't, and the sudo and polkit-1 stacks only gained their lines
Each check was shown to fail by a throwaway scenario that broke the VM five
ways (a world-writable file, a user-owned folder above the guard, a unit
running from /home, secure_path in /home, pam_permit.so atop sudo's stack).
/etc/coredesktop/smb isn't checked: only configure storage makes it, which
needs an SMB server.
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 and 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-dockeris 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.
6. The install path
https://federated.shsendswget(User-Agent not starting withMozilla) to the HTTPS URL ofinstall.shon Gitea, never to plain HTTP.- The
[federated]repo's signing key in pacman is the oneutils.shpins (FEDERATED_REPO_KEY), and the repo isSigLevel = 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.