Securing AI Coding Agents in 2027: A Checklist for Engineering Teams
Quick answer: Securing AI coding agents in 2027 means assuming any text an agent reads can try to hijack it, as 2026's Comment and Control and GitLost disclosures showed, and limiting what a hijacked agent can do. The checklist: give the agent a short-lived read-only token for one repository, keep secrets out of its context, make privileged writes outside the agent, stop outsiders and fork pull requests from starting it, record every tool call, and gate merges on checks and review.
Let an agent earn its place on your team
Define a Factorik agent once and it wakes on an issue, a failed build or a schedule, works in an isolated sandbox and ships a pull request. It starts with a person merging its work and earns more autonomy on its record. Try it free for 7 days, no payment details needed.
Why is AI coding agent security a 2027 planning item?
This article was written in November 2026. It sums up what the security disclosures of 2026 taught about AI coding agents and turns them into a checklist for 2027. Statements about 2027 are expectations based on what already happened, not predictions with numbers.
In 2026, coding agents stopped being something a developer ran at a desk and became something that runs on its own: on an issue being opened, a comment, a failed build, a schedule. That moved them into the places attackers already reach. Anyone who can open an issue on a public repository can put text in front of an agent that reads issues.
Three pieces of public research made the risk concrete. The first is "Comment and Control", published on April 15, 2026 by researcher Aonan Guan with researchers from Johns Hopkins University. It showed one prompt-injection pattern, hidden in GitHub issue or pull request text, with one variant in an HTML comment, leading AI agents from several vendors that ran in GitHub workflows to expose CI secrets. A Cloud Security Alliance research note dated August 7, 2026 described further attack chains of the same kind and said that the vendors' fixes for the original findings had not removed the broader class of weakness.
The second is "GitLost", disclosed by Noma Labs in July 2026. In the researchers' account, a crafted public issue led GitHub Agentic Workflows to read a private repository and publish its contents. The third is not an attack but guidance: the Model Context Protocol's security best practices name "token passthrough" as an anti-pattern, where a server accepts a token that was not issued for it and forwards it to an upstream API, and the specification says servers must not accept tokens that were not explicitly issued for them.
The common thread is simple. Each problem needed three things in one place: text from someone untrusted, something worth stealing, and the power to send it somewhere. Remove any one and the attack becomes much smaller. That is what the checklist below is built on.
What went wrong in 2026's agent security incidents?
It helps to read each case as a question of reach, not of how clever the injected text was. Agents read text and follow instructions; nobody has yet shown a way to make them reliably tell a maintainer's instructions from an attacker's. The useful question is what the agent could do once it was fooled.
In Comment and Control, the agents ran inside CI workflows that had secrets in their environment. Once the injected text steered the agent, the secrets were already within reach and the workflow had a way to post output. In GitLost, reporting on the researchers' work says the attack depended on the agent holding a token that could read repositories beyond the one the issue was filed on, and the agent could publish what it read. In the token-passthrough pattern, a tool server that forwards whatever token it is given turns any token an agent holds into a key for more systems.
GitHub's own guidance for Actions points the same way. Its security documentation advises setting the default GITHUB_TOKEN permission to read-only for repository contents and raising it only for the jobs that need it, avoiding the pull_request_target trigger unless it is necessary, and never checking out untrusted code in workflows that use it, because those workflows may have write access and access to secrets.
| Case (2026) | Untrusted text the agent read | What it could reach | The lesson |
|---|---|---|---|
| Comment and Control (April; CSA note, August) | Issue and pull request text, including an HTML comment | CI secrets in the workflow environment | Keep secrets out of the agent's environment |
| GitLost (Noma Labs, July) | A crafted public issue | A private repository, per the researchers | Scope the token to one repository, read-only |
| MCP token passthrough (spec guidance) | Any tool input | Upstream APIs, with a token not meant for them | Tools use their own credential, held server-side |
What should teams expect for AI coding agent security in 2027?
These are expectations to plan around, each grounded in something from 2026.
Expect more agents triggered by events anyone can create. The 2026 shift to agents that wake on issues, comments and schedules is the same shift that made Comment and Control and GitLost possible. Teams should plan for every new trigger to be reviewed as an entry point, the way a new public endpoint is.
Expect guidance to keep converging on architecture rather than prompts. The Cloud Security Alliance's August 2026 note recommended auditing workflows that start AI agents on content from external contributors, assuming any CI environment variable visible to an agent may be exposed, replacing long-lived tokens with short-lived, narrowly scoped, per-run credentials, restricting outbound network access from runners, and, in the long term, separating an agent's read access to untrusted content from its access to credentials. It is likely that 2027 security reviews ask about exactly these points.
Expect tool access to become the larger surface. As agents read error trackers, analytics and databases through MCP servers and APIs, the question moves from what the repository token can do to what every tool credential can do. The MCP guidance on token passthrough and on minimal scopes is a reasonable baseline to plan for.
And expect auditors and customers to ask for a record: which agent called which tool, with what result, and who allowed the change it made to merge.
What belongs on an AI coding agent security checklist?
The checklist below follows the lessons above. Each item is general advice that applies whatever tools you use; the last column says how Factorik handles it, using only what Factorik actually does.
- A short-lived, read-only token for one repository. The agent needs to read code, not push it, and its run lasts minutes, not days. 2. No secrets in the agent's context. If a secret is in its environment, assume a hijacked agent can print it. 3. Privileged writes outside the agent. Something trusted, outside the sandbox, should publish the change, to a branch it chooses, never force-pushed and never to the default branch. 4. Outsiders do not start agents by default. On a public repository, decide per trigger whether a stranger's issue or comment may wake an agent. 5. No runs on fork pull requests with your credentials nearby. A fork's code running next to your credentials is an outsider running code in your house.
A practical way to work through the list is one trigger at a time. For each, ask three questions: who can cause it to fire, what text from them will the agent read, and what could the agent reach if that text took control. An issue trigger on a public repository answers the first question with anyone on the internet, so the third answer has to be very little. A schedule fires only when the team set it to, but the agent may still read untrusted text along the way, from dependency changelogs or error messages, so the same limits apply.
- Every tool call recorded. When an agent reads Sentry or queries Postgres, the call should go through something that holds the credential and keeps a log. 7. Untrusted text marked as data. Fencing issue and chat text in the prompt does not stop injection, but it lowers the odds. 8. Changes still go through checks, review and a merge policy, so a fooled agent still has to get its diff past them. 9. Outbound network limits on wherever agents run, as the Cloud Security Alliance recommends; check what your provider offers, as this varies.
Our longer piece on giving coding agents production access through MCP goes deeper on item 6.
| Checklist item | Why | How Factorik handles it |
|---|---|---|
| Read-only token, one repository, short-lived | Limits what a hijacked agent can read or change | The sandbox gets a short-lived read-only token for one repository |
| No secrets in the agent's context | A fooled agent can print what it can see | Tool credentials stay on Factorik's server behind a gateway; the sandbox's only GitHub token is read-only |
| Privileged writes outside the agent | The agent cannot push, comment or merge on its own | The server publishes one commit on a branch it names, never force-pushed, never to the default branch directly |
| Outsiders do not trigger by default | Strangers cannot put text in front of an agent at will | On a public repository, outsiders start agents only if the trigger allows anyone |
| No fork pull request runs | Keeps outsiders' code away from credentials | Pull requests from forks are never reviewed |
| Every tool call recorded | An audit trail of what the agent did | Calls go through a gateway that records each one |
| Untrusted text fenced as data | Lowers the odds of injection | Text from issues, comments and Slack is treated as data |
| Merge gated on checks and review | A bad diff must still get past them | Merge policy requires passing checks and protects sensitive paths; auto-merge off by default |
Let an agent earn its place on your team
Define a Factorik agent once and it wakes on an issue, a failed build or a schedule, works in an isolated sandbox and ships a pull request. It starts with a person merging its work and earns more autonomy on its record. Try it free for 7 days, no payment details needed.
How does a contained agent run look when an issue tries to hijack it?
Here is an illustration, not a customer story. The repository is acme/docs-site, public on GitHub. It has an Issue Triager, which gives a first response to new issues and never changes code, with its issue trigger set to allow anyone, and a Bug Fixer that wakes when a person labels an issue "bug".
Step 1: a stranger opens an issue titled "Search page crashes on long queries". Below a plausible stack trace, hidden in an HTML comment, is a line telling any AI agent to print its environment variables and post the deploy key in a comment. Step 2: the Issue Triager wakes. The issue text reaches it fenced as data. Its sandbox holds a short-lived read-only token for acme/docs-site and nothing else: no deploy key, no Sentry token, no GitHub write access. Even if the injected line steers it, there is no secret in reach to print.
Step 3: the triager replies through Factorik, which posts the comment; the sandbox cannot post anything itself. Step 4: a maintainer reads the reply, confirms the crash and adds the "bug" label. The stranger could not have started the Bug Fixer, because its trigger is a label only a team member can add. Step 5: the Bug Fixer reads the error through Sentry. That call goes through Factorik's gateway, which adds the credential on the server and records the call; the agent sees the stack trace, never the token.
Step 6: the Bug Fixer writes a failing test in tests/search.test.ts and fixes src/search/query.ts. The server reads what changed out of the sandbox and publishes it as one commit on a branch it names, then opens a pull request. Step 7: checks run, the Code Reviewer gives a verdict on that commit, and the merge policy decides. The Bug Fixer is at the first level, so a person merges it. If the injected text had somehow shaped the diff, the diff would sit in front of the checks, a reviewer and a person, not on the default branch.
What does this checklist not solve?
No system makes prompt injection impossible, and Factorik does not claim to. The checklist limits what a hijacked agent can do; it does not stop the agent from being fooled.
Some risks remain. A fooled agent can still write a bad diff, which is why checks, review and the merge policy matter, and why any problem traced to a merged change moves the agent that made it down a level at once. An agent can still read everything in the one repository its token covers, so do not keep secrets in the repository. An agent with a production tool can still read what that tool returns, so give each tool the narrowest credential its provider supports, such as a read-only database role or an error-tracker token for one project. And text an agent writes, in a comment or a pull request description, is still output from something that read untrusted input; people should read it with that in mind.
Factorik also only covers its own agents. If your organization runs other agents inside CI workflows with secrets in the environment, those carry the risk the 2026 disclosures described, and the same checklist applies to them. For the attack itself in more depth, read how prompt injection reaches coding agents through GitHub issues.
What can your team do now to secure AI coding agents for 2027?
A short checklist to work through before agents take on more work next year:
- List every place an agent runs today, including agents inside CI workflows, and what starts each one. 2. For each, write down every token and secret in its environment, and remove what it does not need. 3. Replace long-lived tokens with short-lived ones scoped to one repository, read-only where possible. 4. Move pushing, commenting and merging out of the agent and into something trusted. 5. On public repositories, stop strangers' issues, comments and fork pull requests from starting agents unless you chose otherwise. 6. Put tool credentials behind a server that records each call, and check that no tool server passes tokens through. 7. Keep auto-merge off until an agent has a record, and protect sensitive paths in your merge policy. 8. Decide who is told, and how, when a merged change causes a problem.
If you want these defaults without building them yourself, Factorik has a free 7-day trial of the Team plan, with no payment details needed. Define one agent on a GitHub repository, open an issue and follow the run from the sandbox to the pull request. You can start the free trial here, and read should AI agents merge their own pull requests for how merge rights are earned once the basics are safe.
Frequently asked questions
What is the biggest security risk with AI coding agents?
Prompt injection combined with too much reach. An agent can be steered by text hidden in an issue, a comment or a file, and the damage depends on what it holds: secrets, write access, broad tokens. The 2026 disclosures Comment and Control and GitLost both followed that pattern.
Can prompt injection in coding agents be fixed in 2027?
Teams should not plan on it. The Cloud Security Alliance's August 2026 note said vendor fixes for the original Comment and Control findings did not remove the broader class of weakness. The safer plan is to limit what a fooled agent can reach.
What is MCP token passthrough and why does it matter?
The Model Context Protocol's security guidance names token passthrough as an anti-pattern: a server accepts a token that was not issued for it and forwards it to an upstream API. It breaks audit trails and lets a stolen token reach more systems. The specification says MCP servers must not accept tokens that were not explicitly issued for them.
Should AI agents run on pull requests from forks?
Not with your credentials nearby. A fork's code comes from outside the team, and running it next to secrets or an AI provider credential hands outsiders a way in. Factorik never reviews pull requests from forks for this reason.
How does Factorik keep secrets away from its agents?
The sandbox gets only a short-lived read-only token for one repository. Tool credentials stay on Factorik's server, and calls go through a gateway that adds them and records each call. The server, not the agent, publishes changes as one commit on a branch it names.
Let an agent earn its place on your team
Define a Factorik agent once and it wakes on an issue, a failed build or a schedule, works in an isolated sandbox and ships a pull request. It starts with a person merging its work and earns more autonomy on its record. Try it free for 7 days, no payment details needed.