ops: Forgejo runner-isolation review + branch protection follow-ups (from #14) #146

Open
opened 2026-11-11 02:13:05 +01:00 by amiryahaya · 1 comment
Owner

Follow-ups from #14 (closed) — Forgejo-admin items. Branch protection: DONE 2026-11-11 (see below). Runner isolation: review + open decisions.

DONE — branch protection on main (via API /branch_protections, Forgejo 17)

  • Required status check: "Security CI / security-scan" for BOTH pull_request and push contexts (chosen deliberately: api-ci + staging-deploy are paths-filtered, so requiring them would wedge docs-only/clients-only changes forever).
  • Direct pushes: whitelisted to amiryahaya only; force-push and branch deletion blocked (protected-branch defaults).
  • Consequence: PR merges now REQUIRE a green security-scan on the PR head. If a security-ci leg flakes, re-run it before merge.
  • Note: api-ci stays a REVIEW-gate discipline (the no-merge-without-green rule) — protection can't require it without wedging paths-filtered merges.

Runner-isolation review (2026-11-11, grounded in the workflow tree)

Secrets inventory on runners: REGISTRY_USER/TOKEN (cd, staging-deploy), STAGING_SSH_KEY/USER/HOST/KNOWN_HOSTS (staging-deploy — the runner holds a working SSH key INTO the staging VPS), Sentry DSN, and the release fleet's Apple/Google/Tauri secrets (APPLE_* x10, ANDROID_KEYSTORE_*, PLAY_STORE_SERVICE_ACCOUNT_JSON, TAURI_SIGNING_PRIVATE_KEY).

Findings:

  1. GOOD: staging-deploy + cd fire only on main pushes (never PRs), so PR jobs never handle deploy credentials; client CI workflows reference no secrets at all (secrets only inject where explicitly used).
  2. GOOD: the staging SSH key is scoped to the deploy user on one box (staging, not prod).
  3. RISK — main-branch jobs build attacker-influenceable code with secrets present: staging-deploy runs npm install + docker build on whatever lands on main. A compromised dependency at merge time could exfiltrate REGISTRY_TOKEN/STAGING_SSH_KEY from a build step. Mitigations to consider: (a) registry token scoped to package-write on api only, (b) STAGING_SSH_KEY restricted in authorized_keys (restrict + from=runner-egress-IP if static), (c) rotation cadence for both.
  4. RISK — macos-15 runner holds the MOST sensitive secret set (Apple certs, provisioning profiles, Tauri signing key) in desktop-release/ios-release. Review needed: is that runner dedicated to releases, is the job's keychain import cleaned up post-run, is the runner user non-admin, any other workloads sharing it?
  5. HARDENING — act runner containers should be strictly ephemeral: no shared persistent caches across jobs/repos, no host docker socket reachable from job containers, resource limits set. Where do the ubuntu-latest runners physically run (user infra — not visible from the repo)? That answer completes this review.
  6. QUIRK (cosmetic, observed 2026-11-11): cancelled-then-rerun jobs leave a STALE failure commit-status (7f853c8 staging-deploy shows failure although runs 38183/38197 succeeded). Don't trust commit statuses; poll run IDs.

Open actions (Forgejo-admin)

  • Confirm/decide runner hosting + apply finding 5 hardening
  • Registry token scoping + rotation cadence (finding 3a)
  • authorized_keys restriction options for the staging deploy key (finding 3b)
  • macos runner isolation review (finding 4)
Follow-ups from #14 (closed) — Forgejo-admin items. Branch protection: DONE 2026-11-11 (see below). Runner isolation: review + open decisions. ## DONE — branch protection on main (via API /branch_protections, Forgejo 17) - Required status check: "Security CI / security-scan" for BOTH pull_request and push contexts (chosen deliberately: api-ci + staging-deploy are paths-filtered, so requiring them would wedge docs-only/clients-only changes forever). - Direct pushes: whitelisted to amiryahaya only; force-push and branch deletion blocked (protected-branch defaults). - Consequence: PR merges now REQUIRE a green security-scan on the PR head. If a security-ci leg flakes, re-run it before merge. - Note: api-ci stays a REVIEW-gate discipline (the no-merge-without-green rule) — protection can't require it without wedging paths-filtered merges. ## Runner-isolation review (2026-11-11, grounded in the workflow tree) Secrets inventory on runners: REGISTRY_USER/TOKEN (cd, staging-deploy), STAGING_SSH_KEY/USER/HOST/KNOWN_HOSTS (staging-deploy — the runner holds a working SSH key INTO the staging VPS), Sentry DSN, and the release fleet's Apple/Google/Tauri secrets (APPLE_* x10, ANDROID_KEYSTORE_*, PLAY_STORE_SERVICE_ACCOUNT_JSON, TAURI_SIGNING_PRIVATE_KEY). Findings: 1. GOOD: staging-deploy + cd fire only on main pushes (never PRs), so PR jobs never handle deploy credentials; client CI workflows reference no secrets at all (secrets only inject where explicitly used). 2. GOOD: the staging SSH key is scoped to the `deploy` user on one box (staging, not prod). 3. RISK — main-branch jobs build attacker-influenceable code with secrets present: staging-deploy runs npm install + docker build on whatever lands on main. A compromised dependency at merge time could exfiltrate REGISTRY_TOKEN/STAGING_SSH_KEY from a build step. Mitigations to consider: (a) registry token scoped to package-write on api only, (b) STAGING_SSH_KEY restricted in authorized_keys (restrict + from=runner-egress-IP if static), (c) rotation cadence for both. 4. RISK — macos-15 runner holds the MOST sensitive secret set (Apple certs, provisioning profiles, Tauri signing key) in desktop-release/ios-release. Review needed: is that runner dedicated to releases, is the job's keychain import cleaned up post-run, is the runner user non-admin, any other workloads sharing it? 5. HARDENING — act runner containers should be strictly ephemeral: no shared persistent caches across jobs/repos, no host docker socket reachable from job containers, resource limits set. Where do the ubuntu-latest runners physically run (user infra — not visible from the repo)? That answer completes this review. 6. QUIRK (cosmetic, observed 2026-11-11): cancelled-then-rerun jobs leave a STALE failure commit-status (7f853c8 staging-deploy shows failure although runs 38183/38197 succeeded). Don't trust commit statuses; poll run IDs. ## Open actions (Forgejo-admin) - [ ] Confirm/decide runner hosting + apply finding 5 hardening - [ ] Registry token scoping + rotation cadence (finding 3a) - [ ] authorized_keys restriction options for the staging deploy key (finding 3b) - [ ] macos runner isolation review (finding 4)
Author
Owner

Runner-isolation review — findings from infra inspection (2026-11-13)

Answering the open action "Confirm/decide runner hosting + apply finding 5 hardening" with grounded facts. Three self-hosted runner VMs + the Forgejo box, all inventoried over SSH:

Host ssh alias IP Role
vmi3274797 forgejo-runner 194.233.80.53 act_runner (systemd, user runner)
vmi3642298 forgejo-runner-1 84.247.154.32 act_runner
vmi3642297 forgejo-runner-2 84.247.152.71 act_runner
forgejo forgejo 194.233.72.232:2222 Forgejo instance (not on the staging VPS)

All Ubuntu (kernel 6.8, x86_64), act_runner daemon as systemd unit, config at /home/runner/act_runner/config.yml.

New findings

F1 — every job container mounts the host docker socket. All three runners ship:

container:
  options: "--cap-add=SYS_PTRACE -v /var/run/docker.sock:/var/run/docker.sock"
  valid_volumes: ["**"]

Any job on any project these runners serve = effective root on the runner host (docker socket → host root; plus SYS_PTRACE granted). Combined with finding 3 (staging-deploy runs attacker-influenceable code on main), the blast radius of a compromised dependency is: runner host root → runner's ssh keys/env (REGISTRY_TOKEN, STAGING_SSH_KEY are in the runner's job env, not just the workflow scope) → staging VPS deploy user.

F2 — runners are shared across projects. Concurrent PKI-project jobs (pki-ci-base:1, node:20-bullseye) observed on all three VMs. No repo/project-level runner separation: a PR job from any connected repo shares the same docker-socket-mounted containers as our deploy jobs.

F3 — macos-15 label does not exist on any runner. Labels registered: ubuntu-latest, ubuntu-22.04, ubuntu-20.04, rust, dotnet, release-builder, elixir (all docker://forgejo-fix/*). No macOS host anywhere in the fleet → desktop-release.yml / ios-release.yml (runs-on: macos-15) can never be picked up — releases would queue forever. The Apple/Google/Tauri secrets are currently unreachable dead weight. Decision needed: provision a Mac runner with that label, or re-point release workflows at a Linux label (cross-compile / fastlane lane review) and remove the Apple secret surface.

F4 — shared persistent cache per runner. cache.enabled: true with a shared dir across all jobs/repos on each runner (finding 5's cache concern confirmed).

F5 — deploy-failure monitoring gap (today's incident). Staging API crash-looped ~21h (2026-11-12 14:04 → 2026-11-13 hotfix #195) and every staging-deploy run failed its smoke step the whole time — noticed only by accident. Cheapest fix: a cron probe on the staging VPS (curl -f http://127.0.0.1:8080/health/) that opens/updates a Forgejo issue on repeated failure, plus (optionally) a Forgejo webhook on failed main-branch runs.

Proposed decisions (Forgejo-admin)

  • D1 (F1/F2, biggest) — stop mounting docker.sock into job containers by default: drop the -v from options, drop SYS_PTRACE, and set valid_volumes to []; jobs needing docker (staging-deploy, cd) move to a dedicated deploy label on a runner whose config keeps the socket (ideally a socket proxy with a scoped API, or rootless docker). Alternative minimal step: keep the socket but remove valid_volumes: ["**"] so arbitrary volumes: in workflows can't mount anything else.
  • D2 (F3) — decide macos-15: Mac runner vs Linux release path vs defer releases.
  • D3 (finding 3a) — scope REGISTRY_TOKEN to package-write on api only + rotation cadence (quarterly?), same for STAGING_SSH_KEY.
  • D4 (finding 3b) — restrict the deploy key in staging authorized_keys: restrict,command="..." or from= the runner egress IPs (194.233.80.53, 84.247.154.32, 84.247.152.71) if egress is static.
  • D5 (F5) — add the health cron + failure issue bot.

Related: #196 (migration smoke test — the incident root cause), PR #195 (the hotfix).

## Runner-isolation review — findings from infra inspection (2026-11-13) Answering the open action "Confirm/decide runner hosting + apply finding 5 hardening" with grounded facts. **Three self-hosted runner VMs + the Forgejo box, all inventoried over SSH:** | Host | ssh alias | IP | Role | |---|---|---|---| | vmi3274797 | forgejo-runner | 194.233.80.53 | act_runner (systemd, user `runner`) | | vmi3642298 | forgejo-runner-1 | 84.247.154.32 | act_runner | | vmi3642297 | forgejo-runner-2 | 84.247.152.71 | act_runner | | forgejo | forgejo | 194.233.72.232:2222 | Forgejo instance (not on the staging VPS) | All Ubuntu (kernel 6.8, x86_64), `act_runner` daemon as systemd unit, config at `/home/runner/act_runner/config.yml`. ### New findings **F1 — every job container mounts the host docker socket.** All three runners ship: ```yaml container: options: "--cap-add=SYS_PTRACE -v /var/run/docker.sock:/var/run/docker.sock" valid_volumes: ["**"] ``` Any job on any project these runners serve = effective root on the runner host (docker socket → host root; plus `SYS_PTRACE` granted). Combined with finding 3 (staging-deploy runs attacker-influenceable code on main), the blast radius of a compromised dependency is: runner host root → runner's ssh keys/env (REGISTRY_TOKEN, STAGING_SSH_KEY are in the *runner's* job env, not just the workflow scope) → staging VPS deploy user. **F2 — runners are shared across projects.** Concurrent PKI-project jobs (`pki-ci-base:1`, `node:20-bullseye`) observed on all three VMs. No repo/project-level runner separation: a PR job from any connected repo shares the same docker-socket-mounted containers as our deploy jobs. **F3 — `macos-15` label does not exist on any runner.** Labels registered: `ubuntu-latest`, `ubuntu-22.04`, `ubuntu-20.04`, `rust`, `dotnet`, `release-builder`, `elixir` (all `docker://forgejo-fix/*`). No macOS host anywhere in the fleet → `desktop-release.yml` / `ios-release.yml` (`runs-on: macos-15`) can never be picked up — releases would queue forever. The Apple/Google/Tauri secrets are currently unreachable dead weight. **Decision needed:** provision a Mac runner with that label, or re-point release workflows at a Linux label (cross-compile / fastlane lane review) and remove the Apple secret surface. **F4 — shared persistent cache per runner.** `cache.enabled: true` with a shared dir across all jobs/repos on each runner (finding 5's cache concern confirmed). **F5 — deploy-failure monitoring gap (today's incident).** Staging API crash-looped ~21h (2026-11-12 14:04 → 2026-11-13 hotfix #195) and every staging-deploy run failed its smoke step the whole time — noticed only by accident. Cheapest fix: a cron probe on the staging VPS (`curl -f http://127.0.0.1:8080/health/`) that opens/updates a Forgejo issue on repeated failure, plus (optionally) a Forgejo webhook on failed main-branch runs. ### Proposed decisions (Forgejo-admin) - [ ] **D1 (F1/F2, biggest)** — stop mounting `docker.sock` into job containers by default: drop the `-v` from `options`, drop `SYS_PTRACE`, and set `valid_volumes` to `[]`; jobs needing docker (staging-deploy, cd) move to a dedicated `deploy` label on a runner whose config keeps the socket (ideally a socket proxy with a scoped API, or rootless docker). Alternative minimal step: keep the socket but remove `valid_volumes: ["**"]` so arbitrary `volumes:` in workflows can't mount anything else. - [ ] **D2 (F3)** — decide macos-15: Mac runner vs Linux release path vs defer releases. - [ ] **D3 (finding 3a)** — scope REGISTRY_TOKEN to package-write on `api` only + rotation cadence (quarterly?), same for STAGING_SSH_KEY. - [ ] **D4 (finding 3b)** — restrict the deploy key in staging `authorized_keys`: `restrict,command="..."` or `from=` the runner egress IPs (194.233.80.53, 84.247.154.32, 84.247.152.71) if egress is static. - [ ] **D5 (F5)** — add the health cron + failure issue bot. Related: #196 (migration smoke test — the incident root cause), PR #195 (the hotfix).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/failsulit#146
No description provided.