Test the install path
shellcheck / shellcheck (push) Failing after 20s

60-security.sh now also checks the way in: federated.sh sends wget to
install.sh on Gitea over HTTPS at every hop, plain HTTP goes to HTTPS
without serving the script, and a browser goes to the Install page.

For the [federated] repo, it checks that pacman.conf needs signatures on
packages and the database, gets them from Gitea over HTTPS, and lists
the repo after core and extra; that pacman trusts the pinned key; and
that Gitea's repository.key is that key alone. Then it serves a package
from a stand-in repo with [federated]'s settings and pacman's keyring:
pacman refuses it unsigned, signed by a key it doesn't have or doesn't
trust, or in a signed database but unsigned itself, and installs it when
its key is trusted.

It found nothing to fix. Each repo check was shown to fail with
[federated] weakened, moved above core, or its key deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 17:38:56 -07:00
co-authored by Claude Opus 5.5
parent d5925fa551
commit 53c6c8b52e
2 changed files with 177 additions and 15 deletions
@@ -1,6 +1,6 @@
---
name: coredesktop-security-checks
description: 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.
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.
---
# CoreDesktop's security checks
@@ -26,7 +26,7 @@ leak data or give away control, in this order:
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. **Done.**
6. The install path (federated.sh, the `[federated]` repo).
6. The install path (federated.sh, the `[federated]` repo). **Done.**
The pacman guard (`system/pacman-guard`) is
a safety net against mistakes, not a security control: anyone with sudo gets
@@ -129,6 +129,32 @@ 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.
## Done: step 6 (the commit "Test the install path")
`install_path_checks` in `60-security.sh`. It found nothing to fix.
- federated.sh, live: wget is redirected to install.sh on Gitea, every hop
HTTPS (`curl --proto-redir =https`); real wget gets it; plain HTTP
redirects to HTTPS without serving the script; a browser goes to
coredesktop.computer. install.sh's shebang is `#!/bin/bash -i`. The
nightly run fails if federated.sh or Gitea is down.
- `[federated]` in pacman.conf is exactly `SigLevel = Required
DatabaseRequired` and the HTTPS server, after `[core]` and `[extra]`; the
pinned key is fully trusted; Gitea's repository.key is that key alone.
- A stand-in repo (a package built in the VM, served from files, with
`[federated]`'s real settings and keyring, installed into a throwaway
root): pacman refuses it unsigned, signed by an unknown key, signed by a
key it has but doesn't trust, and with a signed database but unsigned
package; the control, its key trusted in a copy of the keyring, installs.
- Code scan: every download piped to bash or pacman-key is HTTPS; no
`--insecure` or weak SigLevel.
- pacman can't pin a repo to one key: `Required` takes any trusted key,
Arch packagers' too. Not fixable in CoreDesktop.
A sabotage run (SigLevel `Optional TrustAll`, `[federated]` above `[core]`,
the key deleted) failed the matching checks, and found a check that tested
only its last line: give a check's tests `&&`, or end on the one that counts,
since `check` scripts don't run with `set -e`.
## Running the smoketest
- `coredesktop-dev smoketest run 60-security`, outside Claude Code's sandbox
@@ -142,7 +168,7 @@ needs an SMB server.
- 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
## Next: step 4 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
@@ -165,11 +191,3 @@ 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.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.
+148 -4
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# shellcheck disable=SC2034,SC2016
DESCRIPTION="security: what an agent in the sandbox can't do, and what root runs"
# shellcheck disable=SC2034,SC2016,SC2028
DESCRIPTION="security: the agent sandbox, what root runs, and the install path"
IMAGE=installed
TIER="nightly"
@@ -15,8 +15,9 @@ TIER="nightly"
#
# Step 5, below the sandbox's: what root runs is root's alone, nothing root runs
# is in a user's home, and a security key or fingerprint for sudo keeps the
# password working. Steps 4 (network exposure, which needs a second machine)
# and 6 (the install path) are still to come.
# password working. Step 6, last: federated.sh hands out install.sh over HTTPS
# only, and pacman takes [federated]'s packages only when signed by a key it
# trusts. Step 4 (network exposure) needs a second machine and is still to come.
AGENTS=(opencode hermes cline-desktop)
FAKE_BIN="\$HOME/smoketest-agents"
@@ -319,6 +320,148 @@ root_checks() {
check "pam: after: no password at all doesn't" "! $(as_pam_user 'timeout 60 sudo -S -k true < /dev/null')"
}
# --- Step 6: the install path ------------------------------------------------
# What README.md tells people to run is wget -qO- https://federated.sh | bash
WGET_UA="Wget/1.25.0"
BROWSER_UA="Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0"
INSTALL_SH_URL="https://gitea.federated.computer/Federated_Computer/coredesktop/raw/branch/main/install.sh"
# Stand-in [federated] repos, served from files
FAKE_REPOS="$SMOKETEST_VM_DIR/federated-repos"
# The pinned key and the repo's URL, from the installed utils.sh
FEDERATED_VARS='
utils=$HOME/.local/share/coredesktop/utils.sh
key=$(sed -n "s/^FEDERATED_REPO_KEY=\"\(.*\)\"$/\1/p" "$utils")
url=$(sed -n "s/^FEDERATED_REPO_URL=\"\(.*\)\"$/\1/p" "$utils")
[ -n "$key" ] && [ -n "$url" ] || { echo "no FEDERATED_REPO_KEY or URL in $utils"; exit 1; }
'
# Build a package and the stand-in repos:
# unsigned nothing signed
# signed package and database signed by a throwaway key
# unsigned-pkg database signed by that key, package not
# The throwaway key's public half is in $FAKE_REPOS/key.asc
setup_fake_repos() {
assert_vm "build a package and stand-in [federated] repos" "set -e
rm -rf $FAKE_REPOS && mkdir -p $FAKE_REPOS/build $FAKE_REPOS/gnupg
chmod 700 $FAKE_REPOS/gnupg
export GNUPGHOME=$FAKE_REPOS/gnupg
gpg --batch --quiet --passphrase '' --quick-gen-key 'Smoketest Not Federated <smoketest@localhost>' ed25519 sign never
fpr=\$(gpg --with-colons --list-keys | awk -F: '\$1 == \"fpr\" { print \$10; exit }')
echo \"\$fpr\" > $FAKE_REPOS/key.fpr
gpg --armor --export \"\$fpr\" > $FAKE_REPOS/key.asc
cd $FAKE_REPOS/build
printf '%s\n' 'pkgname=smoketest-fake' 'pkgver=1' 'pkgrel=1' 'arch=(any)' 'options=(!debug)' \
'package() { install -Dm644 /dev/null \"\$pkgdir/usr/share/smoketest-fake\"; }' > PKGBUILD
makepkg --nodeps --force > /dev/null 2>&1
pkg=\$(ls smoketest-fake-1-1-any.pkg.tar.*)
for repo in unsigned signed unsigned-pkg; do
mkdir -p $FAKE_REPOS/\$repo && cp \"\$pkg\" $FAKE_REPOS/\$repo/
done
gpg --batch --quiet --detach-sign --no-armor -u \"\$fpr\" -o $FAKE_REPOS/signed/\$pkg.sig \"\$pkg\"
repo-add -q $FAKE_REPOS/unsigned/federated.db.tar.gz $FAKE_REPOS/unsigned/\$pkg
repo-add -q --sign --key \"\$fpr\" $FAKE_REPOS/signed/federated.db.tar.gz $FAKE_REPOS/signed/\$pkg
repo-add -q --sign --key \"\$fpr\" $FAKE_REPOS/unsigned-pkg/federated.db.tar.gz $FAKE_REPOS/unsigned-pkg/\$pkg
chmod -R a+rX $FAKE_REPOS
chmod 700 $FAKE_REPOS/gnupg
# Keyrings for the control and for a key that's there but not trusted: copies
# of pacman's, so the real one isn't changed
for ring in trusted untrusted; do
sudo rm -rf $FAKE_REPOS/keyring-\$ring
sudo cp -a /etc/pacman.d/gnupg $FAKE_REPOS/keyring-\$ring
sudo pacman-key --gpgdir $FAKE_REPOS/keyring-\$ring --add $FAKE_REPOS/key.asc > /dev/null 2>&1
done
sudo pacman-key --gpgdir $FAKE_REPOS/keyring-trusted --lsign-key \"\$fpr\" > /dev/null 2>&1"
}
# install_from REPO [KEYRING]: a VM script that installs smoketest-fake from
# the stand-in REPO into a throwaway root, with [federated]'s settings from
# /etc/pacman.conf and pacman's keyring (or KEYRING, a copy of it). Prints
# pacman's output; succeeds only if the package was installed.
install_from() {
local gpgdir=""
[ -n "${2:-}" ] && gpgdir="--gpgdir $FAKE_REPOS/keyring-$2"
echo "set -o pipefail
root=\$(mktemp -d)
sudo mkdir -p \$root/var/lib/pacman \$root/cache \$root/hooks
# [options] and [federated] as they are, but served from the stand-in.
# DownloadUser would download as alpm, which can't write the throwaway
# cache; that's the download sandbox, not signature checking.
awk '/^\\[/ { section = \$0 } section == \"[options]\" || section == \"[federated]\"' /etc/pacman.conf \
| sed -e 's#^Server *=.*#Server = file://$FAKE_REPOS/$1#' -e '/^DownloadUser/d' > \$root.conf
grep -q '^\\[federated\\]' \$root.conf || { echo 'no [federated] in /etc/pacman.conf'; exit 1; }
sudo timeout 120 pacman --config \$root.conf --root \$root --dbpath \$root/var/lib/pacman \
--cachedir \$root/cache --hookdir \$root/hooks --disable-sandbox $gpgdir \
--noconfirm -Sy smoketest-fake 2>&1
[ -e \$root/usr/share/smoketest-fake ]"
}
# refused REPO [KEYRING]: installing from REPO fails, and for a signature's
# sake: a bad one, or a missing .sig file, which Required asks for
refused() {
echo "out=\$($(install_from "$@"))
status=\$?
printf '%s\n' \"\$out\"
[ \$status -ne 0 ] || { echo 'pacman installed it'; exit 1; }
grep -qiE 'signature|\\.sig|PGP|key' <<< \"\$out\" || { echo 'pacman failed, but not over a signature'; exit 1; }"
}
install_path_checks() {
# --- federated.sh ---
check "install: federated.sh sends wget to install.sh on Gitea, over HTTPS" "
read -r code location < <(curl -sS -o /dev/null -w '%{http_code} %{redirect_url}' -A $(q "$WGET_UA") https://federated.sh/)
echo \"\$code \$location\"
[[ \$code == 30[1278] ]] && [ \"\$location\" = $(q "$INSTALL_SH_URL") ]"
check "install: every hop from federated.sh to the script is HTTPS, and it's a bash script" "
first=\$(curl --proto =https --proto-redir =https -fsSL -A $(q "$WGET_UA") https://federated.sh/ 2> /dev/null | head -n 1)
echo \"\$first\"
[[ \$first == '#!/bin/bash'* ]]"
check "install: wget itself gets the script" "
command -v wget > /dev/null || { echo 'no wget in the VM'; exit 1; }
first=\$(wget -qO- https://federated.sh | head -n 1)
echo \"\$first\"
[[ \$first == '#!/bin/bash'* ]]"
check "install: plain HTTP to federated.sh goes to HTTPS and doesn't serve the script" "
body=\$(mktemp)
read -r code location < <(curl -sS -o \$body -w '%{http_code} %{redirect_url}' -A $(q "$WGET_UA") http://federated.sh/)
echo \"\$code \$location\"
[[ \$code == 30[1278] && \$location == https://* ]] && ! grep -q '^#!' \$body"
check "install: a browser goes to the Install page, over HTTPS" "
read -r code location < <(curl -sS -o /dev/null -w '%{http_code} %{redirect_url}' -A $(q "$BROWSER_UA") https://federated.sh/)
echo \"\$code \$location\"
[[ \$code == 30[1278] && \$location == https://coredesktop.computer/* ]]"
# --- The [federated] repo ---
check "install: [federated] needs signatures on packages and database, from Gitea over HTTPS" "$FEDERATED_VARS
section=\$(awk '/^\\[/ { f = (\$0 == \"[federated]\") ; next } f' /etc/pacman.conf | grep -v '^[[:space:]]*\\(#\\|\$\\)')
printf '%s\n' \"\$section\"
[ \"\$section\" = \"\$(printf 'SigLevel = Required DatabaseRequired\nServer = %s/\$repo/\$arch' \"\$url\")\" ] \
&& [[ \$url == https://* ]]"
check "install: [federated] comes after core and extra, so it can't stand in for Arch's packages" "
line() { grep -n \"^\\[\$1\\]\" /etc/pacman.conf | cut -d: -f1; }
f=\$(line federated); c=\$(line core); e=\$(line extra)
echo \"core \$c, extra \$e, federated \$f\"
[ -n \"\$f\" ] && [ \"\$f\" -gt \"\$c\" ] && [ \"\$f\" -gt \"\$e\" ]"
check "install: pacman trusts the pinned key" "$FEDERATED_VARS
validity=\$(sudo gpg --homedir /etc/pacman.d/gnupg --with-colons --list-keys \"\$key\" 2> /dev/null | awk -F: '\$1 == \"pub\" { print \$2 }')
echo \"\$key: validity \$validity\"
[[ \$validity == [fu] ]]"
check "install: Gitea's repository.key is the pinned key and no other" "$FEDERATED_VARS
home=\$(mktemp -d)
keys=\$(curl -fsSL \"\$url/repository.key\" | gpg --homedir \$home --with-colons --show-keys 2> /dev/null \
| awk -F: '\$1 == \"pub\" { getline; print \$10 }')
echo \"\$keys\"
[ \"\$keys\" = \"\$key\" ]"
setup_fake_repos
check "install: control: pacman installs from a repo signed by a key it trusts" "$(install_from signed trusted)"
check "install: pacman refuses a repo with nothing signed" "$(refused unsigned)"
check "install: pacman refuses a repo signed by a key it doesn't have" "$(refused signed)"
check "install: pacman refuses a repo signed by a key it has but doesn't trust" "$(refused signed untrusted)"
check "install: pacman refuses an unsigned package from a signed repo" "$(refused unsigned-pkg trusted)"
}
sandbox_checks() {
local agent secret lan="http://\$(cat \$HOME/smoketest-lan-ip)"
@@ -390,6 +533,7 @@ sandbox_checks() {
scenario() {
sandbox_checks
root_checks
install_path_checks
if [ ${#FAILED[@]} -gt 0 ]; then
printf 'failed: %s\n' "${FAILED[@]}"