One Forgejo bot user per repo — scope FORGEJO_TOKEN's write to the project it works #201

Open
opened 2026-10-15 02:59:09 +00:00 by ben · 0 comments
Owner

Filed from the 2026-10-14 infrastructure review (Claude Code session on Ben's workstation; four parallel read-only review passes over the root harness). Line anchors are against main at 3e50274.

Symptom

One swarm user token has write on every repo and is present in every worker at /run/secrets/forgejo_token, in every unsandboxed claude session (run-triage.sh:276, heal.sh:386), in cron env, and today in .git/config (#195). A prompt-injected worker on any one project can push to main, close issues, and dispatch workflows (forgejo-lib.sh:138 forgejo_dispatch_workflow) on ALL projects.

Proposed change

Forgejo tokens are per USER, so per-repo scoping = one bot user per repo (collaborator with write on that repo only), SWARM_FORGEJO_TOKEN as a REPO-level Actions secret, token scopes limited to write:issue + write:repository. Feasibility (verified): every caller scopes by FORGEJO_API (repo URL) and reads the token from env or the secrets file; claim-lib.sh:186 matches claims by body text, not author; schedule-backstop.sh runs from each repo's own checkout with its own secrets file (ADR 0004 point 3); verify-creds probes /user and repo issue-write (onboard-lib.sh:838-845). Only forgejo_add_dependency (forgejo-lib.sh:131) crosses repos and needs read on the target.

  • onboard.sh labels/identity gain a bot step that documents the bot's login per repo (the identity layer records the login, never the token).
  • swarm-identity.sh optionally records SWARM_BOT_LOGIN so provenance shows which identity pushed.

Why human

One-way-door ruling + Ben's hands: creating forge users and minting tokens is an instance-admin door. Proposed default ruling: do it for dev-factory + one consumer first; others at pin bump.

depends_on

#195

_Filed from the 2026-10-14 infrastructure review (Claude Code session on Ben's workstation; four parallel read-only review passes over the root harness). Line anchors are against `main` at 3e50274._ ## Symptom One `swarm` user token has write on every repo and is present in every worker at `/run/secrets/forgejo_token`, in every unsandboxed claude session (`run-triage.sh:276`, `heal.sh:386`), in cron env, and today in `.git/config` (#195). A prompt-injected worker on any one project can push to main, close issues, and dispatch workflows (`forgejo-lib.sh:138 forgejo_dispatch_workflow`) on ALL projects. ## Proposed change Forgejo tokens are per USER, so per-repo scoping = one bot user per repo (collaborator with write on that repo only), `SWARM_FORGEJO_TOKEN` as a REPO-level Actions secret, token scopes limited to `write:issue` + `write:repository`. Feasibility (verified): every caller scopes by `FORGEJO_API` (repo URL) and reads the token from env or the secrets file; `claim-lib.sh:186` matches claims by body text, not author; `schedule-backstop.sh` runs from each repo's own checkout with its own secrets file (ADR 0004 point 3); verify-creds probes `/user` and repo issue-write (`onboard-lib.sh:838-845`). Only `forgejo_add_dependency` (`forgejo-lib.sh:131`) crosses repos and needs read on the target. - `onboard.sh labels`/`identity` gain a `bot` step that documents the bot's login per repo (the identity layer records the login, never the token). - `swarm-identity.sh` optionally records `SWARM_BOT_LOGIN` so provenance shows which identity pushed. ## Why human One-way-door ruling + Ben's hands: creating forge users and minting tokens is an instance-admin door. Proposed default ruling: do it for dev-factory + one consumer first; others at pin bump. ## depends_on #195
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.

Reference
Matou/dev-factory#201
No description provided.