✦ Zenity is a Founding Member of ServiceNow's Control Tower Alliance

AI Coding Agent Security: Permissions, CI/CD Guardrails, and Runtime Controls

Portrait of Emily Wise
Emily Wise
•
Cover Image

Key Takeaways

  • Enforcement has to sit outside the agent. Controls that depend on the model's judgment can fail, while permissions, isolation, and policy checks enforced independently still hold.
  • Generated code fails security checks often enough to need verification. Across Veracode's 2025 and 2026 benchmarks, roughly 38% to 45% of tested code-completion tasks introduced a vulnerability, though that isn't a production-wide rate.
  • Permissions set the blast radius. Separate agent identities, short-lived credentials, explicit tool access, and fast revocation limit what a bad decision can reach.
  • Pipeline gates are necessary but not sufficient. Continuous integration and continuous delivery (CI/CD) checks can block unsafe merges, but they can't stop an agent from exposing credentials earlier in a task.
  • A control isn't real until you've tested it. Try prohibited actions in a pilot and collect evidence that each one is blocked.

AI coding agent security is the practice of protecting the code agents produce, the environments they operate in, and the systems they can access. It combines application security (AppSec) checks with scoped identities, isolated execution, tool restrictions, approval policies, and activity monitoring.

This article is for AppSec and platform engineering teams that need to control coding agents in their own environments. It explains which controls to implement, where those controls belong, and how to validate them, from permission scoping and pipeline configuration to runtime enforcement and vendor evaluation.

Why Traditional AppSec Controls Miss Coding Agents

Coding agents differ from suggestion tools because they can act: they clone repositories, run commands, install dependencies, and open pull requests. For a full explanation of how they work, see our guide to what coding agents are.

Many AppSec programs assume a human wrote every change and decided what it could touch. Agents break both assumptions. They generate changes faster than reviewers can absorb, and they can inherit credentials provisioned for convenience. Adoption is broad: in JetBrains' 2025 survey of 24,534 developers, 85% said they regularly use AI tools for coding and development, and 62% rely on at least one AI coding assistant, agent, or code editor. JetBrains' 2026 survey found that 90% of professional developers used AI coding agents at work at least weekly, counting local and cloud agents. Definitions differ across these surveys, so treat them as directional indicators rather than a single trend line.

How Do You Detect and Remediate Insecure Code From AI Coding Agents?

Detection starts from one premise: code that works isn't necessarily code that's secure. The studies below point to the same conclusion, but each measures something different.

What the research shows, and what it doesn't

  • Veracode (2025 and 2026): Veracode's GenAI Code Security research has tracked more than 100 models since 2025, using code-completion tasks across four languages and four weakness types, with no security instructions in the prompts. Its 2025 report found a vulnerability in 45% of cases, and its averages stayed near 55% to 56% secure through its 2026 report. Its Fall 2026 update then reported an average pass rate of 62%, with about 38% of tasks introducing a vulnerability and the best models reaching 73%. Cross-site scripting and log injection remain the weakest classes. The tests used models directly, not agents with tooling or review, and the results don't represent production vulnerability rates.
  • BaxBench: BaxBench, a benchmark of 392 backend tasks, found in its 2025 evaluation of 11 models, that the best model tested reached only 62% functional correctness. On average, security exploits worked against around half of the correct programs each model produced. It tested language models on backend code generation, not agentic workflows, and newer models may score higher.
  • Apiiro: Apiiro's observational analysis of Fortune 50 repositories it studied between December 2024 and June 2025 reported that AI-assisted developers committed three to four times as often, in fewer and larger pull requests. It also reported that privilege escalation paths rose 322% and architectural design flaws rose 153%. This is vendor-published telemetry, so it shows an association in those repositories, not a controlled effect.
  • Package hallucination: A USENIX Security 2025 study generated 576,000 code samples across 16 models and found average hallucinated-package rates of at least 5.2% for commercial models and 21.7% for open-source models. Attackers can register those nonexistent names with malicious code, a form of package confusion attack.
  • Human overconfidence: A Stanford user study of 47 participants that used an older Codex-based assistant (codex-davinci-002) found that participants with AI help wrote less secure code and were more likely to believe it was secure. It tested specific tasks with that assistant, not today's coding agents or automated review tools.

Together, these studies agree on direction without agreeing on size, and none of them measures your repositories. Track escaped vulnerabilities by weakness type in your own code to set a real baseline.

Build a remediation workflow that keeps pace

Treat every agent-generated change as untrusted until it clears the same bar as code from an unfamiliar contractor.

  • Run static application security testing (SAST), software composition analysis (SCA), and secrets detection on every agent-authored pull request, and require passing results before merge.
  • Write security acceptance criteria before generation for sensitive paths, such as authorization checks or parameterized queries, so they become testable.
  • Verify suggested packages against the registry before install, and flag new packages, missing maintainer history, or unexpectedly recent publication dates.
  • Pair human review with automated checks and security tests so no single layer carries the load.

Remediation should follow a fixed sequence: a finding, an assigned owner, a proposed fix, independent validation, an approved merge, and a retest. An agent-generated patch should pass the same security requirements as any other change, and the agent that wrote it shouldn't be the one that validates it.

How Should Organizations Scope AI Coding Agent Permissions?

Scope access to the task, and enforce it through the platform instead of through instructions to the model. These defaults are a starting point to adjust for the work at hand.

  • Separate agent identities: Give each agent its own identity so activity is attributable and revocable without disabling a developer's account.
  • Short-lived credentials: Issue task-specific credentials that expire when the task ends.
  • Explicit tool access: Approve specific tools, operations, and Model Context Protocol (MCP) servers instead of granting wildcard access.
  • Restricted network destinations: Allow outbound traffic only to approved destinations, such as an internal package mirror.
  • Revocation: Plan to suspend an agent's identity, tokens, and tool access in minutes, and test that you can.

Scoping a task to one repository and one branch is a useful starting point, not a rule for every job.

Task-based permission examples

  • Fixing a failing unit test: Read access to one repository, write access to a feature branch, no secrets, and network access limited to an approved package mirror.
  • Upgrading a dependency: The same repository scope, installs only from an approved registry, a pull request as the only output, and no ability to edit CI/CD configuration.
  • Investigating a production bug: Read-only access to logs and the relevant code, no production credentials, and no write access to any branch.

These are illustrative defaults, so adapt them to your environment.

Least privilege, then least agency

Least privilege limits what an identity can reach. Least agency limits what an agent can decide on its own, such as whether it can merge or deploy without approval. An agent can hold well-scoped credentials and still take an unreasonable action if nothing constrains its autonomy.

Treat pipeline-facing files as privileged

Agents also change files that run automatically with elevated rights: build scripts, workflow definitions, Dockerfiles, and package manager hooks. Require code owner approval and extra checks for these paths. Agent instruction and configuration files deserve the same treatment, because a quiet change to one steers every later session.

How Do You Enforce Guardrails Across Coding Agent Workflows?

CI/CD gates can block unsafe changes from merging or deploying. They can't prevent an agent from exposing credentials or running a destructive command earlier in a task, so enforcement has to span development, runtime, and the pipeline.

OWASP's AI Agent Security Cheat Sheet describes the pattern. The agent proposes an action, and a separate policy or execution component independently validates scope, privilege, and approval state before anything runs. It also advises failing closed when risk classification, approval validation, policy lookup, or audit logging fails.

Match each threat to an enforcement point

The table pairs common threat scenarios with where the control belongs and what evidence shows it works.

Threat Scenario

Enforcement Point

Evidence to Collect

Malicious issue text redirects an agent

Tool authorization, sandbox, network policy

Blocked command or outbound request

Agent attempts to read production credentials

Identity, secrets manager, filesystem policy

Access denied and attributable event

Agent changes pipeline configuration

Branch protections, required reviewers, policy checks

Change cannot bypass required approval

Agent adds an unsafe dependency

Approved registry, dependency policy, CI checks

Unapproved package or version is blocked

Agent introduces an authorization flaw

Security tests, review, analysis

Cross-user access test fails the build

Compromised MCP server requests sensitive data

MCP allowlist, argument validation, access restrictions

Request denied and tool activity recorded

Harden the pipeline itself

  • Required checks: Make security checks mandatory status checks that agents can't skip or edit.
  • Independent approvals: Enforce branch protections and required reviewers outside the agent's control, and prevent agents from approving their own changes.
  • Protected pipeline files: Restrict who and what can change workflows and deployment manifests.
  • Isolated runners: Run agent-driven jobs on ephemeral runners without production credentials.
  • Untrusted contributions: Avoid privileged triggers on untrusted pull request content. GitHub notes that the pull_request_target and workflow_run triggers, combined with checking out an untrusted pull request, expose a repository to compromise.

Pinning works differently for actions and packages, so don't treat the two as interchangeable. For GitHub Actions, pin third-party actions to full-length commit SHAs, or use GitHub's workflow lockfiles where you've adopted them. For packages, use your ecosystem's version, lockfile, and integrity mechanisms. Mutable tags carry real risk: in March 2025, attackers re-pointed tags on the widely used tj-actions/changed-files action (CVE-2025-30066).

How to Evaluate AI Coding Agent Security Solutions

A short proof of concept tells you more than a feature list. Ask vendors to demonstrate six capabilities in your environment.

  • Block a prohibited command or data transfer.
  • Enforce repository and credential scope.
  • Handle malicious instructions in issues or tool responses.
  • Prevent unauthorized changes to security controls.
  • Revoke agent access during an incident.
  • Reconstruct activity across the initiating user, agent, tools, and resulting changes.

For GitHub, GitLab, and Azure DevOps, document the supported deployment variants, required permissions, enforcement location, review workflows, and limitations, and verify each platform separately. A logo list can't substantiate integration depth. Posture management that assesses agent configuration, permissions, and integrations against policy is one layer worth looking for; see how AI Security Posture Management (AISPM) fits.

Where to Start: A Rollout Checklist

Build the program in stages, and expand only after you verify each stage.

  1. Inventory the agents in use and name an owner for each.
  2. Map what each agent can reach, including repositories, credentials, tools, and network destinations.
  3. Pilot controls on lower-risk repositories first.
  4. Test prohibited actions and keep the evidence.
  5. Set revocation and investigation procedures before you need them.
  6. Expand access as verification and monitoring mature.

The agent is the new endpoint, and inside the software development lifecycle it's also one of the newest privileged identities. Securing AI coding agents means putting controls in the permission model, the review workflow, and the pipeline, and proving they work.

Zenity's Guide to Securing Coding Agents walks AppSec and platform engineering teams through the permission models, detection workflows, and pipeline guardrails covered here. To discuss your environment, connect with the team at Zenity.

FAQs About AI Coding Agent Security

What is AI coding agent security?

AI coding agent security is the practice of protecting the code agents produce, the environments they operate in, and the systems they can access. It combines application security checks with scoped identities, isolated execution, tool restrictions, approval policies, and activity monitoring.

How do you detect insecure code introduced by AI coding agents?

Run static analysis, software composition analysis, and secrets detection on every agent-authored pull request as a required check. Add security tests for sensitive logic such as authorization, and verify suggested packages against the registry before install. Benchmarks show a substantial failure rate in tested scenarios, so measure your own.

What permissions should an AI coding agent have in a dev environment?

Scope access to the task: a separate agent identity, only the repositories and tools the task needs, short-lived credentials, and restricted network destinations. Read-only is a sensible default, with write access limited to opening pull requests. Plan for fast revocation.

Should AI coding agents be allowed to merge code without human review?

No. An agent can propose a change through a pull request, but merge, deployment, and CI/CD configuration changes should stay with an independent reviewer or policy engine. Keeping the proposer separate from the approver stops one bad 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 the agent can decide on its own, such as merging or deploying without approval. An agent can hold well-scoped credentials and still act unreasonably if its autonomy isn't constrained.

Can automated code review alone catch AI-introduced vulnerabilities?

Not reliably. Scanners can miss business-logic flaws, such as a missing authorization check on an otherwise working endpoint. Pair scanning with security tests that probe cross-user access, independent review, and execution controls that limit what the agent can do before code reaches review.

Can CI/CD controls prevent all coding agent attacks?

No. Pipeline controls can stop unsafe changes from merging or deploying, but they act after the agent has worked. They can't by themselves prevent credential exposure, destructive commands, or data transfers earlier in a task, so pair them with scoped identities, isolation, network controls, and monitoring.

What should teams do when a coding agent behaves unexpectedly?

Suspend the agent's identity, tokens, and tool access first. Then reconstruct what it did from logs covering the initiating user, tools, commands, and resulting changes, rotate any credentials it could reach, and review or revert its changes. Afterward, retest the control that failed and update policy.

Who should own AI coding agent security?

In many organizations, ownership is split across security, IT, and AI security functions, which can leave gaps. AppSec and platform engineering teams are well positioned to own pipeline-level and permission-level controls, since they already own the systems an agent passes through. Either way, name an accountable owner for each agent.

All Academy Posts

Secure Your Agents

We’d love to chat with you about how your team can secure and govern AI Agents everywhere.

Get a Demo