Manuscript Offprint

arXiv:2608.30288

Extracting Knowledge from Tools in LLM Agents

Chuanchao Zang, Jianing Wang, Wenyu Chen, Xiangtao Meng, Li Wang, Xinyu Gao, Yingkai Dong, Zheng Li, Shanqing Guo

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

LLM agents commonly use knowledge-based tools and access their underlying files, databases, and search indexes through tool invocation. This integration improves agents' ability to provide domain-specific services but also introduces the risk of tool-mediated knowledge extraction: source content exposed to an agent for legitimate responses may be progressively recovered from its outputs, enabling reconstruction of the knowledge source behind a target tool. This paper systematically investigates this risk and identifies two challenges introduced by tool invocation: tool-selection uncertainty, where an agent may invoke a competing tool instead of the target tool, and tool-argument compression, where fine-grained query information may be lost when the agent generates tool arguments. To tackle these challenges, we propose ToolSiphon, a query-only extraction attack that introduces two complementary signals: a target-discriminative signal, implemented through Tool Contrastive Analysis, to steer queries toward the target tool; and a response-grounded factual signal, implemented through Evidence Chained Feedback, to mitigate argument compression and progressively expand extraction coverage. Across three types of knowledge-based tools and six domain-specific datasets, ToolSiphon recovers 74.3% of source records on average when coarse-grained information about non-target tools is available, with 83.2% textual recovery and 90.2% semantic similarity. Even without such information, it recovers 66.3% of source records. ToolSiphon also remains effective against representative defenses and on three real-world agent platforms.

1 Introduction

LLM agents are increasingly deployed to support domain-specific applications [28, 43]. They are built upon large language models as core engines and can plan, reason, and interact with external resources [39, 48]. One key capability of such agents is tool use: instead of relying only on the model's parametric knowledge, an agent can call external components to retrieve information, query databases, search documents, or invoke APIs. These tools serve different purposes [34, 37]. Some are action tools that primarily modify external state, such as sending emails, updating calendars, or placing orders [34, 37]. Others are information-returning tools that expose underlying knowledge sources—such as uploaded files, retrieval indexes, databases, search engines, or curated knowledge bases—to the agent [2, 18, 19]. In this paper, we focus on the latter class, referred to as knowledge-based tools.

In a typical scenario, users submit requests to the agent; the agent's LLM decides which knowledge-based tool to invoke, translates the request into concrete tool arguments (e.g., search terms, filters, or top-k limits), and answers using the retrieved information [32,34,37]. The sources behind these tools often contain valuable human-curated knowledge, domain expertise, and commercial assets—such as clinical guidelines used by a medical consultation tool or proprietary research reports used by a stock-analysis tool [2, 18, 19, 25]. Yet this same mediated access creates an attack surface: source content made available to the agent for legitimate answers may also be recovered from the agent's responses.

Motivation: In this work, we study a new data extraction attack against LLM agents equipped with knowledge-based tools, namely tool-mediated knowledge extraction. In this attack, the adversary aims to reconstruct the knowledge source behind a target knowledge-based tool, but can access it only through the agent's tool invocation process rather than a direct query interface. Furthermore, this differs from normal agent use: a benign user seeks task-specific answers synthesized from retrieved knowledge, whereas the adversary seeks reusable source-level content behind the target tool.

Using tool-mediated knowledge extraction, an adversary can reconstruct the knowledge source behind a target tool without direct access to that source. This can cause intellectual-property and business risks because recovered knowledge may be used to reproduce similar agents or services [11, 47]. For example, an adversary may extract clinical guidelines from a medical consultation agent or proprietary research reports from a stock-analysis agent and use them to build competing applications. Moreover, such extraction undermines developers' control over curated knowledge sources that require substantial collection, annotation, and maintenance efforts [47].

Figure

Figure 1: Extraction path of tool-mediated knowledge extraction.

Methodology: To perform tool-mediated knowledge extraction, the adversary interacts with the target agent only through its public interface. It submits ordinary task-oriented requests and observes the agent's final answers, without access to the agent's system prompts, tool outputs, execution traces, or the underlying knowledge source. The agent's final responses are therefore the adversary's only observation channel for the tool's content. A straightforward attempt is to ask the agent to return all data behind the target tool; another is to adapt existing extraction attacks designed for RAG systems [3, 11, 33, 44, 47] or agent memory [8, 21, 42]. However, both attempts fall short in this agent-mediated setting.

Unlike direct retrieval [11, 21, 42, 44, 47], where the query can act on the knowledge source more directly, the mediated setting requires the user query to first pass through the agent's tool-invocation process [5, 32, 37], as illustrated in Figure 1. This process introduces two challenges. The first is tool-selection uncertainty: the agent may select a wrong or related tool. Because multiple tools may support overlapping user intents, the agent's selection may depend on subtle differences among tool capabilities [1, 29, 37]. For example, a customer-support agent asked about refund rules may call a product-FAQ tool instead of the refund-policy tool, or may combine evidence from both, resulting in fidelity degradation. The second is tool-argument compression: even when the target tool is selected, the agent may compress or rewrite query details when generating tool arguments, limiting access to unexplored source content [34, 37]. A detailed symptom description, for instance, may be reduced to a generic keyword such as "headache," causing the tool to retrieve repeated or generic records rather than new source content. This limits extraction coverage.

To address these challenges, we propose ToolSiphon, a query-only data extraction attack for reconstructing source content behind target knowledge-based tools through public agent interactions. ToolSiphon assumes a targeted extraction setting: the adversary specifies a target tool and aims to reconstruct the source content behind it. However, the availability of information about other tools may vary across settings. When descriptions of other tools are available, ToolSiphon leverages them as contrastive references to distinguish the target tool from related tools; otherwise, it constructs locally generated shadow tool descriptions as substitutes. Given this target and the available tool information, ToolSiphon constructs two signals that help its queries stay aligned with the target tool and gradually expand the recovered source content. First, it constructs a target-alignment signal. It extracts functional phrases that are more specific to the target tool and uses them to guide request generation toward the target tool, reducing tool-selection uncertainty. Second, ToolSiphon constructs a source-expansion signal by extracting compact evidence items from previous answers, such as names, identifiers, or field values. These items are more likely to survive the agent's tool-argument compression than long semantic descriptions, and they guide follow-up requests toward less explored source content. In each round, ToolSiphon combines the two signals to generate a task-oriented request, submits it through the normal agent interface, and updates the source-expansion signal with new evidence items from the returned answer. In this way, ToolSiphon adaptively expands source coverage while maintaining the fidelity of recovered records.

We evaluate ToolSiphon across three representative types of knowledge-based tools: RAG-based tools, database-backed tools, and search-engine tools. Across six domain-specific datasets, ToolSiphon reconstructs substantial portions of target knowledge sources through query-only interactions with the agent. When non-target tool descriptions are available, ToolSiphon recovers 74.3% of source records on average while achieving 83.2% textual recovery and 90.2% semantic similarity. Even when such descriptions are unavailable, and ToolSiphon relies on locally generated shadow tool descriptions, it still recovers 66.3% of source records on average with 76.7% textual recovery and 85.5% semantic similarity. Compared with the strongest adapted baseline, ToolSiphon substantially improves both source coverage and reconstruction quality. ToolSiphon also remains effective against representative defenses and on three real-world agent-building platforms: GPTs, Coze, and Dify.

Abstractly, our contributions can be summarized as follows:

• We identify a new attack surface in LLM agents equipped with knowledge-based tools and formulate tool-mediated knowledge extraction, where adversaries reconstruct hidden knowledge sources through ordinary interactions.

• We propose ToolSiphon, a query-only extraction attack that overcomes agent-mediated challenges through two complementary signals: target alignment for reducing tool-selection interference and source expansion for exploring unrecovered source content.

• We conduct extensive evaluations across three types of knowledge-based tools, six domain-specific datasets, multiple defenses, and three commercial agent-building platforms, demonstrating the effectiveness of Tool-Siphon.

References (37)