ChainAgent: Automated Discovery of Chainable Vulnerabilities in PHP Web ApplicationsChainAgent: Automated Chainable Vulnerability Discovery in PHP Web Applications
The authors propose ChainAgent, a goal-oriented LLM agent framework that jointly discovers vulnerabilities and functional components from PHP source code and builds exploit chains; the authors state that on 15 applications its number of recovered conditional goal-reaching edges is at most 4.4 times that of Codex.
Given the source code of a target PHP application and a target security goal (RQ4/RQ5 set to RCE), ChainAgent discovers vulnerabilities and functional gadgets and composes exploit chains without a predefined vulnerability list; the paper does not explicitly define the attacker's knowledge level (white-box/black-box), and the actual input is the application source code.
- High-impact attacks against PHP web applications are often composed of multiple vulnerabilities with limited capabilities chained together with normal program behaviors; existing vulnerability mining analyzes individual flaws in isolation, and automated attack planning assumes attack components are known, making it difficult to discover components whose security significance only emerges within a chain.
- The authors first conduct an empirical study of 386 real Web exploit chains, then propose ChainAgent: it represents vulnerabilities and functional gadgets with a precondition–capability abstraction, searches backward from unsatisfied preconditions for capability producers and forward from acquired capabilities for gadgets in a goal-oriented manner, and uses object-centric chain knowledge to guide source code inspection, incrementally building an Exploit Graph and then synthesizing exploit chains.
- Compared with Codex on 15 PHP applications and three shared LLM backends: ChainAgent achieves goal-reaching node recall of 42.02%–44.63% (Codex: 13.03%–37.46%), and under DeepSeek-v4-Flash recovers 185 correct conditional goal-reaching edges (Codex: 42); it also finds 20 vulnerabilities and 13 exploit chains in 30 real applications, 9 of which reach RCE.
- The authors note: no dynamic validation is performed within the discovery pipeline, and whether a complete chain is executable is not confirmed within the pipeline; ground truth comes from the union of vulnerabilities from each tool and documentation, and chains missed by all tools are not in the recall denominator. Evaluation is limited to PHP applications, with four LLM backends, and the only comparison tool is Codex.
- Evaluated models
- DeepSeek-v4-Flash-0731Qwen-3.8-FlashGLM-5.3-Flash
- Benchmarks
- 15 个来自 ZIPPER 的 PHP Web 应用基准30 个 GitHub 星数超过 1,000 的真实 PHP Web 应用386 条真实 Web 利用链语料(Metasploit Framework、nuclei-templates、Awesome-POC)
- Metrics
- TP/FP/Precision(漏洞与 gadget)Goal Reach Node RecallEdge PrecisionConditional Goal-Reaching Edge RecallToken 消耗与执行时间
Researchers propose ChainAgent, a framework in which an LLM agent jointly discovers exploit chain components and their capability dependencies in PHP web application source code. Based on an empirical study of 386 real-world web exploit chains, the method represents vulnerabilities and functional gadgets (expected program behaviors that an attacker can repurpose) with preconditions and capabilities on security-relevant objects, and guides source code review with an evolving exploit graph, searching backward from unsatisfied preconditions for capability producers and forward from discovered capabilities for functional gadgets. In evaluation on 15 PHP applications under 3 shared LLM backends, ChainAgent achieves 42.02%–44.63% recall on target-reachable components and recovers up to 4.4 times as many correct target-reachable dependency edges as the general coding agent Codex. A supplementary evaluation on 30 real-world PHP applications found 20 vulnerabilities and 13 exploit chains, 9 of which enable remote code execution (RCE).
Paper analysis
What problem does this paper attempt to solve?
How to make source code analysis, guided by exploit chain dependencies, jointly discover unknown vulnerabilities and reusable normal program behaviors and compose them into exploit chains.
Core question: Can dependencies within exploit chains be used to guide source code analysis, jointly discovering previously unknown vulnerabilities and normal program behaviors that can be reused by attacks (functional gadgets) while building chains?
- Problem setting: PHP drives more than 69.9% of websites using known server-side technologies (Introduction); a single vulnerability often provides only limited capability (read one database record, change one configuration item), but when chained with other vulnerabilities or normal program behaviors it can achieve high-impact consequences such as RCE; the authors use the Juniper J-Web chain (Figure 1) to illustrate two vulnerabilities combined with PHP's normal startup behavior to achieve RCE.
- Shortcomings of existing methods (according to the paper): vulnerability discovery techniques analyze defects in isolation and do not use their potential role in chains; automated attack planning assumes attack components are known and does not discover new components from source code; according to the paper, this separation makes components that "only reveal their security significance within a chain" difficult to discover.
- Core observations: the authors' empirical study of 386 real Web exploit chains yields three points—chain goals are highly concentrated (94.8% are unauthorized code/command execution); chains contain both vulnerabilities and functional gadgets (12.7% of chains contain gadgets); adjacent components are connected through capability production/consumption on security-relevant objects, rather than determined by vulnerability type (Findings 1–3).
- Proposed approach: ChainAgent, a goal-oriented LLM agent framework that represents components with a precondition–capability abstraction, uses an Exploit Graph to guide source code inspection, searches backward from unsatisfied preconditions for capability producers, and searches forward from discovered capabilities for gadgets.
- Threat model:
- Attacker goal: achieve a specified security goal; set to RCE in the RQ4/RQ5 evaluation, and RQ6 uses all categories enumerated by the CWE technical impact enumeration.
- Knowledge and capability: the analyst has the source code of the target PHP application; the paper does not define the threat model using terms such as white-box/black-box.
- Victim system: PHP Web applications (15 benchmarks, 30 real applications).
- Success determination: discovered components and edges are checked against a ground-truth graph constructed by PoC synthesis plus manual verification (see Question 4).
What related research exists?
Related work falls into three groups: automated attack planning and penetration testing, single-vulnerability exploit generation, and PHP vulnerability discovery; the authors position this paper as filling the gap between component discovery and attack planning.
Automated Attack Planning and Penetration Testing
- PentestGPT [21], PentestAgent [22], PENTESTLLMAGENT [23], Penexpert [38], Incalmo [39]—use LLM agents to automate penetration testing and multi-host red teaming, managing long tasks through modular reasoning, multi-agent collaboration, or task dependency graphs.
- ChainReactor [19], ALFA-Chains [20], and earlier planning work [40]—use explicit action models (such as PDDL) to combine known vulnerabilities and system operations into attack paths, targeting single-host privilege escalation and cross-host lateral movement, respectively.
- The paper points out that these planning frameworks run afterward on a closed world of known vulnerabilities and do not discover new flaws; ChainAgent integrates compositional exploit reasoning into source-level vulnerability discovery.
Single-Vulnerability Exploit Generation
- ChainSaw [41], NAVEX [31] (PHP), FAST [42], Explode.js [43], the NodeMedic series [44][45] (Node.js)—generate inputs or call sequences that reach dangerous sinks for taint-style injection vulnerabilities.
- FUGIO [46], PFortifier [47] (PHP deserialization), ReDoSHunter [48], RENGAR [49], EvilStrGen [50], PufferDoS [51] (ReDoS), PoCGen [52] (npm PoC generation).
- The paper points out that these works focus on triggering a single vulnerability; ChainAgent uses a precondition–capability model to jointly discover vulnerabilities and gadgets and build cross-component dependencies.
PHP Vulnerability Discovery
- The Introduction lists static analysis, fuzzing, and symbolic execution methods such as ZIPPER [2], TChecker [3], Xssky [4], Artemis [5], Cobra [8], FUSE [11], and Atropos [12], which identify single classes of vulnerabilities such as SQL injection, XSS, and file upload; the paper points out that they evaluate vulnerabilities in isolation and may overlook chained attack paths.
Baseline and Benchmark: the comparison baseline is Codex (v0.147.0, a general-purpose coding agent); the evaluation benchmark is 15 PHP applications taken from ZIPPER [2] (3.9K–273.8K lines of code), plus a discovery evaluation on 30 real PHP applications with more than 1,000 GitHub stars.
Authors' positioning: this paper is the first framework to use exploit chain dependencies as guidance for source code analysis, jointly discover unknown vulnerabilities and gadgets, and build chains—this positioning is the authors' own statement; the paper does not use the word "first," but instead says this separation "leaves an important opportunity unexplored."
How does the paper address this problem?
ChainAgent drives goal-oriented iterative search with a precondition–capability abstraction and object-centric chain knowledge, building an Exploit Graph while discovering components, and finally synthesizes exploit chains.
Overall approach: given PHP application source code and a target security goal, ChainAgent maintains a task queue derived from unsatisfied preconditions and discovered capabilities, iteratively discovers vulnerabilities and functional gadgets, updates the Exploit Graph (ExpGraph), and after the tasks are exhausted synthesizes exploit chains reaching the goal from the graph.
Problem setting and Exploit Graph
- ExpGraph is a directed graph G = (N, L): nodes carry a type (Vuln/Gadget/Goal), a precondition set P(n) and a capability set C(n); the P(g) of the virtual goal node g specifies the target capability.
- Preconditions and capabilities are represented by predicate structures Domain.Action(a1, …, ak), where the domain is a security-relevant object, all fields are in natural language, and there is no fixed predicate vocabulary.
- An edge exists if and only if the match set is non-empty:
M(\ell) = \{(c, p) \mid c \in C(u),\ p \in P(v),\ c \models p\}, i.e., some capability of u semantically satisfies some precondition of v; the match set is used for chain synthesis.
Object-centric chain knowledge
- Following Finding 3, adjacent component pairs from the empirical study are grouped by shared security object and transferred capability; each knowledge entry records hints such as search direction, object domain, required/produced capabilities, candidate component families and sink families (Table 5 gives examples).
- Precondition queries point to capability producers (vulnerabilities or gadgets), and capability queries point to gadget consumers; concrete object bindings and constraints are checked during attribute inference and graph update, rather than inferred from component types.
Goal-guided discovery loop (Algorithm 1)
- Tasks are of two kinds: FindVuln(p, nt) finds vulnerabilities whose capabilities satisfy precondition p; FindGadget has a P mode (find gadgets satisfying p) and a C mode (find gadgets that consume/amplify capability c). Tasks are deduplicated by type, normalized attributes, anchor node and mode, and each key is processed only once.
- FindVulnAgent: identifies the object and required capability from p, consults knowledge to obtain vulnerability classes and sink families, retrieves candidate sinks and groups them by application functionality, and dispatches them to a pool of sub-agents for parallel analysis; sub-agents trace input flows and check path guards (authentication, authorization, branch conditions) and sanitization logic.
- FindGadgetAgent: P mode retrieves normal operations that may produce the required capability (e.g., log writing establishing a file inclusion precondition); C mode starts from the source node's capability, retrieves program points that read/use that object, and traces forward to sensitive operations.
Attribute inference and graph update
- The LLM examines candidate component source code and call context, traces attacker-controllable input through assignments, calls and persistent state, checks sanitization and validation along the path, and reconstructs sink parameters as symbolic expressions.
- On this basis it infers P(n) and C(n): required permissions and object access become preconditions, and controllable object operations become capabilities; it also distinguishes vulnerabilities from gadgets based on whether the program behavior is intended functionality.
- New nodes are semantically matched pairwise against all existing nodes in the graph; compatible pairs get an edge and a recorded match set; each precondition derives vulnerability and gadget search tasks, and each capability derives a C-mode gadget task.
Exploit chain synthesis
- Expansion proceeds backward from the goal node, using edge match sets to find predecessors that establish each precondition, combining multiple sources when necessary and checking object binding and path constraint compatibility.
- Predecessors with equivalent capabilities are grouped and a representative is chosen: alternatives with no stronger entry assumptions and the same capability are omitted; if assumptions are incomparable, all are kept, and when equivalent, the one with fewer components is preferred.
- The components on the chain and the capability–precondition pair for each step are output in dependency order; preconditions not established within the chain are reported as explicit entry assumptions.
What experiments did the paper conduct?
Compared with Codex on 15 PHP applications and three shared backends, ChainAgent achieves goal-reaching node recall of 42.02%–44.63% and recovers at most 185 conditional goal-reaching edges (Codex: 42); it also finds 20 vulnerabilities and 13 chains in 30 real applications.
Experimental Setup
- Configurations under test: ChainAgent and Codex (v0.147.0) each run on three shared backends, DeepSeek-v4-Flash-0731, Qwen-3.8-Flash, and GLM-5.3-Flash, plus Codex's officially recommended model GPT-5.4; all models are set to maximum reasoning effort.
- Benchmark: 15 real PHP applications taken from ZIPPER (3.9K–273.8K lines of code); RQ6 additionally selects the latest versions of 30 PHP applications with more than 1,000 GitHub stars.
- Security goals: RQ4/RQ5 set to RCE; RQ6 uses all categories enumerated by the CWE technical impact enumeration.
- Metrics: TP, FP, Precision for vulnerabilities/gadgets; Goal Reach Node Recall (recall of components reaching the goal node); Edge Precision; Conditional Goal-Reaching Edge (TP counted only on ground-truth edges whose both endpoints are correctly discovered; recall = TP/|Econd|).
- Ground-truth construction: components and edges from all ChainAgent and Codex runs plus documented vulnerabilities are aggregated; Codex (driven by DeepSeek-v4-Flash-0731) generates PoCs, which the authors manually execute and verify; candidates that Codex could not exploit are independently audited in source code by two authors; an edge requires confirming that the predecessor capability specifically satisfies the successor precondition.
- Empirical study screening: 7,251 candidate exploit artifacts were preliminarily analyzed by DeepSeek-V4-Pro and manually checked, retaining 386 chains (Table 1).
Main Results
According to Table 6 (RQ4, 15 applications, goal RCE):
Swipe horizontally to read the table
Tool LLM Vulnerability TP/FP Gadget TP/FP Goal Reach Rec. Cond. Edge TP Cond. Edge Rec. ChainAgent DeepSeek-v4-Flash 136/9 32/1 42.02% 185 82.96% ChainAgent Qwen-3.8-Flash 132/23 46/6 43.00% 107 66.05% ChainAgent GLM-5.3-Flash 124/47 34/16 44.63% 90 59.60% Codex DeepSeek-v4-Flash 58/9 20/11 25.08% 42 60.00% Codex Qwen-3.8-Flash 121/50 24/26 37.46% 44 40.37% Codex GLM-5.3-Flash 46/11 10/3 17.92% 23 60.53% Codex GPT-5.4 33/5 7/6 13.03% 8 44.44% - The authors state that ChainAgent recovers more goal-reaching nodes and valid edges under the three shared backends, with 2.4–4.4 times the number of conditional goal-reaching edges of Codex; Figure 5 shows that ChainAgent configurations lie in the upper-right region of the plot, while Codex configurations have fewer than 45 edges.
- Exceptions: under GLM-5.3-Flash, Codex's vulnerability and gadget precision (80.70%, 76.92%) is higher than ChainAgent's (72.51%, 68.00%); under DeepSeek, Codex's edge precision of 95.45% is higher than ChainAgent's 86.40% (Table 6). The authors state that the precision advantage depends on the backend.
- The authors state that even with GPT-5.4, Codex's Goal Reach recall is only 13.03% and conditional edges only 8, and argue that general-purpose coding agents struggle to autonomously reason about exploit dependencies.
Backend Impact and Cost
- Node overlap (Figure 6a): the three backends jointly discover only 52 goal-reaching nodes, with 38 (DeepSeek), 38 (Qwen), and 46 (GLM) unique to each, for a union of 234; the authors state that different LLMs explore markedly different attack paths.
- Structural cohesion (Figure 6b/c): of DeepSeek's 129 nodes, 124 (96.1%) are endpoints of valid edges and 5 are dangling; Qwen and GLM have 15 and 21 dangling nodes, respectively; the number of ground-truth edges with both endpoints discovered is 223 (DeepSeek), 162 (Qwen), and 151 (GLM).
- Cost (Table 7): ChainAgent under DeepSeek-v4-Flash totals 446.71M tokens and 7h28m44s (15 applications); under Qwen, 1416.96M tokens and 35h52m44s; Codex across backends uses 109.90M–217.86M tokens and about 3–9 hours. The authors state that ChainAgent is more expensive but "less than 30 minutes per application on average" (DeepSeek configuration).
Ablation Study (RQ5, DeepSeek-v4-Flash, Table 6)
- ChainAgent-PM (removing precondition–capability modeling): Goal Reach recall drops from 42.02% to 25.73%, conditional edge recall drops from 82.96% to 22.22% (only 12 edges recovered), and edge precision drops from 86.40% to 58.06%.
- ChainAgent-G (removing functional gadgets): gadget TP is 0, goal-reaching nodes are 99, and conditional edges drop from 185 to 68.
- ChainAgent-VK / -GK (removing vulnerability/gadget search knowledge, respectively): vulnerability TP drops from 136 to 109 and FP rises from 9 to 20; gadgets drop from 32 to 17.
- ChainAgent-TS (discover first, then plan): Goal Reach recall drops to 28.01% and conditional edge recall drops to 21.31%; joint discovery identifies 58 more vulnerabilities with a path to the goal than a fixed vulnerability set (108 vs. 79, with 50 in common).
Real-World Application Evaluation (RQ6, Table 8)
- Discovery scale: 7 of 30 applications yield 20 vulnerabilities in total, forming 13 exploit chains, 9 of which reach RCE, and 9 chains contain functional gadgets; 9 vulnerabilities have obtained CVE-IDs, and the rest are in Fixed status.
- Verification and disclosure: the authors state that all vulnerabilities and chains were dynamically verified and reported to developers; three cases (OWA configuration override→log gadget→RCE; TeamPass cross-user credential theft; Ecommerce CodeIgniter Bootstrap SQLi→log→include→RCE) illustrate the bridging role of gadgets in chains, with simplified code given in Appendix C.
- Negative results: no vulnerabilities were found in 23 applications; the authors do not explain why.
What are some points that can be further explored?
The authors note two limitations—the discovery pipeline performs no dynamic validation, and ground truth depends on the union of tools—and propose future work on graph-guided dynamic validation; evaluation covers PHP applications and four LLM backends.
Limitations and Future Directions Noted by the Authors
- No dynamic verification within the pipeline (Section 5 Limitations): ChainAgent does not generate and execute exploits within the discovery process, and "the pipeline itself does not confirm whether a complete chain can be executed successfully"; the authors explored automatic deployment and verification in Docker using a GPT-5.4-based agent, which took more than an hour on average, so verification is placed outside the discovery loop.
- Ground-truth coverage (Section 5 Threats to Validity): the ground truth comes from the union of all evaluated tools and documented vulnerabilities; chains missed by all tools are not included, and recall is measured relative to this verified set rather than all exploitable chains in the applications.
- Future direction (Section 5 Future Work): the authors plan to study graph-guided dynamic verification—first verifying nodes shared by multiple goal paths or connecting large subgraphs; if a capability is disproven, delete edges that depend on it and skip regions no longer on a path from entry to goal; a single failed exploit is not grounds for pruning.
- Future direction (Section 5 Future Work): the authors also plan to reuse environment snapshots and verification results for shared chain prefixes, and to return concise evidence to the discovery process from an independent verification context.
Scope of Experimental Coverage
- The backends under test are three shared models, DeepSeek-v4-Flash-0731, Qwen-3.8-Flash, and GLM-5.3-Flash, plus Codex with GPT-5.4, for four LLM configurations in total (Section 4.1).
- The only comparison tool is Codex (v0.147.0); the benchmark is 15 PHP applications, and the RQ4/RQ5 security goal is set only to RCE (Section 4.1).
- The real-world evaluation covers 30 PHP applications (GitHub stars >1,000), of which 7 have findings (Section 4.4, Table 8).
- Ablations are conducted under the single DeepSeek-v4-Flash backend, with 5 variants in total (Section 4.3).
- The paper does not report per-application results for each benchmark application, the number of repeated runs, or consistency data for the two authors' audits in ground-truth construction.
Summarize the main content of the paper
ChainAgent uses exploit chain dependencies to guide PHP source code analysis, jointly discovers vulnerabilities and functional gadgets and builds exploit chains, achieving more chained discoveries than Codex on both benchmarks and real applications.
An attack surface research paper on automated discovery of exploit chains in PHP Web applications, proposing the goal-oriented LLM agent framework ChainAgent.
- Problem addressed: high-impact attacks often chain capability-limited vulnerabilities with normal program behaviors; existing vulnerability discovery analyzes in isolation and attack planning assumes components are known, leaving the opportunity of "dependency-guided discovery" between the two unexploited.
- Empirical basis: a study of 386 real Web exploit chains finds: 94.8% of chains have unauthorized code/command execution as the final goal (Table 2); 12.7% of chains contain functional gadgets (Table 3); adjacent components are connected through capability production/consumption on security-relevant objects, rather than fixed vulnerability-type pairings (Table 4).
- Method highlights: vulnerabilities and gadgets are uniformly represented with precondition–capability predicates (natural language, no fixed vocabulary); search backward from unsatisfied preconditions for capability producers and forward from discovered capabilities for gadget consumers; object-centric chain knowledge narrows the search scope; component edges enter the Exploit Graph as they are discovered, and finally chains are synthesized by backward traversal and entry assumptions are reported.
- Main results: on 15 PHP applications, ChainAgent achieves goal-reaching node recall of 42.02%–44.63% (Codex 13.03%–37.46%); under DeepSeek-v4-Flash, conditional goal-reaching edge recall is 82.96% with 185 edges recovered, 4.4 times Codex (42 edges, 60.00%) (Table 6); ablations show that removing precondition modeling drops conditional edge recall to 22.22%, and discover-first-then-plan drops it to 21.31%.
- Real-world findings: 7 of 30 applications yield 20 vulnerabilities and 13 exploit chains in total, 9 reach RCE, and 9 vulnerabilities obtain CVE-IDs (Table 8).
- Authors' conclusions and implications: the authors believe capability-dependency-guided source code inspection can help agents discover chain-relevant components that "discover first, then plan" would miss; limitations are that the discovery process does not perform dynamic verification and the ground truth depends on the union of tools, and the authors plan to introduce graph-guided dynamic verification.