Home DevSecOps

A DevSecOps playbook for AI-generated code

AI agents now start more than 40% of GitHub pull requests. Build security checks that keep pace with them.

A code pipeline with security checkpoints, one flagged change stopped at a gate, and an engineer at a console

If AI agents are opening pull requests in your repositories, a growing share of the code your security pipeline reviews was written by a machine. GitHub’s Octoverse 2026 report found that by September 2026, more than 40% of pull requests on its platform started with an AI agent’s first draft. And the code still isn’t secure by default. Veracode’s latest testing of 18 AI models, published Oct. 29, 2026, found an average security pass rate of 62%, which means 38% of the coding tasks produced vulnerable code.

We’ve covered why AI-generated code creates risk, including how your AI coding assistant is creating security debt at machine speed and how to mitigate AI-generated code security risks. If you’re new to the practice, start with our beginner’s guide to DevSecOps for independent software vendors (ISVs). This playbook covers what to change in your pipeline now that agents write code on their own.

Limit what each agent can touch

Treat every AI agent like a new contractor with a narrow job. Give each one its own identity and access token instead of a developer’s credentials, and scope that token to the repositories and actions it needs. Agents should be able to open pull requests, but they shouldn’t be able to merge them, change branch protection rules, or reach production secrets.

Review these permissions the same way you review employee access. Our recent article on why your build pipeline is now your product’s attack surface explains how a single overprivileged token can turn into a supply chain incident.

Check every package before it installs

AI models sometimes recommend software packages that don’t exist. Researchers presenting at USENIX Security 2025analyzed 576,000 code samples from 16 models and found average hallucinated package rates of at least 5.2% for commercial models and 21.7% for open source models, covering 205,474 unique made-up package names. If an attacker registers one of those names on a public registry, an agent that installs it brings malicious code straight into your build.

Start by installing dependencies only from a private registry or proxy that you control. Next, block packages that are brand new or have little download history until someone approves them. Then require lockfiles, so a pull request that adds a dependency shows exactly what changed.

Keep secrets out of prompts and commits

Agents read your code, and they can copy what they find into commits, logs, and prompts. Turn on secret scanning with push protection so credentials are blocked before they reach the repository. GitHub reports that its push protection ran 5.8 billion scans in the past year, nearly four times 2025’s pace, which tells you how routine this control has become. Add pre-commit hooks on developer machines, and keep production secrets in a vault the agent can’t read.

Make scanning AI-generated code a merge requirement

Static application security testing (SAST) for your own code and software composition analysis (SCA) for open source dependencies should both be required checks, so nothing merges until they pass. That matters because AI models are uneven. In Veracode’s October 2026 results, models produced secure code for SQL injection tasks 84% of the time but for cross-site scripting (XSS) only 18% of the time. Java was the weakest language tested, at a 31% pass rate.

Automated dependency updates help on the other side. GitHub says developers merged more than 30 million Dependabot pull requests in its latest reporting year. Let those tools keep your dependencies current, and let required scans catch what agents introduce.

Match human review to risk

Not every change needs your most senior engineer. A text fix doesn’t carry the risk of a change to authentication. Use a CODEOWNERS file or your platform’s equivalent to require review from a designated owner for high-risk paths, such as authentication, payments, encryption, and data access. Changes to those areas get a careful human review no matter who or what wrote them.

AI-assisted code review can help reviewers keep up (GitHub reports its use grew more than 90% in a year), but it should flag issues for a person, not approve changes on its own. Our article on vibe coding and the security debt of new development methods shows what happens when nobody owns that judgment.

Guard against prompt injection in your repository

Agents take instructions from more places than your developers realize. An issue, a README file, a code comment, or documentation the agent fetches can contain hidden instructions telling it to leak data or weaken a check. The Open Worldwide Application Security Project (OWASP) lists prompt injection as the top risk in its Top 10 for large language model applications.

Treat everything an agent reads as untrusted input. Limit the tools and network access agents have, especially when they work on issues filed by outside users. Protect agent instruction and configuration files with the same CODEOWNERS rules as your most sensitive code, since a quiet edit there changes how every future agent task behaves.

Keep an audit trail and an SBOM

Record which agent made each change, which person started the task, and who approved the merge. Most platforms capture this if agents use their own identities. Generate a software bill of materials (SBOM) with each release so you can answer quickly when a dependency turns out to be compromised. Our guide on how ISVs can comply with SBOM recommendations covers the basics.

That record also helps with compliance. If you’re pursuing System and Organization Controls 2 (SOC 2) or answering customer security questionnaires, auditors and buyers will want evidence of how code changes are reviewed and approved. Agent identities, required checks, and merge approvals give you that evidence automatically.

Roll it out in 30 days

In the first week, give agents their own scoped identities and turn on secret scanning with push protection. In week two, route installs through a registry you control and add new-package checks. In week three, make SAST and SCA required checks and add CODEOWNERS rules for high-risk paths. In week four, lock down agent configuration files, confirm your audit trail, and generate your first SBOM.

None of these controls slows a healthy team down for long, and each one makes agent output safer to accept. The ISVs that put them in place now can use AI agents at full speed and still show customers the security evidence they ask for.


Datacap - We Solve Payment Problems
Mike Monocello

Mike Monocello is the co-founder of DevPro Journal and Managed Services Journal, and a training and content specialist at BlueStar US. Previously, Monocello was a member of the RSPA board of directors, the editor-in-chief of Business Solutions magazine, and a former VAR and ISV.

×