/agent-traffic-control:workflow-run-deploy-gate-fork-pr-ref-name-escalationfrom agent-traffic-control
Security trap when authoring/reviewing a GitHub Actions deploy (or any privileged job) triggered by `on: workflow_run` and gated on the triggering run's BRANCH NAME. Use when: (1) a `workflow_run` job gates on `github.event.workflow_run.head_branch == 'main'` (or conclusion == 'success') to decide a privileged deploy / publish / OIDC-cloud action, (2) you are wiring CI-gated auto-deploy-on-merge ("deploy after the CI workflow passes on main"), (3) reviewing a workflow that mints cloud creds (WIF/OIDC, `id-token: write`) off a `workflow_run` event. The trap: `head_branch` is the UNQUALIFIED ref name, and a FORK's default branch is also named `main`. A fork-PR's CI run (event `pull_request`) can complete `success` with `head_branch=='main'`; the upstream `workflow_run` deploy then runs in the PRIVILEGED upstream context and ships the fork's `head_sha` to prod. The "fork CI can't read secrets/OIDC" intuition is a trap — that's the CI job; the deploy is a SEPARATE privileged job. Fix: also gate on the triggering run's ORIGIN — `workflow_run.event == 'push'` AND `workflow_run.head_repository.full_name == github.repository`. Unreachable on a private repo today, but one-line fix + future-proofs a visibility flip.
Trending skills
7-day visitors to each skill page
Ships in agent-traffic-control. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
workflow_run deploy gate: don't trust the ref name (fork-PR escalation)You want auto-deploy after CI passes on main without a plain push trigger (e.g. so a red-CI
merge can't ship, while the required-CI merge gate is deferred). The idiomatic shape is:
on:
workflow_run:
workflows: ["CI"]
types: [completed]
jobs:
deploy:
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main' # ⚠️ ref NAME only
permissions: { contents: read, id-token: write } # WIF / OIDC → prod
This is exploitable. workflow_run.head_branch is the unqualified ref name, and a fork's
default branch is also main. A workflow_run-triggered job runs in the privileged upstream
context (upstream secrets / OIDC), regardless of where the triggering run came from — that is
the inherent workflow_run hazard.
Attack path (public repo): fork → open PR from attacker-fork:main → upstream:main. The
fork's CI (on: pull_request) runs in the fork's unprivileged context, completes success, with
head_branch == 'main'. The upstream deploy workflow_run job then fires privileged, checks out the
attacker's head_sha, and builds+deploys attacker code to prod via the WIF/deploy SA.
The intuition that bites you: "fork CI can't access OIDC/secrets, so this is safe." True of the
CI job. The deploy is a separate workflow_run job that runs privileged no matter the
trigger's origin. Conclusion + branch-name are necessary but not sufficient.
on: workflow_run whose job if: gates a privileged action (deploy, publish,
release, gcloud/aws/az with WIF/OIDC, npm publish, image push) on
workflow_run.conclusion/head_branch only.pull_request (so fork PRs produce CI runs).Gate on the triggering run's origin, not just its name/conclusion. Add BOTH:
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.event == 'push' && # (A)
github.event.workflow_run.head_repository.full_name == github.repository) # (B)
event == 'push' — a fork-PR CI run is event == 'pull_request'; only a write-access
push to main (a merge or a direct push) is event == 'push'. This alone closes the fork path.head_repository.full_name == github.repository — belt-and-suspenders: the CI run was on
our repo, not a fork. (For a push event this is already true; keep it for defence-in-depth.)Neither guard blocks a legitimate deploy: the only legit path is a push-to-main CI run on your own
repo. Deploy the exact tested commit (workflow_run.head_sha), not the branch tip.
Note on scope: the workflow_run workflow file itself is always taken from the default
branch (tamper-safe — a feature branch can't change the gate logic). But its trigger is not, so
you must gate the trigger's origin in the if:.
pull_request CI run) must NOT produce a deploy: the workflow_run run shows
the gate job skipped (the if: is false). A non-success CI must also skip.success (event push) → the workflow_run run is created, not
skipped → gate + deploy jobs run. (A run that is "pending"/"in_progress" rather than immediately
"skipped" means the if: passed.)workflow_dispatch or cancelled-CI run succeeding/ skipping with
proof the gated push path works — see deploy-gate-success-report-doesnt-prove-the-gated-path.Real incident (2026-06-09): a review panel flagged a CI-gated auto-deploy whose gate was
conclusion=='success' && head_branch=='main'. Repo was private (forks can't run CI without write
access → unreachable today), so one reviewer rated it P3; the security reviewer rated it a P1
ship-blocker on don't-trust-ref-name grounds. Fixed with guards (A)+(B) before merge — one-line if:
diff, future-proofs a private→public flip.
workflow_run-triggered privileged job, not just deploys (publish,
release, signing, infra apply).pull_request_target foot-guns (untrusted-code-with-secrets) — same threat class
(privileged context + attacker-influenced ref), different trigger.label-gated-deploy-pull-request-closed-needs-branches-filter (the sibling trigger-trap
on pull_request: closed — a label-gated deploy needs a branches:[main] filter);
deploy-gate-success-report-doesnt-prove-the-gated-path (verify the gated path actually ran,
not a happy-path/dispatch success); gha-auto-deploy-never-ran-skipped-mask (a gated workflow
showing "skipped" can mask a deploy that never successfully ran).workflow_run event runs from the default branch with read/write GITHUB_TOKEN
by default; the triggering run's head_branch/head_repository/event are in
github.event.workflow_run.*. (GitHub Actions docs: "Events that trigger workflows → workflow_run";
"Security hardening for GitHub Actions".)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-control118 skills in this plugin
/agent-refusal-with-evidence-beats-literal-complianceA dispatched agent that does exactly what you asked can ship a defect you would
have stopped yourself, because it can see something at the worksite that you
could not see when you wrote the brief. Use when: (1) you are writing a brief
that prescribes a specific fix, threshold, wording or value rather than the
outcome you want; (2) an agent reports that it did not do what you asked and
you are deciding whether that is insubordination or judgement; (3) an agent
asserts "this is fine" or "not needed" with no measurement behind it; (4) you
are reviewing overnight output and want to know which decisions were checked
and which were assumed. Two halves, and both are needed: give the agent
explicit permission to satisfy the INTENT of an instruction while refusing its
letter, and REQUIRE the evidence with the refusal — what it built or measured,
what that showed, what it did instead. Evidence is the whole difference between
a refusal you can bank and one you have to re-litigate. Four agents correctly
declined an instruction in a single run; one built the suggested fix, measured
that it turned a silent safe refusal into a permanently red pipeline, and
reverted it unpushed.
/auto-merge-rearms-while-agent-live-kill-then-disarm-verifyDisarming auto-merge on a PR whose agent is still running does not hold it —
the agent re-arms within minutes and the PR merges, because arming is a step in
the agent's brief and disarming is not an instruction to the agent at all. Use
when: (1) you want to STOP a pull request from merging that an agent opened and
armed, for review, for a rethink, or because it is landing into a queue you are
trying to drain; (2) a PR you disarmed merged anyway; (3) you are telling agents
which PRs are on hold and want the hold to be enforced rather than announced;
(4) you are about to run `gh pr merge --disable-auto` and have not decided what
to do about the agent. The order is KILL THE AGENT FIRST, THEN DISARM, THEN
VERIFY the disarm by reading `autoMergeRequest` back — a disarm you did not read
back is not a hold. The stronger form needs no ordering at all: convert the PR
to a draft with `gh pr ready --undo`. A draft cannot merge whatever any agent
does to it, so the hold survives an agent you missed, an agent that restarts,
and an agent you did not know about.
/batch-member-cites-a-path-only-a-non-member-addsYou wrote something correct that the default reader cannot reach: a batch member citing a
path only a NON-member adds, or a rule, ruling or ledger sitting on an unlanded branch.
/batch-merge-subject-is-not-evidence-a-member-landedYou are about to close, delete the branch of, or mark as landed a pull
request because a batch, roll-up or merge-train commit on the target branch
names it in the subject line, and because the member's own commits all
predate that merge by wall clock. Neither of those is evidence. A batch
branch is assembled at some moment BEFORE it merges, so anything the member
pushed after assembly is outside it, and the subject records INTENT at
assembly time rather than CONTENT at merge time. Use before closing a
member, when an ancestry check against a squashed batch says no, or when a
member's branch still shows commits ahead of the target. Compare file
content against the target branch instead, expecting exactly one legitimate
difference: the shared aggregate file every member appends to.
/check-a-stale-branch-is-not-undoing-newer-main-workA branch built on an out-of-date main is about to merge, or has merged, and may undo work
that landed since. Use when a green, conflict-free PR deletes files you never touched,
newer values or a whole redesign vanish after a sibling PR merged, rows of a shared ledger
(tracker, registry, CHANGELOG) disappear or revert, or when `git diff main...HEAD` or a
reviewer says your small PR touches dozens of files you did not change.
/ci-leg-skipping-moves-minutes-it-does-not-remove-themYou are about to propose, price or approve a CI cost saving that works by
making a job or matrix leg SKIP on pull requests — a path filter, a safe
list, a changed-files gate, an exemption list. Check first whether the
pipeline runs a complement or backstop on merge, on push, or nightly:
many do, and then the legs a pull request skipped are exactly the legs some
later run executes, so a branch that goes green once and merges bills the
same total either way and the wall clock does not move at all. Use when
pricing a filter change, when a percentage saving is quoted with no basis,
or when choosing between filtering legs and batching pull requests. The
question that separates money from bookkeeping is whether the change
removes RUNS or merely moves LEGS.