ChainAgent: Automated Chainable Vulnerability Discovery in PHP Web Applications

Xinyi Wang, Yeting Li, Shizhe Cui, Jiaming Guo, Qin Mai, Yecheng Sun, Hengyu Yang, Yujie Sun, Huina Chao, Yang Xiao, Feng Li, Wei HuoarXiv 2026 · arXiv

TL;DR

ChainAgent is an LLM-powered framework that discovers complex "exploit chains" in PHP applications by jointly identifying vulnerabilities and benign program behaviors ("functional gadgets") that can be combined to reach high-impact goals. By using a goal-directed search over an evolving exploit graph, it recovers up to 4.4 times more attack-path dependencies than general-purpose coding agents and has already identified 20 new vulnerabilities in popular real-world applications.

What Problem Does This Paper Address?

In web security, a single vulnerability is often just a "low-impact" nuisance on its own—perhaps it only lets an attacker write a file to a temporary directory or read a non-sensitive configuration. However, high-impact attacks (like full server takeovers) rarely rely on a single "silver bullet" bug. Instead, attackers chain multiple limited flaws together with intended program behaviors to amplify their power.

Existing tools generally fall into two camps:

  1. Vulnerability Scanners: These find individual bugs (like SQL injection) in isolation but often miss their "chainable" potential.
  2. Attack Planners: These can figure out how to combine bugs, but they usually assume the bugs are already known and documented.

This leaves a massive gap: How do we discover previously unknown components whose security relevance only becomes clear when they are part of a chain? As shown in the Juniper J-Web exploit (Figure 1), an attack might involve multiple steps that look benign or low-risk until they are composed.

Figure 1: Juniper J-Web exploit chain. Two uses of one upload flaw (CVE-2023-36846 [16]) and environment in- jection (CVE-2023-36845 [17]) compose with PHP’s normal startup behavior to achieve RCE. P and C abbreviate server- generated filenames.

Methods

The authors introduce ChainAgent, a goal-directed agent framework that treats exploit discovery as a joint search-and-composition problem.

The Precondition-Capability Model

ChainAgent models every code component (whether it's a bug or a legitimate feature) using two properties:

  • Preconditions: What state or access does an attacker need to trigger this? (e.g., "Must be an authenticated admin").
  • Capabilities: What can an attacker do once they trigger it? (e.g., "Can write to the cron_jobs table").

Goal-Directed Exploration

Instead of auditing code from top to bottom, ChainAgent starts with a high-impact goal (like Remote Code Execution) and works backward.

  1. Backward Search: It looks for "producers" that can satisfy the unmet preconditions of the current target.
  2. Forward Search: It looks for "consumers" (functional gadgets) that can take a discovered capability and amplify it.
  3. Exploit Graph (ExpGraph): As it finds components, it builds a graph where nodes are vulnerabilities/gadgets and edges represent capability-to-precondition matches.
Figure 3: Workflow of CHAINAGENT. Goal-guided search iteratively derives vulnerability- and gadget-search tasks, discovers components, and updates the ExpGraph using empirical chaining knowledge.

LLM-Powered Reasoning

ChainAgent uses Large Language Models (LLMs) to bridge the gap between low-level code (like a variable assignment) and high-level security semantics (like "this allows an attacker to control the application configuration").

Datasets

The researchers evaluated ChainAgent using three distinct datasets:

  • Empirical Study Corpus: 386 real-world exploit chains distilled from over 7,000 artifacts in repositories like Metasploit and Nuclei.
  • Vulnerability Benchmark: 15 real-world PHP applications (including WordPress and Joomla) used to compare ChainAgent against baseline agents like OpenAI's Codex.
  • Real-World "Wild" Apps: 30 popular PHP projects from GitHub with over 1,000 stars to test the tool's ability to find zero-day vulnerabilities.

Key Insights and Ideas

  • The Power of "Functional Gadgets": One of the most striking findings is that 12.7% of real-world exploit chains include "functional gadgets"—intended, non-vulnerable program behaviors that attackers repurpose. For example, a legitimate task scheduler can be used to execute a malicious command that was previously "parked" in a database by a limited SQL injection (Figure 2).
  • Object-Centered Chaining: Exploit chains aren't usually linked by vulnerability types (e.g., "XSS leads to SQLi"). Instead, they are linked by security-relevant objects like specific files, database tables, or configuration settings.
  • Joint Discovery is Essential: The study proves that finding bugs while planning the attack is far more effective than the traditional "find bugs first, plan later" approach. The context of "I need a way to reach this specific file" helps the agent find subtle bugs it might otherwise ignore.
Figure 2: An exploit chain in FreePBX [29], where an unauthenticated SQL injection leverages an intended task scheduler gadget to achieve RCE.

Key Results

  • Superior Recall: ChainAgent achieved a 42.02%–44.63% recall for goal-reaching components, significantly outperforming general-purpose coding agents.
  • Better Connectivity: It recovered up to 4.4 times more correct dependency edges than Codex, meaning it is much better at understanding how bugs actually fit together.
  • Real-World Impact: In the evaluation of 30 real-world apps, ChainAgent discovered 20 vulnerabilities and 13 exploit chains, 9 of which resulted in full Remote Code Execution (RCE). To date, 9 of these findings have been assigned official CVE identifiers.

Limitations and Future Work

While powerful, ChainAgent has a few notable limitations:

  • Static vs. Dynamic: Currently, ChainAgent performs static analysis via LLMs. It doesn't automatically execute the exploits it finds to verify them in a live environment, which can lead to some "hallucinated" attack paths (though its precision remains high).
  • Cost and Speed: Iterative LLM reasoning is computationally expensive. Running ChainAgent on a large application can take several hours and millions of tokens.
  • Future Directions: The authors plan to integrate "graph-guided dynamic validation," where the agent can spin up a Docker container to test specific links in the exploit graph as it discovers them, pruning invalid paths early.

Summary updated

Abstract

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).
BibTeX
@misc{wang2026chainagent,
  author = {Xinyi Wang and Yeting Li and Shizhe Cui and Jiaming Guo and Qin Mai and Yecheng Sun and Hengyu Yang and Yujie Sun and Huina Chao and Yang Xiao and Feng Li and Wei Huo},
  title = {{ChainAgent: Automated Chainable Vulnerability Discovery in PHP Web Applications}},
  year = {2026},
  eprint = {2611.25412},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.25412},
}
Figure