Manuscript Offprint

arXiv:2610.03014

Beyond Predefined Sinks: Security-Aware Dependency Analysis for LLM Agents

Hang Cui

HANG CUI

Large language model (LLM)-based agents increasingly connect model-generated decisions to security-sensitive software capabilities, including command execution, filesystem access, network communication, browser control, and external tools. Existing analyses often use predefined sensitive operations to anchor their analysis, but operation identity alone is insufficient to determine the security implications of an agent behavior.

We present AGENTSECGRAPH, a security-aware static analysis framework that constructs a candidate-centered Security-Aware Agent Dependency Graph (SECURITY-ADG) for each security-sensitive operation. The representation augments operation identity with agent relevance, source and dependency evidence, trust-boundary context, guard evidence, and external-effect semantics.

We further introduce AGENTSECBENCH, a reproducible corpus of 67 real-world LLM-agent repositories spanning 11 agent ecosystems and 37,542 source files. Applying the current analyzer to all frozen repositories yields 23,866 static security-sensitive operation candidates across 65 repositories, for which AGENTSECGRAPH emits 23,866 candidate-centered SECURITY-ADG artifacts without reported construction failures. Corpus-wide analysis recovers source-to-operation dependency evidence for 9,821 candidates (41.15%) and potential guard evidence for 3,075 (12.88%). The complete analysis finishes in 50.8 minutes.

Using a separate reproduction-backed evaluation layer, we establish a conservative reference set of 22 security-sensitive behaviors across 13 repositories: one confirmed vulnerability, one pending disclosure candidate, and 20 guarded behaviors that do not meet the vulnerability criteria. In a held-out representation study, SECURITY-ADG preserves 91.1% of the reference context and all five observed guards, compared with 20.0% for a sink-only view and 40.0% for a simplified ADG.

These results show that security-aware dependency and contextual evidence enable distinctions that cannot be recovered from sensitive-operation identity alone.

CCS Concepts: • Security and privacy → Software security engineering; • Software and its engineering → Automated static analysis.

Additional Key Words and Phrases: LLM agents, software security, program analysis, static analysis

Preprint. This version has not been peer reviewed.

1 Introduction

Large language model (LLM)-based agents are rapidly evolving from text-generating assistants into software systems capable of planning, invoking tools, maintaining state, and interacting with external environments. Early paradigms such as ReAct [36] and Toolformer [27] demonstrated how language models can interleave reasoning with external actions. Modern frameworks, including LangChain [5], LangGraph [18], AutoGen [33], and CrewAI [7], provide reusable abstractions for tool invocation, memory, workflow orchestration, and multi-agent coordination. The Model Context Protocol (MCP) [2] extends this ecosystem by standardizing access to external tools and resources.

This transition fundamentally changes the security boundary of LLM applications. In a conventional chatbot, an unsafe model output may remain textual; in an agent system, the same output can influence command execution, filesystem operations, browser actions, database access, or remote services. Agent behavior may additionally depend on user instructions, retrieved documents, memory contents, model-generated plans, tool outputs, and messages from other agents. Untrusted information can therefore cross multiple software and trust boundaries before affecting an externally visible operation. Prior work has demonstrated these risks through indirect prompt

Author's Contact Information: Hang Cui, cuihang26@mails.ucas.ac.cn.

Hang Cui

Figure

Fig. 1. Motivation: operation identity alone does not determine security semantics. All three agent tools contain the same command-execution operation. Cases A and C preserve a dependency from the agent-facing input, whereas Case B removes that dependency through a constant overwrite. Case C additionally contains a candidate allowlist guard. Security-aware dependency analysis distinguishes these cases using dependency and security-context evidence.

injection [13, 37], realistic agent attack environments [9], unsafe tool interactions [26], agent security benchmarks [38], resource abuse [25], and MCP-specific attack surfaces [16, 40].

Static program analysis provides a natural foundation for reasoning about these behaviors. Source–sink and taint analyses determine whether values from selected sources may reach security-sensitive operations. Systems such as YASA [30] demonstrate scalable taint analysis across multiple languages, while recent work has adapted program analysis to LLM-integrated applications. Agent-Fuzz [22] dynamically searches for prompts that trigger taint-style vulnerabilities, TaintP2X [14] statically traces LLM-generated values toward sensitive operations, and Agent Audit [39] combines agent-aware data-flow reasoning with credential, configuration, and privilege analysis.

However, operation identity alone is insufficient for security interpretation. The same security-sensitive operation may be directly influenced by an agent-facing input, disconnected from that input by program transformations, or constrained by validation and authorization logic. Conversely, security-relevant capabilities may be exposed through framework-specific abstractions rather than obvious low-level API calls. A useful analysis must therefore recover not only which operation is present, but also how agent-relevant information reaches it and the security context in which it executes.

Figure 1 illustrates this distinction.

Agent frameworks further complicate this problem because relevant relationships may be hidden behind decorators, tool wrappers, workflow nodes, dynamically registered functions, plugins, and remote MCP tools. AgentFlow [29], for example, recovers framework-induced Agent Dependency Graphs (ADGs) over prompts, models, capabilities, memory, and control policies. Recovering these structural dependencies is valuable, but security interpretation also requires evidence about source provenance, trust boundaries, guards, privilege context, and resulting external effects.

This motivates the central research question of this work:

How can static analysis augment security-sensitive operations with agent-specific dependency and security-context evidence to analyze security-critical behaviors in real-world LLM-agent programs?

We present AGENTSECGRAPH, a security-aware static analysis framework for LLM-agent programs. Rather than treating a matched sensitive operation as a vulnerability verdict, AGENTSECGRAPH uses it as an analysis anchor and constructs a candidate-centered SECURITY-ADG. The representation augments operation identity with agent relevance, source provenance, local dependency evidence, trust-boundary context, candidate guards, statically available privilege information, and external-effect semantics. This design separates three analytical layers:

Operation→Dependency→SecurityContext.(1)Operation\rightarrow Dependency\rightarrow Security Context. \tag{1}

This separation allows AGENTSECGRAPH to distinguish behaviors that appear identical under an operation-only view while making the limitations of the underlying static evidence explicit.

We further introduce AGENTSECBENCH, a reproducible corpus of 67 real-world LLM-agent repositories spanning 11 agent ecosystems, 37,542 source files, and 291.2 MB of source code. Applying the current candidate extractor to the full corpus identifies 23,866 static security-sensitive operation candidates across 65 repositories and 7,214 candidate-bearing source files. AGENTSECGRAPH emits one candidate-centered SECURITY-ADG artifact for every candidate without reported construction failures. Across this population, AGENTSECGRAPH recovers source-to-operation dependency evidence for 9,821 candidates (41.15%), explicit framework-specific evidence for 749 (3.14%), and potential guard evidence for 3,075 (12.88%). End-to-end analysis completes in 50.8 minutes.

Separately, we retain a frozen pilot cohort and construct reproduction-backed evidence for 22 security-sensitive behaviors across 13 repositories. The resulting reference set contains one confirmed vulnerability, one pending disclosure candidate, and 20 guarded non-vulnerabilities under the evaluated conditions; neither model-generated judgments nor single-reviewer labels are used as ground truth. Across nine evidence-backed held-out cases, SECURITY-ADG preserves 91.1% of the reference context and all five observed guards, compared with 20.0% context completeness and 0/5 guard visibility for a sink-only view, and 40.0% and 0/5, respectively, for a simplified ADG view.

Our contributions are summarized as follows:

• Security-analysis formulation. We formulate LLM-agent security analysis by distinguishing among sensitive-operation identity, security-critical behavior evidence, and vulnerability claims, avoiding the assumption that every matched sensitive operation constitutes a vulnerability.

• Security-aware dependency analysis. We design AGENTSECGRAPH and its candidate-centered SECURITY-ADG representation to integrate agent relevance, source provenance, local dependency evidence, trust-boundary context, candidate guards, and external-effect semantics.

• Benchmark and corpus-wide analysis. We construct AGENTSECBENCH from 67 frozen real-world LLM-agent repositories spanning 11 ecosystems and 37,542 source files. A full-corpus run of the current analyzer emits 23,866 candidate-centered SECURITY-ADG artifacts across 65 repositories, enabling corpus-wide characterization and scalability analysis.

• Reproduction-backed empirical evidence. We establish a reproduction-confirmed reference set of 22 security-sensitive behaviors across 13 repositories and quantify the security-context information preserved by sink-only, simplified ADG, and full SECURITY-ADG representations.

Hang Cui

References (13)