I spent a weekend building a small team of bots to run a GitHub repo instead of me. A triage bot picks up new issues, a coder bot writes the fix, a review bot checks the work, a scout bot looks for stale dependencies on Mondays, a digest bot sends me one message a day. I only answer questions and click merge.
The whole thing runs on anthropics/claude-code-action@v1, triggered off different GitHub events: bot-triage on issue opened, bot-coder on an agent:go label or an @claude comment from me, bot-review on a dispatch from the coder or on pull request events. It all runs on a self-hosted runner on opai-server, image repo-bot-runner:2.338.0, so I am not burning Actions minutes.
The first pull request was the kit itself
The pull request that installed this whole setup was also the first pull request the review bot ever saw. So its first job, before touching a single line of anyone else's code, was reviewing the workflow files that gave it its own power.
It did not approve itself.
It flagged that bot-review was listening for pull_request events with no check on where the pull request came from. Any PR against the repo, including one opened from a fork by someone with no write access, would trigger a workflow run on my own server, with a GitHub token sitting in the job's environment via npm ci. The repo was private at the time, so there was no stranger around to open that PR. But the setup was built to be reused on other repos, some of which would not stay private, and the hole would go with it.
What a token in the wrong hands gets you
The token in question was not some scoped read-only thing. It was there so the bot could comment on PRs, dispatch other workflows, push commits. A workflow that runs attacker-controlled code (anything from an untrusted fork counts) with that token sitting in GH_TOKEN is a way to hand out write access to your repo to whoever opens a PR. GitHub's own docs warn about this pattern directly: pull_request_target and unscoped pull_request triggers combined with secrets are a known way to get burned.
The fix, and the second pass
The fix was two guards. First, a same-repo check on the trigger itself: head.repo.full_name == github.repository, so a PR from a fork never reaches the workflow at all. Second, belt and suspenders, GH_TOKEN='' on the steps that run PR-controlled code, like npm ci, so even if something slipped past the first guard there is no token for it to find.
I pushed round two. The review bot ran against its own workflow files again, and this time it passed them.
Where this leaves me
The review bot's own workflow table now only fires bot-review on same-repo PRs, or on a direct dispatch from the coder bot, and the token stays empty on any step a stranger's code could touch. The kit is still meant to be reused on other repos, and I now have one concrete thing to check before I turn it loose on a public one: point the reviewer at its own installation first. If it cannot find anything wrong with the thing that gives it its power, it has not looked hard enough yet.
[NEEDS: whether this same guard pattern has been checked against the other bots in the team, triage and coder, which also run on PR-adjacent triggers]