
Key Takeaways
- AI coding agents have moved past autocomplete. They clone repositories, run commands, open pull requests, and in some environments merge code, which means the controls built for suggestion-only tools no longer match what these systems can actually do.
- Insecure output is the norm, not the exception. Independent research puts the failure rate on secure coding benchmarks well above 40%, so treating AI-generated code as pre-vetted is a governance gap, not an efficiency gain.
- Permission scoping determines the blast radius of a bad decision. An agent with standing write access to production, secrets, or CI/CD configuration turns a single prompt injection or hallucinated dependency into a full incident.
- The pipeline, not the agent, has to be the control point. Guardrails that depend on the model behaving correctly will fail eventually; guardrails enforced in CI/CD, permission systems, and policy engines hold even when the agent doesn't.
- A single control is not a security program. Detecting insecure patterns, scoping access, and hardening CI/CD are three distinct layers that have to work together, not three options to pick from.
AI coding agent security has quietly become one of the least-covered risk categories in enterprise AppSec, even as coding agents move from suggestion tools into systems that clone repositories, install dependencies, and open pull requests on their own. AppSec and platform engineering teams built their current controls around a simple assumption: a human wrote every line of code that reached the pipeline, and a human made every decision about what that code could touch. Coding agents break that assumption from both directions. They generate code at a volume no reviewer can fully absorb, and they often inherit credentials and tool access that were provisioned for convenience rather than for a system that can act without waiting for approval.
Closing that gap starts with three questions:
- What guardrails belong inside the CI/CD pipeline?
- How insecure patterns get caught and fixed before they ship?
- How much access an agent actually needs to do its job?
This article walks through all three.
Why the Old AppSec Model Doesn't See Coding Agents
Code-suggestion tools and coding agents look similar from a distance, but they sit on opposite sides of a hard line: does a human approve every action before it happens? A completion tool suggests a snippet you accept or reject. A coding agent can clone a repository, run a test suite, install a dependency, edit a configuration file, and push a branch, all inside a single task, often without a human in the loop for any of it.
Adoption has outpaced governance. A JetBrains survey of more than 24,000 developers across 194 countries found that 85% now use AI coding tools regularly, and 62% rely on at least one AI coding assistant, agent, or code editor day to day. Apiiro's analysis of Fortune 50 repositories found that AI-assisted developers produce three to four times more commits than their peers, but those commits land in fewer, larger pull requests that touch more files and services per change. Bigger, multi-touch PRs slow review and dilute reviewer attention exactly when scrutiny matters most.
The attack surface expanded before the controls did. Coding agents connect to version control systems, CI/CD pipelines, cloud provider APIs, and sometimes production infrastructure. Autonomy without a checkpoint means a single misstep can cascade through an entire delivery pipeline before anyone notices. Traditional SAST, DAST, and code review processes were tuned for human-paced change volume and human-authored vulnerability patterns. They were not built to catch what happens when both the volume and the pattern shift at once.
How Do You Detect and Remediate Insecure Code Patterns Introduced by AI Coding Assistants?
Detection has to start from a specific premise: AI-generated code is functionally correct far more often than it is secure, and those two properties are not related in the way most review processes assume.
Where the vulnerabilities cluster
The scale of the problem is well documented. Veracode's 2025 GenAI Code Security Report tested more than 100 large language models across dozens of real programming tasks and found that generative AI introduces at least one security vulnerability in 45% of cases, with cross-site scripting and log injection flaws appearing in roughly 86% to 88% of relevant test scenarios. The Cloud Security Alliance has reported a similar pattern, with 62% of AI-generated code solutions containing design flaws or known vulnerabilities even when developers used current frontier models. Apiiro's research across Fortune 50 enterprises found that AI-assisted development produced 322% more privilege escalation paths and 153% more architectural design flaws compared with human-written baselines, the kind of structural issue that scanners often miss and reviewers struggle to catch on a first pass.
A newer risk sits alongside these familiar categories: package hallucination. A large-scale academic study analyzing over 570,000 code samples across sixteen LLMs found that nearly one in five recommended packages did not exist, a gap attackers have started to exploit by registering malicious packages under the exact names models hallucinate, a technique now known as slopsquatting.
Building a remediation workflow that keeps pace
The fix isn't a single scanner. It's a workflow that treats every AI-generated change as untrusted until it clears the same bar as code from an unfamiliar contractor:
- Run static analysis, software composition analysis, and secrets detection on every AI-authored pull request, gated in CI so nothing merges without a pass.
- Require security-specific acceptance criteria before generation for sensitive code paths, such as parameterized queries or defined session expiry, so the criteria become testable checks rather than hopes.
- Verify AI-suggested packages against public registries and vulnerability databases before install, and flag anything below a minimum package age or maintainer history threshold.
- Don't rely on human review as the last line of defense. Research on developers using AI coding assistants found they wrote measurably less secure code while rating it as more secure than code they wrote unassisted, a false sense of security that erodes the review layer that used to catch these gaps.
How Should Organizations Scope the Permissions and Access of AI Coding Agents in Dev Environments?
Detection catches what already shipped. Permission scoping decides what an agent could ever do in the first place, and it's the control that most organizations still get wrong.
Least privilege, then least agency
Least privilege asks what an identity can access. A newer, complementary discipline asks a different question: what is this agent allowed to decide on its own? The distinction matters because a coding agent can hold perfectly reasonable credentials and still take an unreasonable action if nothing constrains its agency, only its access.
In practice, that means scoping should be task-specific: one repository, one branch, one job, one set of approved tools, and short-lived credentials rather than standing access. Read-only should be the default. If an agent writes code, it should open a pull request, not commit directly to a protected branch, and it shouldn't be able to approve its own pull request, modify CI/CD configuration, retrieve production secrets, or trigger a deployment. The pipeline should be the control point, not the agent's judgment about what's safe.
Treat pipeline-facing changes as privileged events
Coding agents don't only touch application code. They modify build scripts, CI/CD configuration, package manager hooks, and Dockerfiles, files that execute automatically in trusted contexts with elevated privileges. Any AI-generated change to package.json scripts, GitHub Actions workflows, or deployment manifests deserves the same scrutiny as a production access request, including required human approval and CI checks that diff configuration files before they merge. Agent configuration files, the rules and instructions files that steer an agent's behavior across every future session, deserve the same treatment: they're a persistence mechanism, and an attacker who can quietly modify one controls every generation that follows.
Governance hasn't caught up to the risk. Only 41% of organizations have a formal policy governing AI-generated code, according to JetBrains' developer survey, and agent identity ownership is still fragmented across security, IT, and emerging AI security functions in most enterprises. That fragmentation is exactly where standing, unscoped agent access tends to survive unnoticed.
How Do You Establish Security Guardrails for AI Coding Agents in CI/CD Pipelines?
Guardrails that live only inside the model's own reasoning will eventually fail, because a well-crafted prompt injection or a poisoned dependency doesn't have to convince a human, it only has to convince the model. The pipeline is where enforcement has to live instead.
Make the pipeline the enforcement layer
Applying least privilege to every identity in the pipeline, human accounts and automation accounts alike, means scoping permissions tightly by role, separating deployment authority from approval authority, and auditing those permissions on a regular cadence rather than letting them accumulate. Security leaders who help set standards for agentic development have been direct about where the boundary belongs: the pipeline, not the agent, should be the control point, with enforcement built into the pipeline in code rather than left to the assumption that a model will behave carefully. Policy should also fail closed, per OWASP's AI Agent Security Cheat Sheet: if risk classification, approval validation, or audit logging fails for any reason, the pipeline should block the action rather than let it through.
Protect what the agent reads and writes
Pin third-party actions and dependencies to a specific commit hash, not a mutable version tag, per OWASP's Secure Coding with AI Cheat Sheet; attackers have already demonstrated they can rewrite tags on widely used security-scanning actions to redirect them toward credential-stealing payloads. Configure pipelines to fail on known vulnerabilities in dependencies regardless of whether a human or an agent introduced them, and cross-reference every AI-suggested package against vulnerability databases before it enters the build. None of this requires trusting the agent to make the right call. It requires making the wrong call structurally unavailable.
A Layered Guardrail Stack Is the Only Model That Holds
No single control above is sufficient on its own, and treating any one of them as the finish line is how gaps reappear. Detection catches insecure patterns after generation. Permission scoping limits what an agent can act on. Pipeline guardrails enforce policy at the one point every change has to pass through. Defense in depth means running all three together, continuously, not choosing the one that's easiest to implement this quarter.
Consider what happens without that layering. In 2025, a popular AI coding platform shipped a default database schema template that omitted row-level security policies. The flaw wasn't in any single application; it was in the template every generated application inherited, and it went on to affect more than 170 production deployments before it was caught and patched. No amount of after-the-fact code review would have scaled to catch a structural default like that. What would have caught it: a permission model that never gave the generated schema standing write access to other tenants' data in the first place, and a pipeline gate that tested for exactly that access pattern before deployment.
This is the shift AppSec and platform engineering teams are now responsible for leading. Visibility into what agents exist and what they can access, posture management that continuously assesses agent configuration against policy, and runtime enforcement that doesn't wait for a quarterly audit are no longer SOC-only concerns. They belong as much to the teams who own the pipeline and the codebase as to the teams who own detection and response. Shadow AI adoption inside developer tooling is one of the fastest-growing blind spots inside that shift, and it's one AppSec teams are increasingly asked to close.
Detection after exfiltration is not security, and neither is a permission model nobody reviews after the pilot ends. Building a durable program means treating coding agent access with the same rigor as any other privileged identity in the SDLC, from build time to runtime, and revisiting that access as often as the tools themselves change.
Where to Start Building These Guardrails
The agent is the new endpoint, and inside the software development lifecycle, it's also one of the newest privileged identities in the pipeline. Securing AI coding agents means putting the controls in the permission model, the code review workflow, and the CI/CD configuration itself, not in the hope that the agent's judgment holds up under pressure.
Zenity's guide, The Guide to Securing Coding Agents, walks AppSec and platform engineering teams through the permission models, detection workflows, and pipeline guardrails covered in this article, with a practical framework your team can put to work this quarter.
Download the guide to securing coding agents to get started.
FAQs About AI Coding Agent Security
What is AI coding agent security?
AI coding agent security covers the controls that govern what autonomous coding tools can access, what code they're allowed to ship, and how their actions are reviewed inside the software development lifecycle. It sits at the intersection of AppSec, identity and access management, and CI/CD governance, rather than belonging to any one of those disciplines alone.
How is securing a coding agent different from securing a code-suggestion tool?
A code-suggestion tool only produces a snippet a developer chooses to accept or reject. A coding agent can clone repositories, install dependencies, run commands, and open pull requests on its own, so the risk isn't just what it writes, it's what it's able to do while writing it. Security controls have to account for both.
How do you detect insecure code introduced by AI coding assistants?
Run static analysis, software composition analysis, and secrets detection on every AI-authored pull request as a required CI gate, not an optional step. Pair that with security-specific acceptance criteria written before generation, and verify AI-suggested packages against vulnerability databases and registry age before install, since hallucinated dependencies are a distinct risk category from insecure logic.
What permissions should an AI coding agent have in a dev environment?
Scope access to a single repository, a single branch, and a defined set of tools, using short-lived credentials rather than standing developer-equivalent access. Read-only should be the default, with write access limited to opening pull requests rather than committing directly to protected branches or approving its own changes.
Should AI coding agents be allowed to merge code without human review?
No. An agent should be able to propose a change through a pull request, but merge authority, deployment authority, and the ability to modify CI/CD configuration should stay with a human reviewer or a separate, independently validated policy engine. Separating the agent that proposes an action from the system that approves it is what keeps a single compromised decision from cascading through the pipeline.
What's the difference between least privilege and least agency?
Least privilege limits what an identity can access, such as which repositories or credentials an agent can reach. Least agency limits what that identity is allowed to decide on its own, such as whether it can merge a pull request or trigger a deployment without approval. An agent can hold appropriately scoped credentials and still take an unreasonable action if its agency, not just its access, isn't constrained.
Can automated code review alone catch AI-introduced vulnerabilities?
Not reliably. Research on developers using AI coding assistants found they rated their AI-generated code as more secure than code they wrote unassisted, even though it measurably wasn't, which erodes the human review layer that has historically caught these gaps. Automated scanning has to be paired with permission scoping and pipeline controls, not treated as a standalone safeguard.
Who should own AI coding agent security: AppSec, platform engineering, or the SOC?
In most organizations, it's shared and that's part of the problem. Agent identity ownership is commonly split across security, IT, and emerging AI security functions, which leaves gaps in coverage. AppSec and platform engineering teams are best positioned to own the pipeline-level and permission-level controls, since they already own the systems a coding agent has to pass through.
All Academy PostsSecure Your Agents
We’d love to chat with you about how your team can secure and govern AI Agents everywhere.
Get a Demo

