Google has introduced CodeMender, an AI-powered agent designed to automatically detect and patch security flaws in software.
Announced on 6 October 2025 by Raluca Ada Popa and Four Flynn, CodeMender represents a major step toward leveraging artificial intelligence for proactive code security.
CodeMender builds on Google’s earlier AI research in vulnerability discovery, such as Big Sleep and OSS-Fuzz.
While those projects focused on finding new zero-day flaws in well-tested code, CodeMender takes the next logical leap: it not only finds vulnerabilities but also creates and applies high-quality patches without manual intervention.
Over the past six months, the research team has upstreamed 72 security fixes into open source projects, some spanning over 4.5 million lines of code.
By automating the patch process, CodeMender frees developers to concentrate on building new features instead of chasing down elusive bugs.
How CodeMender Works
At its core, CodeMender leverages Google’s Gemini Deep Think models to reason about complex code structures.
It uses a suite of advanced program analysis tools including static and dynamic analysis, differential testing, fuzzing, and SMT solvers to trace root causes of security flaws.
A multi-agent system then orchestrates specialized sub-agents to critique, debug, and validate proposed fixes.
For instance, after CodeMender generates a patch, a separate critique agent compares the original and modified code to ensure functional equivalence and adherence to style guidelines.
An example patch illustrates CodeMender’s capabilities. Faced with a heap buffer overflow in XML parsing, the agent pinpointed the stack mismanagement issue and applied a minimal change:
// Before: missing bounds check
for (int i = 0; i < length; i++) {
buffer[i] = xmlData[i];
}
// After: added safe copy
for (int i = 0; i < length && i < bufferSize; i++) {
buffer[i] = xmlData[i];
}
This simple yet precise update eliminates the overflow while preserving original functionality.
Beyond reactive patches for new vulnerabilities, CodeMender can proactively rewrite existing code to harden libraries against entire classes of bugs.
The team applied -fbounds-safety annotations to parts of the popular libwebp image library, ensuring that any future buffer overflows would be caught at compile time.
Had this feature existed before CVE-2023-4863, a zero-click iOS exploit might have been prevented entirely.
All patches generated by CodeMender undergo human review before being submitted upstream. This cautious approach has already yielded dozens of accepted patches in critical open source projects.
Google plans to collaborate closely with maintainers, gathering feedback to refine CodeMender’s output. In the coming months, detailed technical papers and reports will share the underlying techniques and real-world results.
With CodeMender, Google aims to make robust code security accessible to all developers.
By combining deep learning reasoning with program analysis, this AI agent could transform the way software is secured, reducing the window of exposure for critical vulnerabilities and enhancing trust in the open source ecosystem.
Follow us on Google News, LinkedIn, and X to Get Instant Updates and Set GBH as a Preferred Source in Google.