Files
coredesktop/.claude/skills/coredesktop-security-checks/SKILL.md
T
davidandClaude Opus 5.5 143473e798
shellcheck / shellcheck (push) Failing after 19s
Test the report receiver and redaction against attacks
server/report-receiver/test_security.py sends the receiver what anyone
on the internet could, and the Redaction tests in tests/report.bats feed
report logs full of secrets. Each test was checked to fail before its fix.

The receiver now refuses a negative Content-Length (read without limit),
parts nested thousands deep (a RecursionError dropped the connection)
and more than 20 parts (thousands took seconds of CPU to parse). It
counts an IPv6 address's /64 for the rate limit, since a home has a
whole /64 to send from. Report fields go into the Gitea issue as inline
code, and titles keep only the characters of step names and versions,
so a report can't @mention the team, link issues, or show a tracking
image. It refuses reports while its disk has less than 2 GB free.

report now also takes out passwords in URLs, Bearer and Basic tokens,
password= and token: values, API keys by their prefixes, Nextcloud app
passwords, private keys, IPv6 and MAC addresses, the Cores' domains and
the user's name. It reads the Core settings rather than sourcing them,
and escapes extended regex characters in names, which it didn't before.

The plan for the checks still to do, in the smoketest VM (the agent
sandbox, network exposure, what root runs, the install path), is a
Claude Code skill: /coredesktop-security-checks.

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

6.8 KiB

name, description
name description
coredesktop-security-checks Plan and progress for CoreDesktop's security test suite. The report receiver and report's redaction are tested; the checks still to write run in the smoketest VM (the agent sandbox, 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. 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.
  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.

Next: steps 3 to 6 in the smoketest VM

Write them as one new scenario, smoketest/scenarios/60-security.sh, IMAGE=installed, TIER="nightly", with assert_vm/refute_vm checks (see smoketest/lib/scenario.sh and 44-low-disk.sh for the 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.

3. The agent sandbox (sandbox/, sandbox/agent, sandbox/bin)

Run a script as an agent would (through sandbox/bin's wrappers, the way opencode and Hermes start) and check that each of these fails:

  • reading ~/.ssh, ~/.gnupg, the GNOME keyring (~/.local/share/keyrings), Bitwarden's data, ~/.config/coredesktop (Core settings), /etc/coredesktop/smb and ~/.winboat (hidden unless configure sandbox shows it)
  • writing outside the folder it was started in and its own state
  • reaching a LAN address that isn't allowed (configure ai-servers adds allowed ones), and anything not through its proxy
  • seeing other users' processes, or the D-Bus session bus (which could ask GNOME to run things outside the sandbox)

Also check that the same reads work from outside the sandbox, so a passing test means the sandbox blocked them, not that the files were missing. tests/sandbox.bats checks only the sandbox's configuration.

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.