ChainAgent: Automated Chainable Vulnerability Discovery in PHP Web Applications
Authors: Xinyi Wang, Yeting Li, Shizhe Cui, Jiaming Guo, Qin Mai, Yecheng Sun, Hengyu Yang, Yujie Sun, Huina Chao, Yang Xiao, Feng Li, Wei Huo
Organizations: {CAS-KLONAT, BKLONSPT}, Institute of Information Engineering, CAS · School of Cyber Security, UCAS · China Southern Power Grid Digital Grid Group Information and Telecommunication Technology Co., Ltd.
High-impact attacks on PHP web applications often chain limited-capability vulnerabilities with other flaws or intended behaviors. Discovering these chains requires identifying flaws and the dependencies enabling capability composition. Existing vulnerability discovery techniques analyze flaws in isolation, while attack planning assumes known components. This separation makes it difficult to discover previously unknown components whose security relevance becomes apparent only through their potential roles in an exploit chain. We present ChainAgent, a goal-directed LLM-agent framework that jointly discovers exploit-chain components and their capability dependencies in source code. Guided by an empirical study of 386 real-world web exploit chains, ChainAgent represents vulnerabilities and functional gadgets--intended program behaviors that can be repurposed in attacks--through preconditions and capabilities over security-relevant objects. Instead of discovering vulnerabilities first and constructing attack paths afterward, ChainAgent uses an evolving exploit graph to guide source-code inspection. It searches backward from unmet preconditions for capability producers and forward from discovered capabilities for functional gadgets that consume or amplify them. Object-centered chaining knowledge from our empirical study directs searches toward promising vulnerability classes, functional operations, and object accesses. We evaluate ChainAgent against Codex, a general-purpose coding agent, on 15 PHP applications across three shared LLM backends. ChainAgent achieves 42.02%--44.63% recall for goal-reaching components and recovers up to 4.4 times as many correct goal-reaching dependency edges as Codex. An additional evaluation of 30 real-world PHP applications identifies 20 vulnerabilities and 13 exploit chains, nine of which achieve remote code execution (RCE).
Figures & tables
Fig. 1 : Juniper J-Web exploit chain. Two uses of one upload flaw (CVE-2023-36846 [ 16 ] ) and environment injection (CVE-2023-36845 [ 17 ] ) compose with PHP’s normal startup behavior to achieve RCE. P and C abbreviate server-generated filenames.
Repository
Artifacts
Exploit Chains
Metasploit Framework
1144
205
Nuclei Templates
4999
114
Awesome POC
1108
67
Total
7251
386
TABLE I : Summary of the collected exploit artifacts and retained exploit chains.
Technical Impact
Count
Ratio
Execute Unauthorized Code or Commands
366
94.8%
Read Data
14
3.6%
Gain Privileges or Assume Identity
5
1.3%
Modify Data
1
0.3%
Total
386
100.0%
TABLE II : RQ1: Final technical impacts of the collected exploit chains.
Repository
Chains
Vuln.
Gadgets
Gadget Chains
Metasploit
205
434
39
39 (19.0%)
Nuclei
114
237
3
3 (2.6%)
Awesome-POC
67
137
7
7 (10.4%)
Total
386
808
49
49 (12.7%)
TABLE III : RQ2: Composition of the collected exploit chains by data source.
Fig. 2 : An exploit chain in FreePBX [ 29 ] , where an unauthenticated SQL injection leverages an intended task scheduler gadget to achieve RCE.
Vuln. → Vuln.
Vuln. → Gadget
Gadget → Vuln.
Domain
Count (%)
Domain
Count (%)
Domain
Count (%)
Credential
190 (45.0)
File System (App. Configuration)
29 (59.2)
File System (Logs)
4 (57.1)
File System
83 (19.7)
Task Scheduler
8 (16.3)
File System (Images)
1 (14.3)
Network Reachability
62 (14.7)
App. Package
7 (14.3)
File System (Scripts)
1 (14.3)
Runtime Memory
60 (14.2)
Database/Runtime Memory
3 (6.1)
Credential
1 (14.3)
Database
27 (6.4)
Credential
2 (4.1)
TABLE IV : RQ3: Security domains connecting adjacent components.
Fig. 3 : Workflow of ChainAgent . Goal-guided search iteratively derives vulnerability- and gadget-search tasks, discovers components, and updates the ExpGraph using empirical chaining knowledge.
Query
Object / capability
Recommended search
P→V
Credential: obtain credentials
SQL injection or information disclosure; inspect credential stores and related read paths.
P→G
File system: create a file with controlled content
Logging routines; inspect writes of request-controlled content.
C→G
Configuration: modify a setting
Configuration loaders; follow reads and uses of the modified setting.
TABLE V : Examples of object-centered chaining knowledge. V denotes a vulnerability and G a functional gadget.
Fig. 4 : Discovery workflows of FindVulnAgent (left) and FindGadgetAgent (right). Chaining knowledge guides sink or object-access retrieval. Candidates are grouped by application feature and dispatched to sub-agent pools for focused source-code inspection.
Fig. 5 : Goal-reaching nodes vs. conditional goal-reaching edges across tool configurations. Points toward the top-right represent superior exploit-graph discovery.
Fig. 6 : In-depth comparison of ChainAgent across three LLM backends: (a) overlap of discovered goal-reaching nodes, (b) breakdown of goal-reaching nodes into GRE endpoints and non-endpoints, and (c) edge eligibility based on whether both, one, or neither endpoint is discovered.
Fig. 7 : Co-occurrence heatmap of the top-15 most frequent CWEs in the collected exploit chains.
Application
#Stars
Vulnerabilities
Exploit Chains
No.
ID
Type
Status
Ecommerce CodeIgniter Bootstrap
1,437
#1
V1
Code injection
CVE-ID Assigned
V2→Glogging→V3→RCE
#2
V2
SQLi
#3
V3
File inclusion
GEOFlow
4,038
#4
V1
XSS
CVE-ID Assigned
V1→V2→filedeletionV1→V3→RCEV1→V4→SSRF
#5
V2
File deletion
TABLE VIII : RQ6: vulnerabilities and exploit chains in real-world PHP applications.
The software supply chain has become an increasingly exposed attack surface because of its reliance on intricate yet fragile dependencies. Existing defenses such as GitHub Dependabot often raise many false alerts because their coarse-grained matching cannot determine whether a vulnerable dependency is actually exploitable. Security analysts typically spend substantial time assessing vulnerability exploitability case by case. Recent LLM agents have emerged as promising candidates for this task given their advanced capabilities in coding and cybersecurity, yet no existing benchmark evaluates them on it. Prior benchmarks target zero-day settings, where agents detect and exploit previously unknown vulnerabilities. In contrast, software supply chain security focuses on how known vulnerabilities in upstream dependencies affect downstream projects. This requires agents to reason across repositories and determine whether an upstream vulnerability is exploitable in the downstream project. To address this gap, we introduce VEX-Bench, the first benchmark for evaluating LLM agents' ability to assess the exploitability of software supply chain vulnerabilities. It contains 75 real-world cases mined from GitHub and labeled by security experts, covering Python, Java, and Go. We evaluate nine models across three agent harnesses. While GPT-5.5 and Claude Opus 4.6 reach approximately 80% F1 on binary vulnerability-status classification, only GPT-5.5 surpasses 70% macro-F1 on fine-grained justification classification. This gap highlights the challenge of moving beyond binary exploitability assessment to identifying fine-grained exploitability reasons. Code and data: https://github.com/steven1518/vex-bench
Jiahao Shi, Edward Tsien, Yifeng Di +10
Department of Computer Science, Purdue University · Red Hat
The advent of agentic vulnerability detection is already becoming a watershed moment for software security. Audits conducted entirely by autonomous LLM agents are uncovering critical vulnerabilities in fundamental software underpinning digital society. Many of these vulnerabilities remained masked for years, surfacing only now with AI agents. Yet the reasoning behind these discoveries remains alarmingly opaque and unvalidated. What assumptions did the agent make about a function's inputs when it deemed that function to be secure? Failures in reasoning and incorrect assumptions can lead to missed vulnerabilities and reduce trust in agentic analysis. We propose a security-specification-first paradigm that (1) exposes the agent's tacit assumptions explicitly as security specifications and (2) continuously refines those specifications via runtime falsification. We realize our approach in Code-Augur, a novel harness for agentic vulnerability detection. Given a codebase, Code-Augur analyzes each component of the system for vulnerable code. When it deems a component to be secure, it commits the local invariants behind that judgment as in-source assertions. In parallel, Code-Augur leverages a guided fuzzer to attempt to falsify those assumptions. When the fuzzer triggers an assertion, this either reveals a genuine vulnerability or a flawed specification to refine. In both cases, this process grounds the agent's understanding, aligning its view of code intent with how the code actually behaves. On real-world subjects, Code-Augur effectively leverages security specifications to detect more vulnerabilities than other state-of-the-art agents. Additionally, Code-Augur found 22 new vulnerabilities in key open-source projects. Compared to curated specialized models like Claude Mythos, Code-Augur offers effective agentic vulnerability detection built on widely available LLMs like Sonnet and DeepSeek.
LLM agents are increasingly used to automate vulnerability detection, but reliable detection is challenging because agents must distinguish subtle, security-relevant fixes from benign code variation. While underlying LLM capability has improved significantly, the accuracy of the agent still depends heavily on the harness: the code that defines the scaffolding around the LLM. Harnesses are typically fixed, and largely hand-written, limiting adaptation to evaluator feedback. Additionally, when harnesses are static, improvements on one dataset or model may not transfer to others. To address these challenges, we introduce MetaVul, a self-improving framework for harness discovery in vulnerability detection. Starting from a seed structured reasoning scaffold, MetaVul uses a workflow-based optimization loop to iteratively refine the harness using feedback from paired vulnerable and patched functions, while preserving the structured reasoning and verdict format. At each iteration, it searches over the history of prior harnesses, with access to their trajectories, logs, and metrics, and it returns a set of Pareto-optimal harnesses. We apply MetaVul to discover agent harnesses for various architectures. A validation set (202 pairs) is used for optimization, while an unseen dataset (430 pairs) is kept as the held-out set. We test whether harnesses learned from one model transfer to others not seen during optimization. Results on both frontier and small LLMs show that the optimized harnesses improve pairwise vulnerability detection up to 23.3 percentage points on the validation set and up to 25.8 points on the held-out set with a Pareto-frontier harness. Harnesses learned with one model also transfer to others. We show that harnesses optimized with one model transfer to another, improving held-out pairwise accuracy by 14.7 points without further optimization.
Ira Ceka, Arnav Garg, Ryan Lutz +4
Columbia University · The Citadel · Monash University +2