Only if the agent can do nothing you would regret when it is wrong or fooled. A build log, a pull request title and a branch name are text that anyone who can open a pull request can write, and in April 2026 researchers showed 3 AI agents in GitHub workflows hijacked through a pull request title, an issue and its comments, or a hidden comment in an issue. Give the agent read-only access, no secrets and no push rights, and treat its answer as a suggestion.
- A log, a pull request title and a branch name are text anyone who can open a pull request can write.
- In April 2026 researchers showed three AI agents in GitHub workflows hijacked through a pull request title, issue text or a hidden comment.
- Restrict the agent: a read-only token, no secrets in its job, an allowlist of tools, and a known gate on who can trigger it.
- Pass untrusted text to a shell through an environment variable, never pasted into the script.
- Marking text untrusted is a request to a model, not a wall; access is what holds.
What is the risk when an agent reads a CI log?
An agent may not tell an instruction from the text it was asked to read. A log holds whatever your build printed, including test names, error messages and the title of the pull request a step echoed, and a pull request from a stranger can shape all of it. If the same agent can push, comment or read a secret, a line in a log can steer it to do so. This is called prompt injection, and the filters that try to remove it are partial: the action’s security page lists what it strips (HTML comments, invisible characters and more) and then says “new bypass techniques may emerge”.
What have researchers shown?
Two reports from 2026, both with the method published. Each describes what happened in the configurations tested.
| Report | What it tested | What it found |
|---|---|---|
| Comment and Control, 15 April 2026 (Guan, Liu, Zhong) | Three agents in GitHub workflows: Claude Code Security Review, Gemini CLI Action and GitHub Copilot Agent. | Claude Code Security Review: a pull request title, after which it posted its API key and GITHUB_TOKEN as a pull request comment. Gemini CLI Action: an issue title and comments, after which it posted its API key as an issue comment. GitHub Copilot Agent: an HTML comment in an issue, after which it committed encoded tokens from its environment to a pull request. |
| GitInject, 7 June 2026, revised 2 November 2026 (Isbarov, Suleymanov, Shumailov, Kantarcioglu) | Eleven attack scenarios across five workflows from four AI providers, run live in temporary GitHub repositories. | Configuration files from unmerged pull requests were treated as trusted instructions. The abstract says "Every provider is susceptible to at least one high-severity attack in the tested configurations." The setups tested were fully automated ones, where outside contributions trigger agents with no person reviewing first. |
The first report’s own conclusion is that the agent and the secrets share a runtime with the untrusted text, and that allowlists for tools, secrets and network access hold better than blocklists. That is the author’s view, and it is the one the next section follows.
What should the agent be able to reach?
Give it the least that lets it do the one job, and take away the rest in the places below.
| Restriction | What it limits | Where it is written |
|---|---|---|
| A read-only GITHUB_TOKEN by default | What a hijacked step can do to the repository. Raise one job's permissions only where it needs them. | GitHub's secure use reference. |
| No secrets in the job that runs the agent | What a hijacked agent can read back. In the Comment and Control report the keys were read from the agent's environment. | The Comment and Control report. |
| An allowlist of tools | What the agent may run. The action's own page warns that its default auto mode is a review and not a boundary. | The Claude Code Action security page, and the report's recommendation. |
| Know who can trigger it | Claude Code Action can only be triggered by users with write access, which is not a defence against a stranger's text in a pull request a writer runs it on. A bot you allow is not checked for permissions. | The Claude Code Action security page. |
| Avoid pull_request_target unless you must | GitHub says workflows on such triggers must not explicitly check out untrusted code. | GitHub's secure use reference. |
| Turn the log tools off if the agent does not need logs | What the agent reads from the run. The action's page gives a --disallowedTools line for its two log tools, and says it may still reach logs through other commands that you allow or that its auto mode review passes, such as gh. | The Claude Code Action security page. |
How do I stop untrusted text reaching a shell?
Pass it through an environment variable, which GitHub’s page calls the preferred approach for inline scripts. This is the pattern, shortened from the example on that page:
- name: Check PR title
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
echo "PR title: $TITLE"
We ran the difference in a local shell with a title written as an attack. Pasted into the script text, the title closes the quotation and runs its own command; read from the environment, it is printed as a title.
TITLE='"; echo INJECTED; echo "'
# pasted into the script text: prints INJECTED on a line of its own
sh -c "echo \"PR title: ${TITLE}\""
# read from the environment: prints the title as it is
TITLE="$TITLE" sh -c 'echo "PR title: $TITLE"'
That closes the route into a shell. It does nothing for a model that reads the same title as a request, which is why the restrictions above are about what the agent can do and not only about what it can read.
How does our MCP server treat log text?
Text that people who can push to a repository wrote, such as log lines, commit messages, and branch and job names, comes back under a key named untrusted, and the server tells the agent to treat it as data. Two tools can change the account, and each is off until the connection is approved for write access by an owner or admin, the organisation switches write tools on, and the call carries confirm: true. Every attempt is recorded. The marking is an instruction to the model and can be ignored by one that is fooled, so the part that holds is the access: a connection acts as the user who approved it and sees what that role sees. The page for our MCP server for GitHub Actions has the details, and the servers for GitHub Actions compares them with the others.
Our plugin for Claude Code, which pushes CI results into a session, treats the names it passes on the same way. Workflow, job and branch names are chosen by whoever pushed the commit, so it cuts each to one line of plain text, removes < and >, and tells Claude to read the text as a notification, not as instructions. It cannot approve a tool call: approvals stay in your terminal.
What does this not fix?
An agent that reads logs and has no way to act on them can still give you a wrong or planted explanation, and a person who runs the command it suggests has acted on a stranger’s text. Keep a person between the suggestion and the change. For the workflow side of this, the security hardening post has the rest, and how an agent reads a failed build has the routes themselves.
Sources
- Secure use reference (GitHub Docs) (docs.github.com)
- Comment and Control: Prompt Injection to Credential Theft in Claude Code, Gemini CLI, and GitHub Copilot Agent (oddguan.com)
- GitInject: Real-World Prompt Injection Attacks in AI-Powered CI/CD Pipelines (arXiv:2606.09935) (arxiv.org)
- Claude Code Action: security (github.com)
- The runners.io MCP server (/docs/observability/mcp-server)
- The runners.io plugin for Claude Code (README) (github.com)
Frequently asked questions
Is it safe to let an AI agent read my CI logs?
Only if the agent can do nothing you would regret when it is wrong or fooled. A log, a pull request title and a branch name are text strangers can write. Give it read-only access, no secrets and no push rights, and check its answer.
What is prompt injection in a CI log?
Text in a log, a title or a comment that a model reads as an instruction instead of as data. If the same agent can push, comment or read a secret, that text can steer it to do so.
What should I restrict for an agent that reads CI logs?
Give it a read-only GITHUB_TOKEN, keep secrets out of its job, allow only the tools it needs, and know who can trigger it. Avoid pull_request_target where you can, and pass untrusted text through an environment variable.
Does marking log text as untrusted stop prompt injection?
No. Marking it, as our MCP server does under an untrusted key, asks the model to treat it as data, and a fooled model can ignore the request. What holds is access: the connection sees only what the approving user's role sees.