How to safely give an AI coding agent push access to your repository

How does GitHub Actions security affect AI agent push access?
GitHub Actions can turn an AI coding agent’s push access into the ability to run code with workflow credentials. Push access sounds like "can change code". But when a GitHub Actions workflow runs scripts/deploy.sh while signed in to your cloud, push access to that script means "can run code as your deploy account". II Agent Runtime's preflight catches this before your agent starts: it reads your workflows, flags push access as a privileged permission, and blocks the agent.
We ran it on Google's own open-source repository. An agent that could push the repository's code, including a test script, was blocked, because the end-to-end test workflow runs that script while signed in to Google Cloud.
Key takeaways:
- Push access can be a privileged permission. If a workflow that holds write permissions, secrets or a cloud sign-in runs a file your agent can push, your agent can run code with those credentials.
- II Agent Runtime checks for this before your agent starts. Its preflight reads the repository's workflows and whether GitHub Actions is on, and compares them with what your agent is allowed to push.
- When it finds a path, it blocks the agent. The runtime won't open the agent's gateway until the check passes, and the report names the file, the workflow job and the cloud account involved.
- It also flags an agent that can push workflow files, because that agent could add a workflow of its own.
- If your agent is meant to deploy, you can allow it. Waive that one check, and the agent starts with the finding still in its report.
- The check only reads. It makes read-only calls to the GitHub API and changes nothing.
Clone it yourself
We have a tool that runs this preflight on its own. You need Node 22.16 or later, Git, and a GitHub token, which the GitHub CLI gives you after gh auth login.
git clone https://github.com/intelligent-iterations/ii-agent-runtime.git
cd ii-agent-runtime
npm ci
cd example/deployment-boundary-checker
npm ci
GITHUB_TOKEN=$(gh auth token) npm run demo
The demo runs the preflight for two agents on Google's repository, prints what it found, and shows whether each agent was blocked or let through.
Why is push access a privileged permission?
Most teams deploy from GitHub Actions. A deploy workflow checks out the repository, signs in to the cloud, and runs something from the repository: a script, npm install, make, a Docker build. The sign-in often needs no stored key at all. With workload identity federation, GitHub vouches for the job, and Google Cloud hands it a short-lived token for a service account.
None of that involves your agent directly. But the files the workflow runs come from the same repository your agent pushes to. Change the script, and you change what runs with the service account's permissions. An agent that can push that script doesn't need a cloud key; the workflow brings its own.
Your repository
A file
- File
test/infra/runner.sh- Your agent can
- Push it to
main
GitHub Actions
A job that runs it
- Job
e2e.yml,e2e-test- Signs in
- To Google Cloud, with no stored key
Google Cloud
A service account
- Name
gh-e2e-runner- Used to
- Build images and run jobs on GKE
BlockedThe preflight flags this path as a potential escalation, and the agent doesn't start.
What does the preflight check?
When your agent's tools include pushing files to GitHub, the runtime's GitHub preflight answers two questions before the agent starts.
Can the agent push workflow files? If it may push anything under .github/workflows/ or .github/actions/, it could add a workflow of its own, so the preflight flags it unless Actions is turned off.
Does a privileged workflow job run a file the agent can push? The preflight reads every workflow on the branch the agent pushes to. It looks for jobs that hold write permissions, secrets or a cloud sign-in and that run repository code, directly or through npm, make, docker build or pip install. If one of them runs a file the agent can push, the report says "potential escalation" and names the file, the job and the cloud account the job signs in as.
The agent starts only when every check is clear. When the preflight can't tell, for example because other code may load a Go file and the check doesn't trace that, the agent is blocked too. The preflight doesn't guess.
Blocked
Agent can push runner.sh
- job holds credentialsyes
- job runs the fileyes
A job signed in to Google Cloud runs this file.
1 exit code: potential escalation
Blocked
Agent can push main.go
- file typecode
- what loads itnot traced
Other code may load it, and the preflight won't guess.
2 exit code: can't tell
Let through
Agent can push README.md
- file typedocs
- named by a jobno
Documentation that no workflow runs or mentions.
0 exit code: clear
What did the preflight find on Google's repository?
The demo checks Google's Secret Manager provider for the Secrets Store CSI Driver, a public Kubernetes project. Its end-to-end test workflow signs in to Google Cloud as the gh-e2e-runner service account, then runs test/infra/runner.sh, which builds container images with Cloud Build and runs test jobs on a GKE cluster.
It checks an agent that can push code to the repository: test/infra/runner.sh, main.go, Makefile and README.md. As a control, it also checks an agent that can push only documentation.
The agent was blocked, because the test job runs test/infra/runner.sh while signed in as that service account. The documentation-only control was let through, which shows the preflight isn't simply blocking every push: no workflow runs or mentions README.md.
Live run · Nov 4, 2026
Setup
- Repository:
GoogleCloudPlatform/secrets-store-csi-driver-provider-gcp, branchmain, commit31170f58a4e9, 3 workflow files - Command:
npm run demo, read-only GitHub API calls, no cloud credentials - Actions settings: need admin access to read, so Actions was treated as enabled
Agent that can push code
test/infra/runner.shescalationmain.gonot clearedMakefilenot clearedREADME.mdclear
Blocked. The preflight found a potential escalation.
Control: docs only
README.mdclear
Let through. No privileged job runs anything it can push.
main.go and Makefile weren't cleared either. The docs-only control is let through, so the preflight isn't blocking every push.What happened on our private repositories?
We ran the same preflight on four private repositories that deploy to Google Cloud, with no cloud credentials. Each time, the agent could push one everyday file: package.json in three of them, a version-bump script in the fourth.
The agent was blocked in all four. In one, the deploy job runs npm and then signs in as a production or development service account, depending on the branch. In two others, the deploy job uses a long-lived cloud key stored in GitHub secrets.
The documentation-only control was let through in two of the repositories. In the other two it was blocked too, because some of their workflows use features the preflight can't fully read yet, such as a local composite action. The preflight blocks what it can't read rather than guess.
Live runs · Nov 2, 2026
Setup
- Repositories: four private repositories that deploy to Google Cloud
- Command: read-only
--githubruns, no cloud credentials - Agents: one that could push one everyday file, and a control that could push only
README.md
| Repository | Agent can push | Preflight | Docs-only control |
|---|---|---|---|
| A | package.json | Blocked | Blocked, can't tell |
| B | a version-bump script | Blocked | Blocked, can't tell |
| C | package.json | Blocked | Let through |
| D | package.json | Blocked | Let through |
What doesn't the preflight cover?
The preflight reads the workflows on one branch, as they are when it runs. It doesn't cover workflows on other branches, later changes to the workflows, or data that your scripts read. It also doesn't resolve trigger filters, environment approvals or branch protection, so a blocked agent can be one that a required approval would still have stopped.
Service accounts are named but not assessed by default. Give the tool a Google Cloud reader token, and the report also shows whether each account accepts the job and which roles it holds.
Frequently asked questions
Do I need to run my agent on II Agent Runtime?
No. The tool runs the same preflight on its own. If your agent does run on II Agent Runtime, the runtime requires a passing preflight before it opens the agent's gateway.
What if I want my agent to deploy?
Then let that check through on purpose. You choose which preflight checks must pass: leave out github.workflow-execution, and the agent starts even when a job runs files it can push, while the finding stays in the report.
admitToolSession(session, report,
report.checks.map(check => check.id).filter(id => id !== 'github.workflow-execution'));
That one setting accepts every job that runs a file the agent can push, not only your deploy job. Keep github.workflow-definition required unless the agent should also be able to write workflows.
Does the preflight need access to my cloud?
No. It reads your workflows through the GitHub API. A Google Cloud reader token is optional; with one, the report also shows what each service account can do.
Does it work on private repositories?
Yes, as long as your GitHub token can read them. It can also read the workflows in a local checkout, with no network access.
Can I run it in CI?
Yes. The tool exits with code 1 for a potential escalation, 2 when it can't tell and 0 when the check is clear, so a pipeline can stop before an agent gets push access.
Built on II Agent Runtime
This is II Agent Runtime's own preflight. The tool runs it on its own, on the same file permissions the runtime enforces. Try it yourself: