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.