Securing AI Agents in CI/CD: Least-Privilege Tokens and Human Approval Gates Aikido Security's December 2025 PromptPwnd disclosure showed that GitHub Actions and GitLab CI/CD workflows feeding untrusted issue, PR and commit text into AI agents — including Gemini CLI, Claude Code, OpenAI Codex and GitHub AI Inference — let a malicious issue make Google's Gemini CLI agent write secrets into a public issue, which Google fixed within 4 days, with press coverage reporting at least 5 Fortune 500 companies exposed. A follow-up April 2026 study by researcher Aonan Guan and colleagues, Comment and Control, hijacked Anthropic's Claude Code Security Review, Google's Gemini CLI Action and GitHub's Copilot coding agent via crafted PR titles, comments and issue bodies, with 3 vendors confirming the findings, while the UK's National Cyber Security Centre argues prompt injection may never be fully mitigated and should be treated as residual risk. The guidance recommends read-only tokens, pinned actions, a propose-don't-apply split between agent and validated job, and human approval gates for sensitive actions, citing the 2025 tj-actions compromise that reached roughly 23,000 repositories. TL;DR AI agents in CI/CD read text written by strangers while holding credentials, and researchers have already shown that this combination can leak secrets. Prompt injection can't be filtered away, so design for impact: Least privilege: read-only tokens, almost no secrets, pinned actions. Propose, don't apply: the agent suggests, and a separate validated job acts. Human gates: a person approves anything sensitive, and merges stay human. | 4 days | 5+ | 3 | ~23,000 | |---|---|---|---| | Time Google took to fix the Gemini CLI issue after Aikido's disclosure | Fortune 500 companies reported as exposed to PromptPwnd | Vendors that confirmed the Comment and Control findings | Repositories reached by the 2025 tj-actions compromise | Figures come from Aikido's disclosure via press coverage , SecurityWeek, and the Cloud Security Alliance. AI agents are moving into the pipeline. They triage issues, review pull requests, apply labels, and sometimes open fixes, often as ordinary GitHub Actions jobs. That creates a situation CI/CD security never had to handle: a component that reads text written by strangers, holds credentials, and acts on what it reads. This post covers what has gone wrong, a simple mental model, and two habits that limit the damage when an agent is tricked. The examples use GitHub Actions, but the principles apply to any CI system. Why this is a different kind of risk A traditional workflow does what its YAML says. An agent's behavior is also shaped by whatever it reads at runtime. In a pipeline, much of that text comes from people you don't control: issue titles, PR descriptions, commit messages, branch names, code comments, and logs. Instructions hidden in that content are called prompt injection . It's tempting to compare it to SQL injection, but the UK's National Cyber Security Centre argues the comparison is dangerous https://www.ncsc.gov.uk/blog-post/prompt-injection-is-not-sql-injection . SQL injection has a structural fix, parameterised queries, while a language model has no inherent boundary between data and instructions. The NCSC concludes that prompt injection may never be fully mitigated, so it should be treated as residual risk. If a system can't tolerate what's left, an LLM may be the wrong tool for it. Remember: The goal isn't a perfect filter. It's to make sure that when an agent is tricked, there's very little it can do. What has already happened timeline title How the risk surfaced Oct 2025 : Meta publishes the Agents Rule of Two Dec 2025 : Aikido discloses PromptPwnd : NCSC says prompt injection may never be fully mitigated Apr 2026 : Comment and Control hijacks agents from three vendors May 2026 : CSA publishes research on prompt injection in GitHub Actions Aug 2026 : CSA reports new flaws kept emerging after the fixes - PromptPwnd December 2025 . Aikido Security found workflows https://aikido.dev/blog/promptpwnd-github-actions-ai-agents in GitHub Actions and GitLab CI/CD that fed untrusted issue, PR, or commit text straight into AI agent prompts. - The agents included Gemini CLI, Claude Code, OpenAI Codex, and GitHub AI Inference. - They also held high-privilege tokens and tools such as shell access or issue editing. - In a proof of concept against Google's Gemini CLI repository, a malicious issue made the agent write secrets into a public issue. - Google fixed it within days, and press coverage reported at least five Fortune 500 companies were exposed. - Comment and Control April 2026 . Researcher Aonan Guan and colleagues showed https://www.securityweek.com/claude-code-gemini-cli-github-copilot-agents-vulnerable-to-prompt-injection-via-comments/ that crafted PR titles, comments, and issue bodies could hijack Anthropic's Claude Code Security Review, Google's Gemini CLI Action, and GitHub's Copilot coding agent, usually with no action from a maintainer. - All three vendors confirmed the findings. - Guan's point was that layered defenses can be bypassed, because injected text is simply context the agent is designed to process. - It keeps recurring. A later Cloud Security Alliance research note https://labs.cloudsecurityalliance.org/wp-content/uploads/2026/08/CSA research note ai coding agent ci prompt injection 20260807-csa-styled.pdf reported new, independently exploitable flaws emerging in these tools after the original fixes. Patching one product at a time doesn't end the problem. Warning: Passing untrusted text through an environment variable prevents classic command injection, but not prompt injection. The model still receives the attacker's words. The attack chain is short, and none of it requires special access: sequenceDiagram autonumber actor Attacker participant Issue as Public issue or PR participant WF as Workflow runner participant Agent as AI agent participant Secrets as Tokens and API keys participant Thread as Public thread or logs Attacker- Issue: Posts text with hidden instructions Issue- WF: Event triggers the workflow automatically WF- Agent: Passes the text into the prompt Note over Agent: The model cannot reliably tell data from instructions Agent- Secrets: Uses its tools to read credentials Agent- Thread: Writes the credentials into a comment or log Attacker- Thread: Reads the leaked secrets The Rule of Two Meta's security team proposed a simple test https://ai.meta.com/blog/practical-ai-agent-security/ : until prompt injection can be reliably detected and refused, an agent session should combine no more than two of these three properties. | Property | What it looks like in CI/CD | |---|---| | A. Untrusted input | Issue and PR text, comments, commit messages, branch names, the code under review, logs | | B. Sensitive access | A broad GITHUB TOKEN , API keys, cloud credentials, deployment secrets | | C. State change or external communication | Pushing commits, editing issues, posting comments, running shell commands with network access | The vulnerable workflows above combined all three. Break any link in the chain and the attack fails: flowchart LR A "A. Untrusted input