Knowledge-Enhanced Agentic Vulnerability Repair
The paper introduces KeaRepair, a novel agentic automated vulnerability repair framework that enhances patch generation by integrating multi-dimensional historical knowledge with tool-augmented reasoning and closed-loop validation, achieving a state-of-the-art 83.64% repair rate on C/C++ vulnerabilities.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine software as a massive, intricate castle. Over time, thieves (hackers) find hidden cracks in the walls (vulnerabilities) to sneak inside. For a long time, finding these cracks was hard and expensive. But recently, super-smart AI "detectives" (Large Language Models) have gotten so good at spotting these cracks that they are finding them faster than anyone can fix them.
The problem is: Finding the crack is easy; fixing it correctly is hard.
Current AI repair tools are like enthusiastic but inexperienced apprentices. They often guess where the crack is (and guess wrong), or they try to patch it using a "one-size-fits-all" method that doesn't fit the specific shape of the hole.
The paper introduces KEAREPAIR, a new system designed to be a Master Architect rather than just an apprentice. Here is how it works, broken down into simple steps:
1. The Problem with the Old Way
- The "Hallucination" Issue: If you ask a standard AI to fix a bug, it might make things up. It might say, "The problem is here!" when the problem is actually over there. It's like a detective guessing the location of a crime scene based on a hunch rather than evidence.
- The "Surface Level" Issue: When looking for past examples of how to fix similar problems, old tools just look for code that looks the same. But in programming, two things can look identical but need completely different fixes. It's like seeing two cars with flat tires and assuming you fix both by just pumping air, when one actually needs a new wheel.
2. The KEAREPAIR Solution: A Three-Step Master Plan
KEAREPAIR changes the game by adding two crucial ingredients: Hard Evidence and Deep Knowledge.
Step A: The Detective with a Flashlight (Fact-Grounded Diagnosis)
Instead of letting the AI guess where the problem is, KEAREPAIR gives it a set of specialized tools (like a magnifying glass, a map, and a stress-tester).
- The Analogy: Imagine a detective who doesn't just guess where the thief entered. Instead, they physically trace the footprints (data flow) and check the locked doors (control flow) to get verified facts.
- The Result: The AI doesn't guess the cause of the bug; it is handed a report of proven facts. This stops the AI from making things up.
Step B: The Library of Wisdom (Knowledge-Enhanced Retrieval)
Once the AI knows exactly what the problem is, it needs to find a past example of how to fix it.
- The Analogy: Old systems search a library by looking for books with similar titles (surface code). KEAREPAIR searches by the story of the crime. It looks for past cases where the mechanism of the break-in was the same, even if the building looked different.
- The Twist: It splits the search into two views:
- Data Flow: How did the bad data travel?
- Control Flow: How did the program's logic allow the bad data to pass?
By matching both the "story" and the "logic," it finds the perfect past example to learn from, avoiding bad advice.
Step C: The Iterative Refinement (The Closed Loop)
The AI generates a patch (a fix), but it doesn't stop there.
- The Analogy: Imagine a tailor making a suit. They don't just cut the fabric and hand it over. They put it on the customer, check if it fits, pin it, take it off, adjust it, and try again.
- The Process: KEAREPAIR tries the fix, runs tests to see if it breaks anything else, and if it fails, it asks the AI to try again with the new feedback. It keeps looping until the fix is perfect.
3. The Results: A Masterpiece in the Making
The researchers tested this "Master Architect" on 55 real-world software vulnerabilities (mostly in C/C++ code).
- The Score: When paired with a powerful AI model (Gemini-3.1-Pro), KEAREPAIR successfully fixed 83.64% of the vulnerabilities.
- The Comparison: The best previous tools managed to fix far fewer. KEAREPAIR fixed 9 unique vulnerabilities that the best competing tool couldn't touch at all.
- The Speed & Cost: It did this quickly (under 50 seconds per bug) and cheaply (about 30 cents per bug).
- The Bonus: They also tested it on other languages (Python, JavaScript, Go) and found it worked just as well there, proving it's not just a one-trick pony.
Summary
Think of KEAREPAIR as upgrading from a guessing game to a forensic investigation.
- It uses tools to get hard facts about the bug (no guessing).
- It searches a library for deeply relevant past solutions (not just surface matches).
- It tests and refines the fix until it's perfect.
The paper claims this approach solves the biggest bottleneck in cybersecurity today: the inability to automatically and reliably fix the vulnerabilities that AI is now finding faster than ever.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.