Severity: high. The in-cluster builder agent runs Claude Code with --dangerously-skip-permissions and reads attacker-influenceable input (issue/PR text). It currently holds the Forgejo ADMIN PAT (PLAT_TOKEN, dispatcher.ts:54) through THREE channels (verified in agents/src/runner.ts):
runner.ts:171 — spawnEnv() does {...process.env}, copying PLAT_TOKEN into every subprocess.
runner.ts:435 — the git clone remote is https://plat:<PLAT_TOKEN>@host/o/r.git, persisted into .git/config (recoverable via git remote -v).
Impact: with the admin token a prompt-injected agent can overwrite/read secrets, rewrite branch protection, and — worst — author a pull_request workflow that emits ${{ toJSON(secrets) }} to EXFILTRATE EVERY PRODUCTION SECRET (confirmed: _app-template/.forgejo/workflows/preview.yml runs on: pull_request and already consumes secrets.*; Forgejo populates secrets for same-repo non-fork PR workflows).
Fix (Phase 0 of the secret-scoping design #15 — must ship first):
Strip the admin PAT from the subprocess entirely; the dispatcher keeps it for its own work.
Per-(owner,app) git credential, push-only — a per-repo deploy key in the remote URL, never the admin PAT.
Per-app non-admin scoped MCP bearer; the MCP server authorizes every call against the run (o,a) instead of collapsing to plat admin.
spawnEnv builds the subprocess env from an explicit allowlist (Claude+git essentials + the per-run dev token), not ...process.env.
Branch protection on .forgejo/workflows/** (binds only once the agent is non-admin — admin bypasses protections, which is why #1 is the prerequisite).
One change (drop the agent admin; give it a scoped non-admin push credential) makes scope-in-Variables real, makes branch protection bind, and closes the exfil. Highest-value security fix on its own; blocks #15 Phase 1.
Severity: high. The in-cluster builder agent runs Claude Code with --dangerously-skip-permissions and reads attacker-influenceable input (issue/PR text). It currently holds the Forgejo ADMIN PAT (PLAT_TOKEN, dispatcher.ts:54) through THREE channels (verified in agents/src/runner.ts):
Impact: with the admin token a prompt-injected agent can overwrite/read secrets, rewrite branch protection, and — worst — author a pull_request workflow that emits ${{ toJSON(secrets) }} to EXFILTRATE EVERY PRODUCTION SECRET (confirmed: _app-template/.forgejo/workflows/preview.yml runs on: pull_request and already consumes secrets.*; Forgejo populates secrets for same-repo non-fork PR workflows).
Fix (Phase 0 of the secret-scoping design #15 — must ship first):
One change (drop the agent admin; give it a scoped non-admin push credential) makes scope-in-Variables real, makes branch protection bind, and closes the exfil. Highest-value security fix on its own; blocks #15 Phase 1.