Google's AI Agent Automatically Rewrites Code to Fix Security Vulnerabilities
Google DeepMind has introduced a new AI agent that autonomously identifies and resolves critical security vulnerabilities in software code. Named CodeMender, the system has already delivered 72 security patches to major open-source projects within the past six months.
Detecting and resolving vulnerabilities remains a notoriously difficult and labor-intensive task, even with established automated techniques like fuzzing. Google DeepMind’s previous research, including AI-driven initiatives such as Big Sleep and OSS-Fuzz, has successfully uncovered new zero-day vulnerabilities in well-reviewed codebases. Yet this success introduces a new challenge: as AI accelerates the discovery of flaws, the pressure on developers to address them also grows.
CodeMender was created to address this growing imbalance. It functions as a fully autonomous AI agent that takes a complete approach to securing software. The system operates both reactively—patching newly identified vulnerabilities as they emerge—and proactively—rewriting existing code to eliminate entire classes of security risks before they can be exploited. This enables developers and project maintainers to focus more time on building new features and improving software performance.
The system relies on the sophisticated reasoning abilities of Google’s recent Gemini Deep Think models. This underlying technology helps the agent debug and resolve complex security issues with significant autonomy. CodeMender is also equipped with a suite of tools that allow it to carefully analyze and assess code before making any modifications. It further incorporates a validation phase to ensure proposed fixes are accurate and do not create unexpected issues, often referred to as regressions.
Given the high stakes involved in code security, even as large language models evolve, a single coding error can be extremely costly. CodeMender’s automated validation framework is thus essential. It systematically verifies that each proposed fix addresses the underlying cause of the vulnerability, maintains functional correctness, does not disrupt existing tests, and aligns with the project’s coding conventions. Only patches that meet all of these strict criteria are presented for human review.
To enhance the system's effectiveness, the DeepMind team developed new techniques for the AI agent. CodeMender employs advanced program analysis, drawing on static and dynamic analysis, differential testing, fuzzing, and SMT solvers. These tools help it thoroughly examine code patterns, control flow, and data flow to detect the underlying causes of security flaws and structural weaknesses.
The architecture also relies on a multi-agent setup, where specialized agents handle different aspects of a given problem. For example, one dedicated large language model-based tool analyzes differences between the original code and modified versions. This helps the main agent confirm that its proposed changes do not introduce unwanted side effects, and allows it to adjust its strategy as needed.
In one example scenario, CodeMender resolved a vulnerability involving a heap buffer overflow that was flagged in a crash report. Although the ultimate solution modified only a few lines of code, the root cause was not immediately clear. By employing debugger and code search tools, the agent identified that the actual issue stemmed from incorrect stack management of Extensible Markup Language (XML) elements during parsing, located in a different section of the codebase. In another instance, the agent developed a sophisticated patch for a complex object lifetime issue, adapting a custom C code generation system within the target project.
Beyond responding to known bugs, CodeMender is built to proactively strengthen software against future attacks. The team deployed the agent to add -fbounds-safety annotations to parts of libwebp, a widely used image compression library. These annotations guide the compiler to insert bounds checks into the code, helping prevent attackers from exploiting buffer overflows to run arbitrary code.
This improvement is especially relevant given that a heap buffer overflow in libwebp, documented as CVE-2023-4863, was previously exploited in a zero-click iOS attack. According to DeepMind, if these annotations had been in place at the time, that specific vulnerability—and most other buffer overflows in the annotated sections—would have been rendered unexploitable.
The AI’s proactive repair process involves detailed decision-making. When adding annotations, it can autonomously resolve new compilation errors and test failures that result from its own modifications. If validation uncovers that a change has disrupted functionality, the agent uses that feedback to self-correct and try an alternative solution.
Despite the encouraging initial results, Google DeepMind is proceeding cautiously with deployment, prioritizing reliability. Currently, every patch created by CodeMender is reviewed by human experts before being submitted to open-source projects. The team is incrementally increasing submissions to maintain high standards and systematically integrate feedback from the open-source community.
Looking forward, the researchers plan to connect with maintainers of mission-critical open-source projects and share CodeMender-generated patches. By incorporating community input, they aim to eventually release CodeMender as a publicly available tool for all software developers.
In the coming months, the DeepMind team also intends to publish technical papers and reports detailing their methodology and outcomes. This initiative represents an early step in exploring how AI agents can proactively repair code and fundamentally strengthen software security for everyone.
See also: CAMIA privacy attack reveals what AI models memorise

Interested in learning more about AI and big data from industry experts? Attend the AI & Big Data Expo in Amsterdam, California, or London. This comprehensive event is part of TechEx and runs alongside other top tech events including the Cyber Security Expo. Click here for more information.
AI News is delivered by TechForge Media. Discover other upcoming enterprise technology events and webinars here.
Related article
Ollie bets privacy focus to win AI assistant race
To be genuinely helpful, an AI assistant must understand its user deeply. Ollie, a personal assistant designed for daily life, operates on the premise that this doesn’t require surrendering your data or compromising your privacy.While certain enterpr
How AI LIVE: London Will Explore AI & Industrial Automation
The summit will convene C-suite executives from around the globe to address pressing challenges in global industries, ranging from AI-driven disruption to economic volatility.AI LIVE: The London Summit will gather over 2,000 international leaders und
Anthropic Enters AI Legal Tech Market as Competition Intensifies
Anthropic unveiled a suite of new chatbot capabilities on Tuesday, aimed at delivering automated support to legal practices. These enhancements expand upon Claude for Legal, the firm-specific platform introduced earlier this year, by adding specializ
Related Special Topic Recommendations
Comments (0)
0/500
Google DeepMind has introduced a new AI agent that autonomously identifies and resolves critical security vulnerabilities in software code. Named CodeMender, the system has already delivered 72 security patches to major open-source projects within the past six months.
Detecting and resolving vulnerabilities remains a notoriously difficult and labor-intensive task, even with established automated techniques like fuzzing. Google DeepMind’s previous research, including AI-driven initiatives such as Big Sleep and OSS-Fuzz, has successfully uncovered new zero-day vulnerabilities in well-reviewed codebases. Yet this success introduces a new challenge: as AI accelerates the discovery of flaws, the pressure on developers to address them also grows.
CodeMender was created to address this growing imbalance. It functions as a fully autonomous AI agent that takes a complete approach to securing software. The system operates both reactively—patching newly identified vulnerabilities as they emerge—and proactively—rewriting existing code to eliminate entire classes of security risks before they can be exploited. This enables developers and project maintainers to focus more time on building new features and improving software performance.
The system relies on the sophisticated reasoning abilities of Google’s recent Gemini Deep Think models. This underlying technology helps the agent debug and resolve complex security issues with significant autonomy. CodeMender is also equipped with a suite of tools that allow it to carefully analyze and assess code before making any modifications. It further incorporates a validation phase to ensure proposed fixes are accurate and do not create unexpected issues, often referred to as regressions.
Given the high stakes involved in code security, even as large language models evolve, a single coding error can be extremely costly. CodeMender’s automated validation framework is thus essential. It systematically verifies that each proposed fix addresses the underlying cause of the vulnerability, maintains functional correctness, does not disrupt existing tests, and aligns with the project’s coding conventions. Only patches that meet all of these strict criteria are presented for human review.
To enhance the system's effectiveness, the DeepMind team developed new techniques for the AI agent. CodeMender employs advanced program analysis, drawing on static and dynamic analysis, differential testing, fuzzing, and SMT solvers. These tools help it thoroughly examine code patterns, control flow, and data flow to detect the underlying causes of security flaws and structural weaknesses.
The architecture also relies on a multi-agent setup, where specialized agents handle different aspects of a given problem. For example, one dedicated large language model-based tool analyzes differences between the original code and modified versions. This helps the main agent confirm that its proposed changes do not introduce unwanted side effects, and allows it to adjust its strategy as needed.
In one example scenario, CodeMender resolved a vulnerability involving a heap buffer overflow that was flagged in a crash report. Although the ultimate solution modified only a few lines of code, the root cause was not immediately clear. By employing debugger and code search tools, the agent identified that the actual issue stemmed from incorrect stack management of Extensible Markup Language (XML) elements during parsing, located in a different section of the codebase. In another instance, the agent developed a sophisticated patch for a complex object lifetime issue, adapting a custom C code generation system within the target project.
Beyond responding to known bugs, CodeMender is built to proactively strengthen software against future attacks. The team deployed the agent to add -fbounds-safety annotations to parts of libwebp, a widely used image compression library. These annotations guide the compiler to insert bounds checks into the code, helping prevent attackers from exploiting buffer overflows to run arbitrary code.
This improvement is especially relevant given that a heap buffer overflow in libwebp, documented as CVE-2023-4863, was previously exploited in a zero-click iOS attack. According to DeepMind, if these annotations had been in place at the time, that specific vulnerability—and most other buffer overflows in the annotated sections—would have been rendered unexploitable.
The AI’s proactive repair process involves detailed decision-making. When adding annotations, it can autonomously resolve new compilation errors and test failures that result from its own modifications. If validation uncovers that a change has disrupted functionality, the agent uses that feedback to self-correct and try an alternative solution.
Despite the encouraging initial results, Google DeepMind is proceeding cautiously with deployment, prioritizing reliability. Currently, every patch created by CodeMender is reviewed by human experts before being submitted to open-source projects. The team is incrementally increasing submissions to maintain high standards and systematically integrate feedback from the open-source community.
Looking forward, the researchers plan to connect with maintainers of mission-critical open-source projects and share CodeMender-generated patches. By incorporating community input, they aim to eventually release CodeMender as a publicly available tool for all software developers.
In the coming months, the DeepMind team also intends to publish technical papers and reports detailing their methodology and outcomes. This initiative represents an early step in exploring how AI agents can proactively repair code and fundamentally strengthen software security for everyone.
See also: CAMIA privacy attack reveals what AI models memorise

Interested in learning more about AI and big data from industry experts? Attend the AI & Big Data Expo in Amsterdam, California, or London. This comprehensive event is part of TechEx and runs alongside other top tech events including the Cyber Security Expo. Click here for more information.
AI News is delivered by TechForge Media. Discover other upcoming enterprise technology events and webinars here.
Ollie bets privacy focus to win AI assistant race
To be genuinely helpful, an AI assistant must understand its user deeply. Ollie, a personal assistant designed for daily life, operates on the premise that this doesn’t require surrendering your data or compromising your privacy.While certain enterpr
How AI LIVE: London Will Explore AI & Industrial Automation
The summit will convene C-suite executives from around the globe to address pressing challenges in global industries, ranging from AI-driven disruption to economic volatility.AI LIVE: The London Summit will gather over 2,000 international leaders und
Anthropic Enters AI Legal Tech Market as Competition Intensifies
Anthropic unveiled a suite of new chatbot capabilities on Tuesday, aimed at delivering automated support to legal practices. These enhancements expand upon Claude for Legal, the firm-specific platform introduced earlier this year, by adding specializ





Home






