Let the Trial Begin: A Mock-Court Approach to Vulnerability Detection using LLM-Based Agents
Ratnadira Widyasari, Martin Weyssow, Ivana Clairine Irsan, Han Wei Ang, Frank Liauw, Eng Lieh Ouh, Lwin Khin Shar, Hong Jin Kang, David Lo
TL;DR
VulTrial addresses the challenge of detecting subtle code vulnerabilities by deploying a courtroom-inspired, four-agent multi-agent system built around a shared LLM. By assigning distinct roles—prosecutor, defense attorney, judge, and jury—the framework enables adversarial debate, richer reasoning, and detailed explanations beyond binary labels. Empirical results on PrimeVul show VulTrial with GPT-4o substantially outperforms single-agent baselines and prior multi-agent systems, with instruction tuning on the moderator yielding the largest gains, and generalizes to LLaMA-3.1-8B while demonstrating practical utility through open-world vulnerability disclosures. The work highlights the value of structured interaction and explainable outputs for robust vulnerability detection in real-world software security contexts.
Abstract
Detecting vulnerabilities in source code remains a critical yet challenging task, especially when benign and vulnerable functions share significant similarities. In this work, we introduce VulTrial, a courtroom-inspired multi-agent framework designed to identify vulnerable code and to provide explanations. It employs four role-specific agents, which are security researcher, code author, moderator, and review board. Using GPT-4o as the base LLM, VulTrial almost doubles the efficacy of prior best-performing baselines. Additionally, we show that role-specific instruction tuning with small quantities of data significantly further boosts VulTrial's efficacy. Our extensive experiments demonstrate the efficacy of VulTrial across different LLMs, including an open-source, in-house-deployable model (LLaMA-3.1-8B), as well as the high quality of its generated explanations and its ability to uncover multiple confirmed zero-day vulnerabilities in the wild.
