arXiv(opens in a new tab)cs.SESep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.04535

An Empirical Analysis of CodeQL False Positives and Query Refinements for Java Vulnerabilities

Amirali Sajadi, Saikat Dutta, Preetha Chatterjee

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Amirali Sajadi

College of Computing & Informatics

Drexel University, Philadelphia, PA, USA

amirali.sajadi@drexel.edu

Saikat Dutta

Department of Computer Science

Cornell University, Ithaca, NY, USA

saikatd@cornell.edu

Preetha Chatterjee

College of Computing & Informatics

Drexel University, Philadelphia, PA, USA

preetha.chatterjee@drexel.edu

Abstract—Static application security testing (SAST) tools help developers find vulnerabilities before deployment. However, false positive reports result in substantial triage efforts. This paper studies whether CodeQL false positives in Java security analysis are recurring, explainable patterns that can be reduced by refining the analysis itself. We run CodeQL's Java security query suite on 167 CVE instances spanning 110 projects, focusing on the ten queries with highest false positive rates. From these queries, we manually review 500 sampled false positive paths/locations and construct a source-level taxonomy of false positive causes. The five high-level categories of false positive causes are Missed Path Constraint or Sanitization (36.6%), Benign Execution Context (29.4%), and Missing Trust Boundary Modeling (27.6%), followed by Imprecise Concurrency Modeling (5%) and Imprecise Sink Modeling (1.4%).

Using insights from our empirical analysis, we implement CodeQL refinements that model recurring false positive patterns to enable their detection and filtering at the query level. Our refinements remove 81.8% of reviewed false positives. On the full selected-query dataset, they remove 15.8% of reported paths and locations while retaining 7/8 true positives, showing that many false positives can be reduced directly in the analysis, but also that fixed refinements often depend on project-specific context. To address this generalization gap, we evaluate whether agentic coding tools can adapt refinement patterns to new project-specific contexts. With our refinement patterns as templates to extend, they succeed on 56% and 62% of tasks, respectively, with query compile-pass rates above 90%. However, without this guidance, the success rates drop to 28% for both tools, while the compile rate drops to 30-36%. Overall, our results support a refinement-oriented SAST workflow in which recurring false positives are modeled in CodeQL queries and then automatically adjusted to different project contexts, reducing repeated triage.

Index Terms—Static application security testing, false positives, CodeQL, Java vulnerabilities, taint analysis, query refinement

I. INTRODUCTION

Static Application Security Testing (or SAST) tools help developers find vulnerabilities before software is deployed. They are valuable as they can be automatically run codebases, can be integrated into CI/CD workflows, and report source locations that developers can inspect for bugs. However, false positive alerts limit their overall effectiveness [1]–[5]. When a tool reports too many alerts that do not correspond to real or exploitable vulnerabilities, developers waste time triaging false alerts instead of fixing real defects. Further, false positives discourage the usage of SAST tools and limit their adoption in broader open-source software. In practice, most developers expect false positive rates below 15–20% for adoption, while more than 76% of SAST warnings can be irrelevant to real vulnerabilities [6], [7].

CodeQL [8] is one of the most popular query-based SAST tools. Its query-driven design makes the analysis logic explicit and allows the query to be inspected, modified, and re-executed, making it well suited for systematically studying how and why false positives arise. However, like other SAST tools, CodeQL alerts can still be false positives. CodeQL relies on predefined program patterns and taint analysis specifications to identify potential vulnerabilities. These specifications model how user-controlled data (source) flows through the program and reaches sensitive operations (sinks), but they can often be incomplete, difficult to maintain, outdated, or overly conservative. As a result, benign dataflows may be labeled as dangerous when project-specific logic already ensures security. For example, project-specific authentication mechanisms may not be captured if they are not explicitly modeled in CodeQL's specifications. In these cases, the underlying issue is not only that the alert needs to be filtered, but that the query cannot accurately model the program's behavior.

Prior work has studied why developers do not adopt SAST and how false positive suppression can be used in practice [6], [9], [10]. Others have studied the quality of SAST results and taint analysis performance across tools and benchmarks [7], [11]–[15]. However, these studies do not use source-level false positive evidence to refine the underlying SAST analyses, nor do they study whether such empirically grounded refinements can be adapted to project-specific contexts. Recent work has also used post-processing, ranking, exploit generation, and LLM-based workflows to reduce false positives [16]–[19]. However, LLM-based methods need to be used after every run, which can become very expensive very quickly in CI and they are also prone to imprecise reasoning, which may be hard to reproduce. This motivates the question of how to systematically incorporate fine-grained, project-specific evidence into SAST analyses without incurring high manual and monetary cost.

In this paper, we present a systematic study of false positive reduction through CodeQL query refinements. Prior false positive studies mostly characterize static-analysis warnings, study developer reactions, or filter alerts after they are reported. Our study instead connects source-level false positive causes

Figure

Fig. 1. Overview of the Study Methodology.

to actionable changes in the CodeQL queries themselves. Grounded in our empirical analysis, we design refinements that model recurring false positive patterns directly in CodeQL query logic. We then study whether agentic LLMs can adapt these refinements to project-specific contexts. This differs from LLM-based false positive filtering, where the model typically filters the alerts after analysis has already run. In our setting, the final artifact is a modified CodeQL query that can be inspected, rerun, and reused to prevent similar false positives in future analyses. However, maintaining separate refinements for each project can be costly, since codebases and threat models change over time. Our approach therefore studies reusable refinements and agent-assisted adaptation as a way to make project-specific query refinement more practical.

We frame our study around three main research questions:

RQ1: What are the source-level reasons behind CodeQL false positives in Java projects? First, we run CodeQL's 'security-extended' query suite on 167 CVEs, focusing on the top ten queries that produce the most false positives. We then manually inspect a statistically significant subset of 500 confirmed false positives and identify fine-grained causes grouped into five broader families, i.e., Missed Path Constraint or Sanitization, Benign Execution Context, Missing Trust Boundary Modeling, Imprecise Concurrency Modeling, and Imprecise Sink Modeling. More importantly, this analysis identifies the patterns behind the project-specific refinements which must be modeled to adequately address false positives in CodeQL queries.

RQ2. Can targeted query refinements reduce recurring false positive patterns? We use the insights from RQ1 to design CodeQL refinements that encode recurring false positive causes. Our refinements remove 409/500 (81.8%) reviewed false positives, retaining 7/8 (87.5%) true positives across the full dataset. While developers can suppress individual CodeQL alerts at specific source locations, these suppressions only affect the singular instance and do not address the underlying analysis pattern. In contrast, our refinements address the recurring false positive patterns directly in the query logic.

RQ3: Can agentic LLMs adapt CodeQL refinements to project-specific contexts and prevent future false positives? Though our RQ2 refinements significantly reduce false positives within the reviewed sample, their generalizability remains limited as many refinements are project-specific. This motivates our study of agent-based query adjustments. A

developer may review an alert and decide it is a false positive in a specific project. We ask whether this feedback can be used to adapt the relevant RQ2 refinement to that project. In this setting, the agent receives a false positive, the project context, and the corresponding refinement queries from RQ2 as a template to extend. The agent then adjusts the query in order to eliminate the project-specific false positive pattern. We evaluate this workflow using OpenAI Codex (GPT 5.5) and Claude Code (Claude Opus 4.6) agents, showing that guided refinements provide evidence-based reductions in false positives in up to 56% of cases, compared to 28% when agents write refinements without our RQ2 templates. The large gap between guided and unguided runs highlights the value of empirical refinement patterns as reusable templates for project-specific query adaptation.

Our study reveals the following novel insights: First, our results demonstrate that an overwhelming majority of false positives can be captured using source-level patterns. Second, most of these patterns can be modeled via CodeQL via targeted query refinements, which drastically reduce false positives while retaining true positive alerts. Third, these refinements are very project-specific and so, by construction, they are very hard to easily generalize to many projects. Finally, our early evaluation of LLM agents reveal that they could be useful in automating the query refinement task to some extent but they often struggle with understanding the semantics of CodeQL and the code pattern. So, more future research is needed to carefully guide LLM agents into automating these refinements. Our full replication package is available at [20].

References (48)