NewThe Mac app is out for Apple SiliconGet it →
Fenzi
blog, safety

Is it safe to run Claude Code in GitHub Actions?

It can be, for a narrow job with a short tool list and the fewest tokens it needs. The risk is text: an issue, a pull request or a comment the agent reads can steer it while the job holds your model key and a GitHub token. Anthropic's action refuses outsiders and bots by default, but its own security notes say auto mode "is a review, not a boundary", so keep untrusted text, secrets and a way out of the job from meeting in one run.

By Boris Kwemo, , seven-minute read

A CI job has nobody at its terminal. The agent reads what the event hands it, runs with the permissions in the workflow file, and nobody sees a prompt. That changes the question from whether you trust the model to what the job lets any text it reads do.

This post covers Anthropic's Claude Code GitHub Actions integration, the anthropics/claude-code-action step, and the same reasoning applies to any agent you start from a workflow.

What the action does by default

The action runs in one of two ways. With no prompt, it waits for @claude in an issue, a pull request or a review, and answers there. With a prompt, it runs on whatever event starts the workflow, a cron schedule included.

Before Claude starts, it checks who triggered the run. On issue and pull request events that person needs write access to the repository. On every event a bot is refused unless you list it in allowed_bots. A scheduled run has no outside actor, so it skips the write check.

By default the action runs in Claude Code auto mode, where a safety review decides the tool calls your allow rules do not cover. For a plain text prompt in automation mode, Anthropic's docs say Claude has no shell or GitHub API access until you grant the tools it needs. Claude does not open pull requests on its own: it pushes a branch and posts a link, and a person creates the pull request.

Where the risk comes from: text the job reads

The write check is about who starts a run, not about whose words the agent reads. The action's security notes say it plainly: when a maintainer labels or assigns someone else's issue, Claude still reads the body. Issues and comments from outside contributors still reach Claude.

That text can carry instructions, which is the core of most prompt injection examples. The action strips HTML comments, invisible characters, image alt text and hidden attributes before Claude sees the content, and the same page warns that "new bypass techniques may emerge."

Now add what a CI job holds. GitHub's secure use reference notes that any user with write access can read every secret the repository has, and that log redaction "is not guaranteed" once a secret is transformed. A job with untrusted text, a secret in reach and a way to send it out has all three parts of the lethal trifecta.

A real case: the key in the process environment

Microsoft's Defender research team published a case in June 2026. The workflow read issues from users without write access, so the action scrubbed secrets from the environment of Bash commands. Claude's Read tool ran in the main process, where the key was still set, and could read /proc/self/environ.

The injected issue framed the request as a compliance review and asked for the key with its first seven characters removed. That got past the model's reluctance to print keys and past secret scanning. Depending on the workflow, the result could leave through web fetch, a shell command, an issue comment or a verbose log. Anthropic fixed it in Claude Code 2.1.128 on 5 May 2026 by blocking reads of sensitive /proc files.

Untrusted inputs like GitHub issues must be treated as hostile by default.Microsoft Defender Security Research, Securing CI/CD in an agentic world

The bug is fixed. The shape is not: one tool the scrubbing did not cover, one secret in the process, one way out. Their first recommendation is the rule of two, a job should not hold untrusted input, access to secrets and a way to change state or talk to the outside at the same time.

Settings that widen the job

Most of the risk in a given workflow comes from a few inputs. Each one is documented, and each one has a narrower form.

SettingWhat it changesNarrower form
allowed_non_write_usersSkips the write check, which the security notes call the action's primary security mechanismOnly for jobs with tiny permissions, such as labeling, with the job's GITHUB_TOKEN and never a personal token
allowed_bots: '*'On a public repository, any GitHub App can trigger a run with a prompt it controlsA short list of app names you trust
Broad allow rulesAn allowed rule skips auto mode's review; Write reaches outside the workspace and Bash(git:*) can run programsExact commands, or --permission-mode default so uncovered calls are denied
bypassPermissions in claude_argsCommands outside the action's list run without any checkLeave the action's default mode
show_full_output: truePuts the full session in the job log, one of the exits in Microsoft's caseLeave it off on public repositories
The official Claude GitHub AppOne permission set for every Claude feature, including write access to workflows, which the action does not useA custom app with Contents, Issues and Pull requests only

Our notes on how Claude Code permissions work cover the rule syntax behind --allowedTools and --disallowedTools.

Pull requests from forks

Forks are where an ordinary workflow mistake meets an agent. GitHub's reference says pull_request_target and workflow_run run in a privileged context with access to secrets, and that checking out an untrusted pull request in them can let someone take over the repository. The action's notes repeat it: do not check out an untrusted ref into the workspace root before the action runs.

The action already does several things here. On a pull request it restores .claude/, CLAUDE.md, .mcp.json and other agent config from the base branch. When the author lacks write access, it also denies common commands that run repository code, such as package managers and test runners. Its own wording is the caveat: "This is a list of common commands, not a sandbox."

Two more lines from the same page matter. On a fork's pull request Claude pushes to a pr-N branch in your repository, so keep pr-* out of any CI that holds secrets. And if you do not need forks at all, allow_fork_prs: "false" makes the action skip them.

"Only maintainers can trigger it, so it only does what maintainers ask."

Revision 1: maintainers start the run; anyone who wrote the issue, the comment or the pull request can still put words in front of the agent.

How to run it with less at stake

One task per workflow. A daily report, a review, a labeler. A fixed prompt with a fixed tool list is easier to bound than an agent that answers any mention.

Least privilege on the token. GitHub suggests read-only contents by default, raised per job. Anthropic's scheduled example shows the shape:

permissions:
  contents: read
  issues: read
  id-token: write
steps:
  - uses: anthropics/claude-code-action@v1
    with:
      anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
      prompt: "Generate a summary of yesterday's commits and open issues"
      claude_args: |
        --allowedTools "mcp__github__list_commits,mcp__github__list_issues"

Fewer long-lived secrets. Anthropic's docs describe workload identity federation, which trades the workflow's OIDC token for model access instead of storing an API key. Use one key per workflow so a leak has a small radius.

Pin what runs. GitHub recommends pinning actions to a full commit SHA, since a tag can be moved by whoever controls the repository.

Keep the person at the merge. Claude pushes a branch; a person opens and reviews the pull request. Branch protection on the default branch keeps it that way when a workflow allows other push commands. That split of who decides what is how we read agentic AI security, and our list of AI agent security risks covers what happens when nobody decides.

A side note on how we do it

We build Fenzi, which runs the agent in an OpenShell sandbox on the runner under the same policy a laptop runs: it sees a placeholder instead of the model key, holds no git token, and its commits come back as a branch, as the CI sheet describes. A workflow that keeps tokens out of the agent's step and refuses unlisted hosts answers the same question.

So, is it safe?

On trusted input, with a fixed task, a read-only token and an exact tool list, yes: the worst case is a branch you do not merge. On a public repository that answers any mention, with broad allow rules and secrets in the job, it is one well-written issue away from a leaked key. The action's defaults help, and they are not a boundary.

Decide which two of untrusted text, secrets and a way out each workflow gets, then write the permissions to match. The action's security documentation is the best next read.

One line to install.
One command to run.

curl -fsSL https://fenzi.dev/install.sh | sh

Then fenzi run claude. Ask it to open a pull request with the GitHub API, and watch the deny land.