RedCodeAgent: Microsoft’s Next-Gen AI Red Team Automates Code Agent Security Assessment

RedCodeAgent: Microsoft’s Ambitious Next-Gen AI Red Team Automates Code Agent Security Assessment

User avatar placeholder
Written by Dave W. Shanahan

November 4, 2025

Microsoft Research has introduced a significant breakthrough in the field of AI safety and cybersecurity: RedCodeAgent, an automatic red-teaming agent specifically designed to stress-test and evaluate code-generating AI systems, known as code agents. This innovation, revealed in a detailed November 2025 Microsoft Research blog post, responds to the growing challenges associated with the widespread adoption of large language models (LLMs) that write code, automate workflows, and power modern software development.​

The Rise of Code Agents and Their Risks

AI-powered code agents like OpenCodeInterpreter, ReAct, MetaGPT, Cursor, and Codeium are revolutionizing how software is developed and maintained. These advanced language models can generate production-level code, debug scripts, and even execute complex workflows within code interpreters. Such capabilities dramatically improve developer productivity and open new horizons for automation—but they also bring heightened safety and security risks.​

Unlike traditional software, where vulnerabilities can often be discovered through static analysis or predetermined test cases, LLM-powered code agents have dynamic behaviors that are not easily captured by static benchmarks or simple input rejection tests. Dangerous combinations of prompts, novel jailbreak methods, and creative adversarial attacks can enable these agents to generate and execute malicious or unintended code—posing real threats to software integrity and organizational security.​


Why Existing Safety Benchmarks Fall Short

Conventional red-teaming for AI focuses on simple prompt-rejection: does the model refuse an unsafe or malicious request? However, with code agents, the threat is more nuanced—the AI must not only recognize and reject bad prompts, but also avoid producing and executing dangerous code if those prompts slip past initial defenses. Static benchmarks, which test with a fixed set of malicious queries, often fail to detect real-world scenarios where layered or adaptive attack techniques are used.​

RedCodeAgent addresses this flaw by automating the entire red-teaming process in a way that mirrors the persistent, adaptive nature of actual adversaries. It systematically crafts, tests, and evolves its attack strategies, probing a model’s defenses until weaknesses are found or confidence in security is demonstrated.​


How RedCodeAgent Works: Adaptive and Automated Red Teaming

RedCodeAgent: Microsoft’s Next-Gen AI Red Team Automates Code Agent Security Assessment
RedCodeAgent on automatic red-teaming against a target code agent.

RedCodeAgent introduces a new paradigm for AI security evaluation, based on several innovations:

  • Memory Module: Remembers and accumulates successful attack techniques, enabling it to build upon previous successes and failures as it explores new vulnerabilities.

  • Adaptive Toolbox: Leverages a vast toolkit of red-teaming techniques—including prompt generation, code substitution, jailbreak exploitation, and adversarial optimization. When an attempt fails, RedCodeAgent tries alternative tools or combinations, adapting its approach for the task at hand.​

  • Code Substitution & Function Calling: Simulates real-world attacks by substituting code elements and using advanced algorithms (like Greedy Coordinate Gradient, GCG) to bypass model safety guardrails.​

  • Sandbox Evaluations: All code generated is executed within secure, simulated sandboxes. This dynamic assessment reveals not just if code can be generated, but what it actually does in practice—detecting dangerous operations that static or “LLM-as-a-judge” methods would miss.​

The agent interacts with code models over multiple turns, learning from each trial, and intelligently optimizing prompts and strategies for maximum effect.

RedCodeAgent: Microsoft’s Next-Gen AI Red Team Automates Code Agent Security Assessment
A case study of RedCodeAgent calling different tools to successfully attack the target code agent.

Experimental Insights and Key Findings

Across extensive testing on diverse code agents, programming languages (Python, C, C++, Java), and task scenarios, RedCodeAgent achieves:

  • Higher Attack Success Rates (ASR): It exposes vulnerabilities in both open-source and commercial code agents where fixed and even advanced prompt-based jailbreak methods failed.​

  • Lower Model Rejection Rates: By dynamically crafting more plausible prompts and combining attack tools, RedCodeAgent can trick AI systems into executing risky behaviors at a much higher rate than static baseline tests.

  • Discovery of Unknown Vulnerabilities: RedCodeAgent finds novel exploits in commonly used code agents. In controlled experiments, it uncovered 82 unique vulnerabilities in OpenCodeInterpreter and 78 in ReAct—cases that all other tested baselines missed.​

  • Adaptive Tool Use: The agent spends minimal resources on easy tasks, maximizing efficiency, but quickly escalates to advanced toolchains for harder-to-break defenses—mimicking a real, resourceful attacker.​


Real-World Case Study: Breaking Safety Guardrails

One illustrative attack outlined in the research shows RedCodeAgent using a combination of the GCG algorithm and code substitution. When its initial attempt to delete a file via a prompt is blocked, it persistently refines and modifies the request, eventually combining GCG-generated adversarial prompts and alternative code (like using Python’s pathlib) to circumvent safety filters. Ultimately, it succeeds in making the target code agent execute a forbidden file delete operation—highlighting both the power and necessity of such rigorous red-teaming.​


What Sets RedCodeAgent Apart

Most red-teaming solutions still rely primarily on static prompts and “refusal rates” as proxies for security. RedCodeAgent innovates by:

  • Learning from Attack Trajectories: Not just marking a pass/fail, but analyzing, adapting, and remembering what works—resulting in deeper, iterative exploration of a model’s weaknesses.

  • Systematically Scaling: Its framework enables large-scale, automated safety evaluations—crucial for keeping pace with the speed of LLM updates and deployments in real-world dev environments.  RedCodeAgent: Microsoft’s Next-Gen AI Red Team Automates Code Agent Security Assessment

  • Focusing on End-to-End Risk: By assessing both the model’s willingness to execute dangerous code and the actual impact of that code in a sandbox, RedCodeAgent provides the closest simulation to what a real-world attacker might accomplish.​RedCodeAgent: Microsoft’s Next-Gen AI Red Team Automates Code Agent Security Assessment


The Future of AI Red Teaming and Automated Security

Microsoft Research’s RedCodeAgent establishes a new, safer baseline for enterprise AI solutions. It illustrates the need for continuous, adaptive, and automated testing of LLM-based agents, especially as they become deeply integrated into critical infrastructure, developer tools, and cloud platforms. With AI systems now able to write, test, and deploy software, robust defenses can no longer rely on static analysis or occasional human intervention alone.​

The research team emphasizes the importance of human oversight: while RedCodeAgent uncovers many vulnerabilities missed by current automation, human expertise remains vital for nuanced evaluations and domain-specific risk assessment. The layered, defense-in-depth approach—combining automation, sandboxing, and vigilant security professionals—is essential for a resilient AI-driven future.​


Toward Safer, Smarter Code Agents

With RedCodeAgent, Microsoft Research leads the way in next-generation automated AI red-teaming, enabling developers, organizations, and AI providers to proactively identify and fix vulnerabilities in their code agents before real-world attackers strike. As code agents, like SentinelStep, gain popularity for software development, workflow automation, and coding assistance, tools like RedCodeAgent are critical for ensuring these intelligent systems remain robust, trustworthy, and secure for global users.​​


Discover more from Microsoft News Now

Subscribe to get the latest posts sent to your email.

Image placeholder

I'm Dave W. Shanahan, a Microsoft enthusiast with a passion for Windows, Xbox, Microsoft 365 Copilot, Azure, and more. I started MSFTNewsNow.com to keep the world updated on Microsoft news. Based in Massachusetts, you can email me at davewshanahan@gmail.com.