Keep other machines on the network from reaching Docker containers
shellcheck / shellcheck (push) Failing after 19s
shellcheck / shellcheck (push) Failing after 19s
60-security.sh now checks network exposure (step 4), from two other machines made of network namespaces in the VM: one on private addresses, like a neighbour on the same Wi-Fi, and one on public-looking ones. From each, over IPv4 and IPv6: only SSH and LocalSend are open, a container's published port can't be reached, containers still reach both machines, and SSH takes keys only. It also checks ufw's rules and sshd -T. It found that ufw-docker's rules let any private address (10/8, 172.16/12, 192.168/16) reach published ports, so anyone on a café's or hotel's Wi-Fi could. system/docker-firewall.sh lets only Docker's own bridges (docker0, br-+) past instead; firewall.sh runs it on a new install and migration 1794878760 on existing machines. To let other machines reach a container's port: sudo ufw-docker allow <container> <port>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
---
|
||||
name: coredesktop-security-checks
|
||||
description: Plan and progress for CoreDesktop's security test suite. The report receiver, report's redaction, the agent sandbox, what root runs and the install path are tested; network exposure, which needs a scan from outside the smoketest VM, is still to write. 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. All six steps are written and pass: the report receiver, report's redaction, and in the smoketest VM (smoketest/scenarios/60-security.sh) the agent sandbox, network exposure, what root runs and the install path. A few follow-ups remain. Use when resuming, checking the status of, extending 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:
|
||||
Written on 2026-11-16; all six steps were done the same day. 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.
|
||||
Tell the user what's left (the follow-ups below) and confirm before starting
|
||||
any of it.
|
||||
|
||||
## Scope
|
||||
|
||||
@@ -24,7 +25,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. **Done.**
|
||||
4. Network exposure from outside.
|
||||
4. Network exposure from outside. **Done.**
|
||||
5. Files root runs, and secrets only root may read. **Done.**
|
||||
6. The install path (federated.sh, the `[federated]` repo). **Done.**
|
||||
|
||||
@@ -165,29 +166,52 @@ since `check` scripts don't run with `set -e`.
|
||||
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.
|
||||
- The user's global git config had no name or email on 2026-11-16. A privacy
|
||||
hook refuses commands that put the user's email address on the command
|
||||
line (`git -c user.email=...`), so if it's still unset, ask the user to set
|
||||
it or to commit themselves. Throwaway test commits can use
|
||||
`Smoketest <smoketest@localhost>`.
|
||||
- The full 60-security run takes about 12 minutes; past the Bash tool's 10,
|
||||
so run it in the background.
|
||||
|
||||
## Next: step 4 in the smoketest VM
|
||||
## Done: step 4 (the commit "Keep other machines on the network from reaching Docker containers")
|
||||
|
||||
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.
|
||||
`network_checks` in `60-security.sh`. There's no second VM or bridged network
|
||||
(coredesktop-dev uses QEMU user networking), so the scenario makes two
|
||||
"other machines" inside the VM: network namespaces joined by veth pairs, whose
|
||||
traffic arrives on an ordinary interface like a LAN machine's. `lan` has
|
||||
private addresses (192.168.77.0/24, fd77:1::/64), `wan` public-looking ones
|
||||
(198.51.100.0/24, 2001:db8:77::/64). From each, over IPv4 and IPv6:
|
||||
- nmap `-p-` finds only 22 and 53317 open; a test listener on every address
|
||||
doesn't show
|
||||
- UDP 18091 doesn't answer; LocalSend's 53317 does (the control)
|
||||
- a container's published port can't be reached; containers on Docker's
|
||||
default bridge and on their own network still reach both machines; after
|
||||
`ufw-docker allow`, the LAN machine reaches the container
|
||||
- SSH offers only publickey, and tester's real password (`tester`) fails
|
||||
Plus: ufw is active, denies incoming, and has exactly the four allow rules;
|
||||
`sshd -T` (CamelCase names in this OpenSSH) has no passwords,
|
||||
keyboard-interactive or root login.
|
||||
|
||||
### 4. Network exposure
|
||||
It found: ufw-docker's rules let any private source (10/8, 172.16/12,
|
||||
192.168/16) reach published ports over IPv4, so anyone on the same Wi-Fi
|
||||
could. The user chose to block it. `system/docker-firewall.sh` replaces those
|
||||
lines with `-i docker0` and `-i br-+` RETURNs (run by `system/firewall.sh` and
|
||||
migration 1794878760); `tests/firewall.bats` tests it. People who reached a
|
||||
container from their LAN now need `sudo ufw-docker allow <container> <port>`.
|
||||
|
||||
`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
|
||||
Lessons: socat `UDP-RECVFROM,fork` answered only its first sender; loop a
|
||||
one-shot listener instead. Show a check's evidence on failure (the ufw-docker
|
||||
block, sshd -T's output) so a run explains itself.
|
||||
|
||||
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.
|
||||
## Follow-ups
|
||||
|
||||
- From steps 1 and 2 (above): deploy the new `receiver.py`; try Caddy's
|
||||
`request_buffers` for slow uploads; check how Gitea serves attached `.log`
|
||||
files; the daily report limit (ask before changing it).
|
||||
- The `tailscale0` allow rule isn't tested: it needs a Tailscale login.
|
||||
- Keep `ROOT_FILES` and `PAM_FILES` in `60-security.sh` up to date when
|
||||
CoreDesktop installs something new that root runs.
|
||||
- Check on a real machine which ports WinBoat's Windows container publishes,
|
||||
and on which addresses (not checked yet). The Docker fix keeps the LAN out
|
||||
of any it publishes on all addresses.
|
||||
|
||||
Reference in New Issue
Block a user