ci: exercise root guards under unprivileged uid
CI / tests-and-images (pull_request) Failing after 16s
Runner smoke test / runner-smoke (pull_request) Successful in 1s

This commit is contained in:
codex committed 2026-10-18 08:32:48 +03:00
1 parent 3a89dc2196
commit 436806a834
9 files changed
+121 -40

No files matched your search

+4 -1
View File
@@ -19,6 +19,8 @@ jobs:
run: python3 -m unittest discover -s tools/telegram-bot -p 'test_*.py' -v
- name: Run infrastructure backup tests
run: python3 -m unittest discover -s infra/backup -p 'test_*.py' -v
- name: Check root guard UID decisions
run: bash infra/bootstrap/test-root-guard.sh
- name: Check recovery host guard
run: bash infra/bootstrap/test-host-guard.sh
- name: Check verifier helper argument guard
@@ -42,7 +44,8 @@ jobs:
infra/bootstrap/verify.sh infra/bootstrap/verify-helper.sh infra/bootstrap/audit-host.sh \
infra/deploy/install-helper.sh infra/deploy/compose-helper.sh infra/deploy/test-compose-helper.sh \
infra/deploy/prepare-production-config.sh infra/deploy/test-production-config-guard.sh \
infra/bootstrap/test-audit-host.sh infra/bootstrap/test-verify-helper.sh \
infra/bootstrap/test-audit-host.sh infra/bootstrap/test-root-guard.sh \
infra/bootstrap/test-verify-helper.sh infra/test/run-as-unprivileged.sh \
infra/runner/install-runner.sh infra/runner/install-runner-lib.sh \
infra/runner/act-runner-healthcheck.sh infra/runner/test-runner-config.sh \
infra/runner/test-install-runner-idempotency.sh infra/runner/test-install-runner-guard.sh \
+14 -7
View File
@@ -185,10 +185,17 @@ automatic recovery step.
## Status
The owner reports that the repository-scoped runner is registered, appears
Idle in Gitea, and its rootless Docker daemon works. Gitea reported the smoke
workflow successful on PR head `69c62466` (run 62). The main CI job on that head
remained queued as run 61 because it requested `ubuntu-latest` instead of
`akyldash-ci`. This PR changes the target label and replaces job-container
Docker operations with digest-pinned Caddy and Kaniko container actions. The
new actions and their resource fit have not yet been verified on the VPS runner;
no VPS changes are part of this PR.
Idle in Gitea, and its rootless Docker daemon works; the report date was not
recorded. Gitea status checked 2026-10-18 showed smoke run 62 successful and CI
run 61 pending on head `69c62466`. That workflow requested `ubuntu-latest`,
while the smoke workflow used `akyldash-ci`; the label difference is a
plausible explanation for the pending status, but the runner inventory API
returned 403 and the scheduler's reason was not independently confirmed.
On head `3a89dc21`, Gitea reported CI run 63 failed at `Check host audit root
guard` and smoke run 64 succeeded. The job had not reached Caddy or Kaniko, so
their execution and resource fit remain unverified. This PR changes the root
guard tests to use `setpriv` for their negative path when a job starts as UID 0.
A separate test evaluates the extracted host-audit guard with simulated UID 0
and UID 65534; the real audit, config setup, and runner installer are never
executed as root by those tests. No VPS changes are part of this PR.
+27 -24
View File
@@ -49,11 +49,13 @@ UFW rule details, and protected file metadata remain unverified.
PRs enabled. `main` is protected and requires one approval; the current API
principal cannot push or merge directly to `main`.
- The repository runner-list API returns `403` because this API principal is
not the repository owner. On PR head `69c62466`, Gitea reported runner smoke
success (run 62) while the main CI job remained queued (run 61) because its
workflow label did not match the registered runner. The owner reports the
repository runner is registered and Idle and rootless Docker is working.
Runner inventory and package publishing permissions remain unverified.
not the repository owner. Gitea status checked 2026-10-18 showed smoke run 62
successful and CI run 61 pending on PR head `69c62466`. That workflow used
`ubuntu-latest`, while the smoke workflow used `akyldash-ci`; this label
difference is a plausible explanation, not a confirmed scheduler diagnosis.
The owner reports that the runner is registered and Idle and rootless Docker
works (report date not recorded). Runner inventory and package publishing
permissions remain unverified.
- No public application listener is observed on TCP `80`/`443`. Docker
container/volume state still requires the root audit. Repository Compose describes
Caddy `2.11.6` pinned by digest, Python Search API `0.11.3`, SQLite
@@ -88,13 +90,14 @@ UFW rule details, and protected file metadata remain unverified.
3 GiB RAM, 512 processes), account slice limits (2.5 CPU, 4 GiB RAM, 2048
tasks), rotated file logs, and a systemd health timer. Jobs target the
`akyldash-ci` label and do not receive either Docker socket. The owner reports
that runner registration and rootless Docker are working. Gitea reported the
smoke workflow successful for PR head `69c62466` (run 62). The CI job on that
head was queued as run 61 because the workflow still requested `ubuntu-latest`;
this PR updates the label and moves container-dependent validation into
digest-pinned actions. No VPS changes are made by this PR; the updated actions
and their fit within the configured 3 GiB / 2 CPU per-job limits remain to be
verified by the new CI run.
that runner registration and rootless Docker work (report date not recorded).
Gitea status checked 2026-10-18 showed smoke run 62 successful and CI run 61
pending on PR head `69c62466`. The workflow/label difference may explain that
pending status, but the scheduler reason was not independently verified. On
head `3a89dc21`, CI run 63 failed at the host audit root guard and smoke run 64
succeeded; Caddy and Kaniko steps were skipped. No VPS changes are made by
this PR. The new actions and fit within the configured 3 GiB / 2 CPU per-job
limits remain unverified.
- An isolated local Compose smoke test built backend/OpenSearch images,
reached healthy status for OpenSearch, backend, and Caddy, and returned HTTP
200 for `/review` through Caddy. Its containers, networks, and volumes were
@@ -112,8 +115,10 @@ UFW rule details, and protected file metadata remain unverified.
and restore of real production data remain unverified because production is
not deployed.
- Cloudflare edge response was checked; origin DNS target, origin certificate,
Full (strict), runner registration/Online state, registry publishing, and production
deployment have not been verified.
Full (strict), registry publishing, successful Caddy/Kaniko action execution,
runner resource fit, and production deployment have not been verified. The
owner-reported Idle state has not been independently checked through runner
inventory because the API returned 403.
- This audit made no host changes. No package or service was installed by this
audit; the owner performed the initial bootstrap beforehand.
@@ -131,13 +136,10 @@ UFW rule details, and protected file metadata remain unverified.
3. Run `sudo bash /opt/akyldash/current/infra/deploy/install-helper.sh` after
reviewing the checkout; it grants only fixed verification, Compose
`config`/`status`, and guarded rollback commands.
4. After PR review and root audit, run
`sudo bash /opt/akyldash/current/infra/runner/install-runner.sh`. In the
repository Settings → Actions → Runners create a repository-level runner;
enter the token only at the interactive registration prompt as documented
in [CI_RUNNER.md](CI_RUNNER.md). Then enable the runner and health timer,
confirm **Online**, and dispatch the smoke workflow. Production deployment
remains manual and has no CI job.
4. After PR review, inspect the latest CI and smoke runs on `akyldash-ci`.
Confirm both pinned container actions complete within the configured per-job
CPU, memory, and disk limits. Production deployment remains manual and has
no CI job.
5. Test backup/restore and rollback only with synthetic data in an isolated
environment before any production deployment.
@@ -146,6 +148,7 @@ UFW rule details, and protected file metadata remain unverified.
The branch targets `akyldash-ci` and uses digest-pinned isolated actions for
Caddy validation and the two production Dockerfile builds. Kaniko image
publishing and cache publishing are disabled. This repository change does not
modify the VPS or grant workflow containers a Docker socket. The Gitea CI run
must confirm action execution and resource fit before this becomes validated
runner state.
modify the VPS or grant workflow containers a Docker socket. Gitea CI run 63 failed at the host audit root-guard test before reaching
Caddy or Kaniko actions. The smoke run succeeded. This PR updates the root-guard
tests; a later successful run must verify the container actions and resource
fit before they are considered validated runner behavior.
+5 -2
View File
@@ -1,10 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir=$(dirname "${BASH_SOURCE[0]}")
source "$script_dir/../test/run-as-unprivileged.sh"
output=$(mktemp)
trap 'rm -f "$output"' EXIT
if bash "$(dirname "$0")/audit-host.sh" >"$output" 2>&1; then
echo 'Host audit unexpectedly succeeded without root.' >&2
if run_as_unprivileged bash "$script_dir/audit-host.sh" >"$output" 2>&1; then
echo 'Host audit unexpectedly succeeded as an unprivileged UID.' >&2
exit 1
fi
grep -qx 'Run this read-only audit as root.' "$output"
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir=$(dirname "${BASH_SOURCE[0]}")
guard=$(mktemp)
output=$(mktemp)
trap 'rm -f "$guard" "$output"' EXIT
awk '
/^if \[\[ \$EUID -ne 0 \]\]; then$/ { capture = 1 }
capture { print }
capture && /^fi$/ { found = 1; exit }
END { if (!found) exit 1 }
' "$script_dir/audit-host.sh" | sed 's/\$EUID/\$TEST_EUID/g' >"$guard" || {
echo 'Could not extract the host audit root guard.' >&2
exit 1
}
if ! grep -Fq 'if [[ $TEST_EUID -ne 0 ]]; then' "$guard"; then
echo 'Extracted guard does not use the simulated effective UID.' >&2
exit 1
fi
if TEST_EUID=0 bash "$guard" >"$output" 2>&1; then
[[ ! -s $output ]] || { cat "$output" >&2; exit 1; }
else
echo 'Host audit root guard rejected simulated UID 0.' >&2
exit 1
fi
if TEST_EUID=65534 bash "$guard" >"$output" 2>&1; then
echo 'Host audit root guard accepted simulated non-root UID.' >&2
exit 1
fi
grep -qx 'Run this read-only audit as root.' "$output"
echo 'PASS host audit root guard accepts UID 0 and rejects non-root UIDs'
+5 -2
View File
@@ -1,10 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir=$(dirname "${BASH_SOURCE[0]}")
source "$script_dir/../test/run-as-unprivileged.sh"
output=$(mktemp)
trap 'rm -f "$output"' EXIT
if bash "$(dirname "$0")/prepare-production-config.sh" >"$output" 2>&1; then
echo 'Production config setup unexpectedly succeeded without root.' >&2
if run_as_unprivileged bash "$script_dir/prepare-production-config.sh" >"$output" 2>&1; then
echo 'Production config setup unexpectedly succeeded as an unprivileged UID.' >&2
exit 1
fi
grep -qx 'Run this configuration step as root.' "$output"
+15 -2
View File
@@ -17,8 +17,21 @@ if grep -Eq 'docker (build|run)([[:space:]]|$)' "$workflow"; then
echo 'workflow must not invoke docker build/run in a job container' >&2
exit 1
fi
grep -Fq -- '--no-push' "$kaniko_action"
grep -Fq -- '--no-push-cache' "$kaniko_action"
check_kaniko_publish_flags() {
grep -Fxq -- ' - --no-push' "$1" &&
grep -Fxq -- ' - --no-push-cache' "$1"
}
if ! check_kaniko_publish_flags "$kaniko_action"; then
echo 'Kaniko must disable image and cache publishing with separate arguments.' >&2
exit 1
fi
without_no_push=$(mktemp)
trap 'rm -f "$without_no_push"' EXIT
sed '/^ - --no-push$/d' "$kaniko_action" >"$without_no_push"
if check_kaniko_publish_flags "$without_no_push"; then
echo 'CI isolation test accepted --no-push-cache without standalone --no-push.' >&2
exit 1
fi
grep -Fq 'FROM ghcr.io/osscontainertools/kaniko:v1.28.5-debug@sha256:c73ca67a3b494bce79a8fb6090c4f73c18997ab272d80bffc460a62343aeb412' .gitea/actions/kaniko-build/Dockerfile
grep -Fq 'FROM caddy:2.11.6-alpine@sha256:881bbc60f9986d5ab8e7cfd6cf7e4ef3c9c0439fef2429d035d065577882f028' .gitea/actions/caddy-validate/Dockerfile
if grep -REn 'docker.sock|privileged:|container.options:|^[[:space:]]*volumes:' "$workflow" .gitea/actions/kaniko-build .gitea/actions/caddy-validate; then
+5 -2
View File
@@ -1,10 +1,13 @@
#!/usr/bin/env bash
set -Eeuo pipefail
script_dir=$(dirname "${BASH_SOURCE[0]}")
source "$script_dir/../test/run-as-unprivileged.sh"
output=$(mktemp)
trap 'rm -f "$output"' EXIT
if bash "$(dirname "$0")/install-runner.sh" >"$output" 2>&1; then
echo 'Runner installer unexpectedly succeeded without root.' >&2
if run_as_unprivileged bash "$script_dir/install-runner.sh" >"$output" 2>&1; then
echo 'Runner installer unexpectedly succeeded as an unprivileged UID.' >&2
exit 1
fi
grep -qx 'ERROR: run this script as root' "$output"
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
run_as_unprivileged() {
if [[ $EUID -eq 0 ]]; then
if ! command -v setpriv >/dev/null 2>&1; then
echo 'setpriv is required to run guard tests as an unprivileged UID.' >&2
return 127
fi
setpriv --reuid=65534 --regid=65534 --clear-groups -- "$@"
else
"$@"
fi
}