Manuscript Offprint

arXiv:2610.36295

Detecting and Mitigating Query-Based System Prompt Leakage Attacks

Tushar Nayan, Pratik Poudel, Qian Lou, Yuede Ji, Jason Liu, Ruimin Sun

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

Tushar Nayan

Florida International University

tnaya002@fiu.edu

Yuede Ji

University of Texas at Arlington

yuede.ji@uta.edu

Pratik Poudel

Florida International University

ppoud001@fiu.edu

Jason Liu

Florida International University

liux@fiu.edu

Qian Lou

University of Central Florida

qian.lou@ucf.edu

Ruimin Sun

Florida International University

rsun@fiu.edu

Abstract—Large Language Models (LLMs) deployed in real-world applications rely on proprietary system prompts to enforce task directives, safety policies, and access controls. Recent studies demonstrate that these system prompts are vulnerable to query-based prompt leakage attacks, where adversaries with only black-box access can iteratively extract confidential instructions through adaptive, multi-turn interactions. Many existing prompt-leakage defenses primarily make per-query decisions and have limited visibility into attacks whose malicious objective emerges only across a sequence of interactions.

In this paper, we present AdvGuard, a model-agnostic framework for detecting and mitigating query-based system prompt leakage. Our key insight is that multi-turn prompt leakage can exhibit distinctive cross-query relational structure even when individual queries appear benign in isolation. AdvGuard captures these relationships in a bounded semantic interaction graph, uses statistical filtering to identify candidate interaction components, and then transforms each candidate into a line graph for GCN-based classification. The GCN learns multihop relational patterns over the topology and strength of these similarity relationships, enabling AdvGuard to distinguish coordinated extraction from benign iterative workflows. A lightweight prompt-level detector provides early protection before sufficient interaction structure has accumulated, while the overall design remains compatible with black-box LLM deployments.

We evaluate AdvGuard against representative prompt leakage attacks, including optimization-based and agent-driven extraction strategies, under controlled mixed-query and multi-turn workloads. Across mixed-query workloads, AdvGuard improves recall by up to 36% over the strongest baseline while maintaining FPR ≤ 3.4%. Under multi-turn conversational workloads, it achieves 97.23–99.1% F1 with 100% recall. In leave-one-attack-family-out evaluation, AdvGuard achieves 99.98% mean recall and 99.99% mean F1 on previously unseen attack families, with zero observed false positives. When inserted into the response-adaptive PLeak and LeakAgent attack loops, AdvGuard limits exact-match leakage to 0.00–0.01 and substring-match leakage to 0.01–0.09 across the evaluated victim models. These results show that AdvGuard generalizes beyond attack families observed during training and substantially limits prompt reconstruction under response-adaptive querying.

I. INTRODUCTION

Large Language Models (LLMs) are increasingly deployed in applications ranging from customer support and code generation to decision-support tools and autonomous agents [1]–[3]. In API-based and black-box deployments, developers often rely on hidden system prompts to encode application logic, enforce safety policies, and define tool-use protocols [4], [5]. Because these prompts can contain proprietary instructions and security-sensitive control logic, their exposure—known as prompt leakage—can reveal implementation details, weaken safety controls, and enable targeted follow-on attacks.

Attackers can elicit system-prompt content through explicit requests or more elaborate extraction strategies. Existing attacks use iterative probing [6], [7], adaptive reformulation [8], [9], encoding tricks [10]–[12], and multi-turn manipulation [13]. Although some attempts are overt and detectable from a single prompt, others distribute the extraction objective across multiple semantically related queries. In these cases, no individual query provides decisive evidence, while the accumulated interaction reveals repeated probing, reformulation, or contextual scaffolding.

Many existing defenses make decisions on individual inputs or outputs [14]–[16]. Such defenses can identify explicit extraction attempts, but they have limited visibility into attacks whose evidence emerges only across related interactions. Our key observation is not that every prompt-leakage attack requires multiple turns, but that iterative extraction can leave a distinctive cross-query relational structure. Repeated semantic reuse and coordinated reformulation may therefore provide a complementary signal when individual-query evidence is insufficient.

To capture this signal, we present AdvGuard, a lightweight, model-agnostic framework that operates at the input boundary of a black-box LLM service. AdvGuard first applies a prompt-level detector to identify explicit extraction attempts before interaction history is available. It then maintains a bounded semantic interaction graph that records similarity relationships among queries. Components with unusually high accumulated similarity are selected for further analysis and transformed into line graphs, allowing a graph convolutional network to classify their relational topology and edge strengths. This multi-stage design combines per-query and interaction-level evidence without requiring access to the protected system prompt, generated responses, or model internals.

We evaluate AdvGuard under controlled mixed-query traffic, benign multi-turn conversations, and response-adaptive attack loops. Across four prompt-leakage attack families and five benign workloads, AdvGuard achieves

91.14–100% recall while maintaining FPR at or below 3.4%. Under benign multi-turn conversational workloads, AdvGuard achieves 100% recall with FPR between 1.34% and 3.42%. When inserted into the response-adaptive PLeak and LeakAgent attack loops, AdvGuard limits exact-match leakage to 0.00–0.01 and substring-match leakage to 0.01–0.09 across the evaluated victim models. In our runtime evaluation, AdvGuard processes queries with an average latency of 32.96 ms.

In summary, this paper makes the following contributions:

• We formulate iterative prompt leakage as an interaction-level detection problem and study accumulated cross-query structure as a signal that complements individual-prompt analysis.

• We design AdvGuard, a lightweight black-box-compatible framework that combines prompt-level detection, bounded semantic interaction graphs, component-level candidate filtering, and line-graph classification.

• We evaluate AdvGuard across multiple attack families, benign workloads, victim models, and response-adaptive attack loops, measuring detection effectiveness, leakage mitigation, generalization, and runtime overhead.

References (61)