The Challenge
A 2025 study of over 7,700 AI-generated files from public GitHub repositories found 4,241 Common Weakness Enumeration instances across 77 vulnerability types. Python files showed vulnerability rates of 16-18%. These aren't new attack patterns. AI coding agents consistently reproduce old security mistakes that traditional static application security testing tools miss.
The core challenge is architectural. Your security stack was built for human developers who write code, submit it for review, and wait for approval. Coding agents operate differently. They clone repositories, modify files, run tests, and push changes without asking permission at each step. This autonomy creates a fundamentally different risk profile that your existing controls cannot address.
Three risk amplifiers distinguish these systems from passive assistants. First, autonomy without oversight: agents execute multi-step workflows while developers are in meetings. Second, expanded tool access: agents connect to version control systems, CI/CD pipelines, and production infrastructure. Third, persistence and memory: unlike stateless tools, agents maintain context across sessions, creating attack vectors through memory poisoning that traditional application security tools were never designed to detect.
The Environment and Constraints
Enterprises face a timing problem. Development teams are adopting coding agents faster than security teams can assess them. Anthropic's research on trustworthy agents acknowledges this tension, noting that agents operate with reduced human oversight, increasing the potential for misinterpreted intent and creating attack surfaces for prompt injection exploits.
This constraint isn't theoretical. Prompt injection vulnerabilities have been documented in at least 14 major AI products since April 2023. OpenAI's CISO has publicly acknowledged that prompt injection remains an unsolved security problem despite extensive red-teaming. You're deploying systems with known, unresolved vulnerability classes.
Traditional security tools fail here because they were optimized for human-written code, not agent-generated output. Your SAST scanner won't catch an indirect prompt injection where a poisoned comment in a GitHub issue instructs an agent to add a backdoor during a routine bug fix. Your secrets management won't prevent an agent from logging API keys in error messages that get committed to public repositories.
The regulatory environment compounds the problem. SR 11-7 model risk management requirements, GDPR data lineage obligations, and emerging EU AI Act provisions all apply to coding agents. You need demonstrable preventive controls, not just incident logs. Regulators will ask not just "what did the agent do?" but "how did you ensure it operated safely?"
The Approach Required
Defense-in-depth across the agent lifecycle is the only viable strategy. No single control is sufficient.
Start with inventory and visibility. You cannot secure what you cannot see. Maintain a registry of all coding agents, their permissions, and access scopes. This registry should track which agents are active, what resources they can access, and who authorized their deployment. Treat this as you would your model inventory under SR 11-7, not as optional documentation.
Implement least privilege access with time-bound credentials that expire after a set duration. An agent that needs read access to a repository should not have write access. An agent that needs to query a database should not have schema modification privileges. Rotate keys automatically, not when a breach is suspected.
Deploy runtime guardrails that evaluate agent actions before execution. Specific checks include command validation to block shell commands matching known exploit patterns, API call inspection to verify requests align with the agent's intended function, and code security scanning to detect injection vulnerabilities and hardcoded secrets before code is committed.
Integrate agent security into your CI/CD pipelines. Require code signing for agent-generated code so you can trace every change back to its source. Implement mandatory review gates for high-risk operations such as database schema changes or infrastructure provisioning. This isn't about slowing development. It's about preventing a 2 a.m. schema migration triggered by a poisoned comment.
Use dedicated secrets management. Never embed credentials in prompts or agent memory. Implement automatic secret scanning that runs on every commit. A common failure pattern: an agent generates a database connection string with the password in plaintext and commits it to a public repository. Your security team receives a GitHub alert 20 minutes later, but the credential has already been scraped by automated bots.
Results and What Works
Runtime observability enables continuous validation that pre-deployment testing cannot provide. Agents behave differently under production loads and with real-world inputs.
Your observability stack should capture traces of every agent decision, tool invocation, and code modification with full execution context. This means logging not just what the agent did, but why it made that decision and what data informed the choice.
Anomaly detection identifies deviations from baseline behavior patterns: unusual API sequences that don't match the agent's typical workflow, unexpected resource access, command patterns that differ from historical norms. Drift monitoring detects when agent outputs diverge from expected patterns over time. An agent that consistently generates secure code for six months, then suddenly starts introducing SQL injection vulnerabilities, has drifted. Your observability system should flag this change immediately, not during a quarterly audit.
Connect agent telemetry to your existing SIEM and SOAR platforms for unified security operations. Your security team needs to see what agents are doing in real time, not just reviewing logs after an incident.
What Would Be Done Differently
The biggest gap is treating coding agents as developer-equivalent rather than as high-risk models requiring enhanced oversight. Organizations that apply SR 11-7 model risk management principles from Day 1 avoid the retrofit problem.
Model Context Protocol tools introduce unique challenges. MCP tools can mutate their definitions post-installation. A tool approved as safe on Day 1 could silently reroute API keys to attackers by Day 7. You need continuous validation, not point-in-time approval.
Incident response readiness is frequently overlooked. Create runbooks for rogue agent and compromise scenarios before you need them. Include kill switches that disable agents instantly when anomalous behavior is detected. Your security team should be able to shut down an agent with a single command, not a multi-step approval process.
Takeaways for Your Team
Treat agent-generated code as untrusted input requiring specialized validation, not as developer-equivalent output that passes through standard review gates.
Build your AI registry now. You need a single source of truth for all coding agents, their versions, permissions, and operational status. This isn't documentation for compliance theater. It's operational infrastructure.
Implement defense-in-depth across inventory, access controls, runtime guardrails, CI/CD integration, secrets management, and incident response. No single layer is sufficient.
Connect coding agent security to your broader AI governance framework. Access reviews, change management, data lineage, and model risk management all apply. The OWASP Top 10 for LLMs, NIST AI RMF, and EU AI Act requirements aren't future concerns. They're current obligations.
Your coding agent just pushed a change to production. Can you explain what it did, why it did it, and how you verified it was safe? If not, you have a governance gap, not just a security problem.



