Skip to content

AAK-AGENT-TRUST-002: Headless agent CI runs on attacker-controllable input with the repo's credentials

Severity
CRITICAL
Category
Hook Injection (hook-injection)
Scanner
agent_audit_kit/scanners/agent_trust_surface.py
Auto-fixable
No.
SARIF name
HeadlessAgentCiUntrustedRef

What it detects

A workflow that runs a coding agent non-interactively is triggered by an attacker-controllable event (pull_request_target, issue_comment, workflow_run, pull_request_review[_comment]) or explicitly checks out the pull-request head ref, and then runs the agent with the base repository's write-scoped GITHUB_TOKEN and secrets available. Because the headless run trusts repo-resident skill / MCP / task files on load, a fork PR that adds or edits one of those files gets its shell commands executed in CI with the base repo's credentials, with no human trust prompt. This is the trust-on-first-use bypass amplified by the classic pwn-request trigger. It also fires when the trigger is trusted and the data is not: a job gives an agent (the actions and CLIs above, or the Copilot agent through gh agent-task, copilot-swe-agent or the copilot CLI) contents: write, pull-requests: write, write-all or a personal token, in a workflow that fetches another project's commits or diff (git fetch from a remote other than origin, git remote add, or gh api or api.github.com on repos/<other>/compare or commits), with no egress block on that job. Whoever lands a commit upstream writes part of the prompt. Any trigger counts, a schedule or a workflow_call included.

How to fix

Never run a headless agent on pull_request_target / workflow_run / issue_comment with secrets in scope, and never check out the PR head into a job that then runs the agent. Split the privileged step onto the trusted base ref, gate on a maintainer approval, and drop GITHUB_TOKEN to read-only. For another project's commits, split the trust boundary across two workflows: one on a schedule with no permissions fetches and runs the agent, and a separate workflow_run workflow holds the write scope and never reads the diff. Add a deny-by-default egress allowlist on the agent's job, and fail the run if the agent touched .github/.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-AGENT-TRUST-002

Limitations

Single-artifact pre-screen, not a boundary control. These rules inspect one file at a time, so they cannot see intent split across several individually-benign skills loaded into the same agent context. Cross-skill composition defeats per-skill scanners: ColluSkill (arXiv:2608.09732) reports a 96.0% average attack success rate across six skill scanners, and SkillsMetric (arXiv:2608.08468) reports 0% detection for host-destruction via common shell commands and 42% for natural-language prompt injection. Run these early and cheaply as a first pass; they are not a guarantee. The composition blind spot they cannot see is covered by the set-level rule AAK-AGENT-COMPOSE-001. The third-party arm reads one workflow file: a fetch in another workflow or in a script it calls, git clone and actions/checkout of another repository are not read, and neither is an agent started by a script, as a Python script that fires the Copilot agent is. git fetch of anything but origin counts, so a variable that holds origin fires, and a repository named by a variable counts as another project unless the env of the step, job or workflow sets it from github.repository. Only the contents and pull-requests scopes and write-all are read, so issues: write or no permissions block, where the repository's default applies, does not fire. A personal token is a secret with PAT or TOKEN in its name, other than GITHUB_TOKEN or a model provider's, in the env or with of the agent's step, or the env of its job or workflow. step-security/harden-runner with egress-policy: block is the only egress control read.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-AGENT-TRUST-002.md: the page then shows that text, with the registry reference appended under it.