ARQ: Agentic CodeQL Query Refinement for C/C++ Vulnerability Detection
On the map: LLM agents and tool use → Agent threats, guardrails and governance
Abstract (arXiv)
Static analyzers have been widely adopted for vulnerability detection in C/C++ programs. Query-based static analyzers (e.g., CodeQL) encode vulnerable code patterns in detection queries and match them against source code. However, existing queries still suffer from false positives (FPs, incorrectly flagging benign code as vulnerable) and false negatives (FNs, missing real vulnerabilities). We present ARQ, an agentic framework that automatically refines C/C++ CodeQL queries using execution-grounded evidence from synthesized C/C++ programs. Our key insight is that a synthesized program exposes a query's weakness whenever its execution disagrees with the query's verdict. If the program is genuinely vulnerable but the query stays silent, the query has an FN weakness; if the program is safe but the query fires anyway, it has an FP weakness. ARQ then runs an LLM-based refinement loop that repairs the query using these disagreements as ground truth. Unlike previous query refining methods, ARQ requires no labeled datasets, no commit history, and no vulnerability-specific templates. We demonstrate the effectiveness of ARQ by refining 12 official CodeQL queries using three commercial LLMs (GPT-5.4, Claude-Sonnet-4.6, and Gemini-3.5-flash). We compare both ARQ-refined and original CodeQL queries on the Juliet v1.3 and FormAI v2 datasets and show that ARQ-refined queries detect substantially more true positives, by up to 119.8%, with a Precision of at least 98.0% throughout. ARQ successfully fixed three unresolved GitHub issues raised in the official CodeQL query repository that had remained open for as long as textit27 months. The refined queries also exposed two previously undiscovered bugs in the real-world libraries libpng and zlib.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 8 of its 22 references that are in the map. First posted on arXiv 21 Aug 2026.
Builds on
8 of 22 references.
References · 8
- 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 139
- 2024IRIS: LLM-Assisted Static Analysis for Detecting Security Vulnerabilitiescited by 103
- 2023DiverseVul: A New Vulnerable Source Code Dataset for Deep Learning Based Vulnerability Detectioncited by 102
- 2022Repair Is Nearly Generation: Multilingual Program Repair with LLMscited by 68
- 2024Vul-RAG: Enhancing LLM-based Vulnerability Detection via Knowledge-level RAGcited by 68
- 2023Prompt-Enhanced Software Vulnerability Detection Using ChatGPTcited by 51
- 2024Finetuning Large Language Models for Vulnerability Detectioncited by 40
- 2025KNighter: Transforming Static Analysis with LLM-Synthesized Checkerscited by 24
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025QLCoder: A Query Synthesizer For Static Analysis of Security Vulnerabilities
- 2026An Empirical Analysis of CodeQL False Positives and Query Refinements for Java Vulnerabilities ↗
- 2026Verify Before You Fix: Agentic Execution Grounding for Trustworthy Cross-Language Code Analysis
- 2026Veritas: Grounding LLM Agents for Reliable Vulnerability Reasoning over Stripped Binaries
- 2026Tool-Guided Retrieval-Augmented Repair for Securing LLM-Generated C Code
- 2026RAVEN: Agentic RAG for Automated Vulnerability Repair
- 2026Code-Augur: Agentic Vulnerability Detection via Specification Inference
- 2026When Passing Tests Hides Vulnerabilities: An Empirical Study of Silent Failures in Agentic Systems