Manuscript Offprint

arXiv:2610.09935

AgentTracer: Tracing Indirect Prompt Injection Attack through Fine-Grained Intention-Execution Alignment

Zitong Yao, Jiangrong Wu, Yixi Lin, Anrui Huang, Luoyun Zhang, Yuhong Nan

Zitong Yao, Sun Yat-sen University, China

Jiangrong Wu ∗^{*}, The Hong Kong University of Science and Technology, China

Yixi Lin, Sun Yat-sen University, China

Anrui Huang, Sun Yat-sen University, China

Luoyun Zhang, Sun Yat-sen University, China

Yuhong Nan, Sun Yat-sen University, China

Large language model (LLM) agents interact with external resources to complete complex user tasks, exposing them to indirect prompt injection (IPI), where malicious instructions redirect agents toward attacker-intended tasks. Since IPI is difficult to defend against in real-world environments, post-incident tracing is essential for locating the injection source and reconstructing the attack chain. However, existing tracing methods primarily capture explicit control-flow and data-flow dependencies, overlooking the implicit relationships among tool calls driven by the malicious instruction. These tool calls may lack explicit dependencies and be interleaved with legitimate operations, making complete attack-chain reconstruction difficult. In this paper, we present AgentTracer, an intent-aware tracing framework that treats IPI as task intent drift. AgentTracer recovers implicit decision dependencies among tool calls to construct an Intent-Driven Execution Graph that connects dispersed tool calls by task intent. It combines the user request with an operation knowledge base to construct a user intent authorization space and identify intent-drift tool calls. Starting from an anomalous tool call under audit, AgentTracer performs target-based pruning and backward tracing to reconstruct the attack chain and locate the injection source and injection point. To evaluate AgentTracer in the presence of noise from normal tasks, we combine execution logs constructed from successful IPI attacks in AgentDyn and InjecAgent with normal execution logs containing 1,800 user requests and 9,000 background tool calls without IPI. In end-to-end experiments, AgentTracer achieves 94.17% injection-point accuracy and 93.56% path precision. Comparative experiments show that AgentTracer improves injection-point accuracy over existing methods by 18–54%.

CCS Concepts: • Software and its engineering → Software creation and management.

Additional Key Words and Phrases: LLM agents, indirect prompt injection, security tracing, attack-chain reconstruction, intent alignment

1 Introduction

Large language model (LLM) agents have now become one of the mainstream application architectures, which can perform tasks such as office work, online shopping, and software maintenance. To handle complex user tasks, existing agents often need to interact with external resources. This exposes them to a common threat known as Indirect Prompt Injection (IPI) [9, 45, 47]. IPI involves embedding malicious instructions within external resources (e.g., web pages, emails) to compromise the LLM powering an agent and redirect an agent from the user task to perform the attacker-intended task.

In real-world environments, IPI is ubiquitous and difficult to defend against [7, 9, 47]. Therefore, a security tracing and attribution method for IPI is crucial. When an anomalous tool call is discovered,

∗^{*}Corresponding author.

Authors' Contact Information: Zitong Yao, Sun Yat-sen University, Guangzhou, China, yaozt@mail2.sysu.edu.cn; Jiangrong Wu, The Hong Kong University of Science and Technology, Hong Kong, China, jiangrongwu@cse.ust.hk; Yixi Lin, Sun Yat-sen University, Guangzhou, China, linyx98@mail2.sysu.edu.cn; Anrui Huang, Sun Yat-sen University, Guangzhou, China, huanganr3@mail2.sysu.edu.cn; Luoyun Zhang, Sun Yat-sen University, Guangzhou, China, zhangk367@mail2.sysu.edu.cn; Yuhong Nan, Sun Yat-sen University, Guangzhou, China, nanhy@mail.sysu.edu.cn.

auditors need a tracing method to investigate the incident. Such a method enables developers or auditors to trace the entire IPI incident through vast agent execution logs, thereby guiding developers in deploying superior and more robust agent architectures and supporting auditors in responding to incidents.

However, existing tracing methods [2, 16, 19, 38, 41] for LLM agents are limited for IPI attacks. Existing work primarily captures explicit control-flow and data-flow dependencies, overlooking the tool call sequence relationship generated by the malicious instructions, which represent the attacker intent. Since an IPI instruction can influence several tool calls without explicit dependencies between them, together with legitimate and malicious operations may alternate within one execution, existing tracing methods are incompatible for IPI attacks.

Our Work. In this paper, we propose AgentTracer, an intent-aware tracing framework for IPI attacks. We define task intent to represent the tool call sequence executed by the agent for the task goal (More details in Section 2.1). The key of AgentTracer is to treat the IPI as a form of task intent drift by the malicious instruction, which causes the corresponding tool invocation to deviate from the user intent (i.e., the tool call sequence expected by the user). Accordingly, AgentTracer compares the agent's task intent against the user intent to identify intent-drift operations, reconstruct the attack chain, and locate the injection source and its entry point in the agent execution log (the injection point).

To achieve this goal, there are three challenges that need to be solved: (i) How to construct a tracing graph that connects tool calls driven by the task intent; (ii) How to recognize tool calls that drift from the user intent; (iii) How to efficiently reconstruct the attack chain from noisy historical agent execution logs. First, legitimate and malicious operations may be interleaved in agent execution logs. This interleaving makes it difficult to connect dispersed tool calls by task intent. Second, user requests only describe high-level goals. Therefore, it is necessary to transform a natural-language request into a concrete yet flexible authorization space, which acts as the criteria for identifying intent-drift operations. Third, historical agent execution logs contain large amounts of unrelated execution data. Effective tracing must prune the tracing space while preserving the critical log scope needed to reconstruct the attack chain.

AgentTracer addresses these challenges with three core modules:

• Intent-Driven Execution Graph Construction. Based on the agent’s execution logs, AgentTracer recovers implicit decision dependencies among tool calls and uses these dependencies to construct an Intent-Driven Execution Graph. The graph connects dispersed tool calls by task intent.

  • User Intent Alignment. AgentTracer combines the user request with an operation knowledge base to construct a concrete user intent authorization space. AgentTracer then evaluates agent tool calls against this space to identify intent-drift tool calls.

• Attack-Chain Traceback. AgentTracer performs event-guided pruning to progressively narrow the tracing space and reconstruct the attack chain. The anomalous tool call under audit serves as the pruning anchor. AgentTracer then traces the intent-drift tool-call sequence backward to reconstruct the attack chain and locate the injection source and injection point.

Evaluation. We evaluate AgentTracer on two representative datasets, AgentDyn [17] and InjecAgent [47], covering diverse implementations of IPI attacks. In addition, to evaluate AgentTracer under noise from normal tasks, we combine the attack logs with normal execution logs containing 1,800 user requests and 9,000 background tool calls without IPI. All attack-tracing experiments are conducted on the combined execution logs.

Figure

Fig. 1. An Example of an Indirect Prompt Injection (IPI) Attack. The malicious instruction induces an attack chain interleaved with user-authorized tool calls.

Across the two datasets, AgentTracer achieves 94.17% injection-point accuracy (accuracy in locating the injection point) and 93.56% path precision (precision of the reconstructed attack chain). Compared with existing methods, AgentTracer improves injection-point accuracy by 18–54%.

Contributions. Our contributions are threefold:

  • We formulate IPI tracing as fine-grained alignment between task intent and tool calls. We introduce the Intent-Driven Execution Graph to connect dispersed tool calls by task intent and represent the tool-call sequence that realizes each task intent.

  • We propose a knowledge-enhanced user intent alignment method that combines the user request with operation knowledge to construct a structured user intent authorization space. The method evaluates tool calls along three dimensions—action, target, and constraint—to identify intent drift.

  • We construct and annotate datasets of agent execution logs covering diverse agent scenarios and multi-step IPI attacks. The evaluation demonstrates the effectiveness and efficiency of AgentTracer in locating injection points and reconstructing attack chains.

References (41)