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>
This commit is contained in:
2026-11-16 16:13:32 -07:00
co-authored by Claude Opus 5.5
parent d974b91144
commit e991264ddc
7 changed files with 305 additions and 38 deletions
@@ -1,11 +1,12 @@
---
name: coredesktop-security-checks
description: 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.
description: 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. Work out the current state before doing anything:
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
@@ -22,7 +23,7 @@ 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.
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).
@@ -64,32 +65,66 @@ Still open from these steps:
- **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
## Done: step 3 (the commits "Test the agent sandbox from inside..." and the Hermes homeserver fix)
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.
`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`
### 3. The agent sandbox (sandbox/, `sandbox/agent`, `sandbox/bin`)
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.
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)
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.
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.
## 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