Skip to content

Extracting System Prompts of LLM Services in Complex (Agent) Scenarios: Hierarchical Optimization and Reliable Evaluation MetricsExtracting System Prompt of LLM Services in Complex (Agentic) Settings: Hierarchical Optimization and Reliable Evaluation Metrics

arXiv: Jailbreaks, Prompt Injection, Poisoning & Defenses· arXiv:2611.04803· Shuaidong Li, Chenhao Lin, Xinshan Yang, Chao Shen, Yufei Chen, Zhengyu ZhaoXi’an Jiaotong University; City University of Hong KongIndexed by this site · 20 days ago· Originally publishedAttacks

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

The authors propose a black-box system prompt extraction attack, ExtraHerO, tested on a GPT-4o chatbot and six GUI agents; the authors state that its fidelity, functionality and downstream injection gains all outperform five baselines.

Threat modelThe black-box attacker submits queries only through public interfaces and observes the final, usually post-processed output or action, with no access to model weights, gradients, or token probabilities, and cannot see internal reasoning (CoT) or tool-call logs; the goal is to extract system prompts from PaaS-style LLM services (chatbots and GUI agents), with success measured along three dimensions: fidelity, functionality, and adversarial utility.

Questions
System prompts are the core intellectual property of LLM services, but the authors argue that the threat models of existing extraction attacks are overly simplistic: real system prompts are longer, contain tool schemas and safety guardrails, and attackers can only see actions after agent post-processing rather than raw text.
Methods
Proposes ExtraHerO: decomposes extraction into multi-stage reconstruction according to a predefined structural template, iteratively updates adversarial queries using text gradients, and uses dual-track convergence control (information gain and gradient direction stability) to decide early stopping or restarting; for evaluation, it switches to sentence-level similarity, the new metric SKM, and the downstream injection gain adversarial utility.
Experiments and results
Compared with five baselines on a GPT-4o chatbot (150 prompts) and six GUI agents: on the chatbot, sentence-level similarity 75.07%, SKM 30.89%, downstream injection ASR 76.67% (Tables 4, 6); on agents, most baselines have SKM of 0, and ExtraHerO reaches 76.92% on MobileAgent (Table 7).
Limitations and future work
The authors state that future directions are reducing the number of queries and evaluating attacks and defenses in more realistic settings such as tool-augmented and multimodal; the experiments use only one victim model, GPT-4o, and test only one instruction-based defense, and the paper does not report query counts or repetition counts.
Experimental setupGPT-4o · 150 条五级复杂度系统提示词(L1–L5,含合成与真实来源)、Multi-modal Mind2Web(100 条任务响应) · BLEU、ROUGE-L et al.
Evaluated models
GPT-4o
Benchmarks
150 条五级复杂度系统提示词(L1–L5,含合成与真实来源)Multi-modal Mind2Web(100 条任务响应)
Metrics
BLEUROUGE-LMETEORBERTScoreSentence SemanticsSKMAction RecallASR
AI summaryThe researchers propose the ExtraHerO attack method to extract system prompts of LLM services in complex settings where system prompts are longer and more structured and agent scenarios can only observe the final processed output. The method decomposes extraction into a hierarchical reconstruction process based on predefined structural templates, iteratively updates adversarial queries according to the differences between feedback and templates, and monitors the information gain of attack optimization to stop early or reset, balancing effectiveness and efficiency. The paper points out that existing prompt fidelity metrics may be misleading because they do not consider structural information, and instead uses global text similarity and prioritizes structural keywords; it also proposes a system-level metric, adversarial utility, that measures how much extraction helps real downstream attacks. Experiments show that ExtraHerO improves on chatbots by an average of 12.5% (fidelity), 2.3% (functionality), and 6.0% (adversarial utility), and on agents by 12.2%, 34.3%, and 30.5%, respectively.

The researchers propose the ExtraHerO attack method to extract system prompts of LLM services in complex settings where system prompts are longer and more structured and agent scenarios can only observe the final processed output. The method decomposes extraction into a hierarchical reconstruction process based on predefined structural templates, iteratively updates adversarial queries according to the differences between feedback and templates, and monitors the information gain of attack optimization to stop early or reset, balancing effectiveness and efficiency. The paper points out that existing prompt fidelity metrics may be misleading because they do not consider structural information, and instead uses global text similarity and prioritizes structural keywords; it also proposes a system-level metric, adversarial utility, that measures how much extraction helps real downstream attacks. Experiments show that ExtraHerO improves on chatbots by an average of 12.5% (fidelity), 2.3% (functionality), and 6.0% (adversarial utility), and on agents by 12.2%, 34.3%, and 30.5%, respectively.

Related events and news

1 events · 1 news mentions

News that mentions this paper

大模型安全周报:智能体安全边界在签名、授权与上下文

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors argue that existing prompt extraction attacks fail under longer, more structured prompts and post-processed outputs, and propose ExtraHerO and more reliable evaluation metrics.

    Core question: how to extract system prompts from black-box LLM services in complex (agentic) settings, and reliably measure extraction quality.

    • Problem setting: System prompts are the core intellectual property of LLM services, containing operational logic, tool schemas, and safety guardrails; the authors state that successful extraction can replicate service functionality at near-zero cost, causing asset loss.
    • Shortcomings of existing methods: The authors argue that the threat models of existing extraction attacks are overly simplistic—they assume prompts are linear text and that attackers can see raw text outputs; in real services, prompts are longer and more structured, and users can only see actions after agent post-processing. The authors verify with a pilot study: as prompt complexity rises, five fidelity metrics of baseline attacks decline progressively (Figure 2); after outputs are post-processed, sentence-level similarity drops from 86.12 to 42.85 (Figure 3).
    • Problems with evaluation metrics: The authors point out that token-level metrics (BLEU, ROUGE-L, etc.) contain no structural information and are inflated by stopwords such as "please" and "You are" (Table 2 gives a counterexample: Case A is semantically opposite but has far higher token-level scores than Case B).
    • What the paper proposes: The attack framework ExtraHerO (hierarchical decomposition + text-gradient iteration + dual-track convergence control), and a three-dimensional evaluation framework: fidelity (including the new metric SKM), functionality, and adversarial utility (the gain of the extracted prompt on downstream prompt injection).
    • Threat model (Section 2.3):
      • Goal: Extract the system prompt θ of a victim service, ultimately treating the extraction result θ′ as a white-box proxy for θ.
      • Knowledge: black-box; no access to model weights, gradients, or token probabilities.
      • Capability: Submit queries x only through public interfaces, and observe the final, usually post-processed output y (natural language reply or action); internal CoT and tool-call logs are not visible.
      • Victim systems: PaaS-style LLM services, including chatbots and GUI agents.
  2. What related research exists?

    Related work falls into four groups: prompt extraction attacks, optimization-based LLM attacks, LLM-as-optimizer, and extraction defenses; the baselines are five extraction attacks.

    System prompt extraction attacks

    • Early manual methods (Perez et al. 2022; Liang et al. 2025, etc.): template injection in the style of "Ignore previous instructions" to bypass alignment filters; the authors state that such static methods are easily mitigated by safety training.
    • output2prompt (Zhang et al. 2024): treats extraction as reverse engineering, reconstructing the system prompt by analyzing the model's responses to fixed inputs.
    • PRSA (Yang et al. 2025): a two-stage reconstruction framework that classifies the LLM service and matches tone, style and wording.
    • T-GPS (Tan et al. 2025): uses textual gradient optimization to make the recovered prompt functionally closer to the original prompt; the paper calls it a state-of-the-art optimization-based attack.
    • The authors state that these optimization-based methods generally suffer from high query cost and traffic bursts that are easily detected by rate limiting, and that they emphasize textual similarity rather than functional executability, producing mostly "descriptive" text rather than executable system instructions.

    Optimization-based LLM attacks (jailbreak direction)

    • GCG (Zou et al. 2023): gradient-based white-box attack; PAIR (Chao et al. 2023) and TAP (Mehrotra et al. 2024): use an adversarial LLM to iteratively rewrite prompts based on victim model feedback; AutoDAN (Liu et al. 2024): genetic search to generate stealthy jailbreak prompts.
    • The paper points out the difference between this work and these jailbreak works: jailbreaks target any safety violation as a binary success objective, whereas prompt extraction is a reconstruction task for structured information.

    LLM as optimizer

    • OPRO (Yang et al. 2024), TextGrad (Yuksekgonul et al. 2024), ProTeGi (Pryzant et al. 2023), APE (Zhou et al. 2023): validate that textual feedback is a viable substitute for gradients; ExtraHerO borrows this idea, but the authors state that it uses textual gradients to balance "effective information acquisition" and "avoiding triggering safety filters."

    Prompt extraction/injection defenses

    • Including prompt hardening (Chen et al. 2025, etc.), input/output filtering (Phute et al. 2024; Robey et al. 2024, etc.), alignment fine-tuning (SecAlign, etc.), prompt obfuscation and vectorization (Cao et al. 2025); the paper cites a survey (Wang et al. 2025) stating that defenses against prompt leakage in agentic settings remain under-researched.

    Baselines and benchmarks: the comparison baselines are five extraction attacks: Naive, RTS (Cao et al. 2025), output2prompt, PRSA, and T-GPS; evaluation uses 150 system prompts at five complexity levels (chatbot) constructed by the authors and 100 task responses from Multi-modal Mind2Web (agent). The authors position this work as a black-box extraction attack targeting complex agentic settings, aiming at structural fidelity and query efficiency, with more reliable evaluation metrics.

  3. How does the paper address this problem?

    ExtraHerO adopts Decompose-then-Optimize: templated hierarchical decomposition, iterative query rewriting via textual gradients, and dual-track convergence control with early stopping and restart.

    The overall idea is to transform high-entropy holistic extraction into a series of easily optimizable subtasks after decomposition according to a structural template; the framework is named Extraction with Hierarchical Optimization (ExtraHerO) and adopts the Decompose-then-Optimize paradigm (Algorithm 1).

    Problem formulation

    • Service output y = f(LLM(x ∣ θ)), where f is a projection function that compresses internal information into user-observable signals; in the chatbot, f is the identity function, and in the agent, f is a lossy projection (exposing only actions).
    • The prompt θ is defined as a composite set of five functional component classes: role-play (R), formatting (F), tool-integration (T), logical reasoning (L), safety mechanisms (S).
    • Success is judged along three dimensions: fidelity = Sim(θ, θ′); functionality = Sim(yθ, yθ′); adversarial utility = the ASR increment after using θ′ to enhance a downstream attack (ASRθ′ − ASRw/o).

    Hierarchical Multi-Stage Decomposition (HMSD)

    • A predefined structural template θtemplate (given in Appendix .1: placeholder slots for role definition, input format, workflow, output format, tool descriptions, constraints, etc.) is used to decompose extraction into subtasks by functional stage.
    • The decomposition operator F(·) transforms the prompt into a set of semantic anchors; the segment θs recovered at each stage is appended to the cumulative state θ*, serving as anchors for subsequent stages.
    • The authors' rationale: probing conditioned on anchors aligned with the system's internal logic can increase the model's attention to relevant sensitive components in the prompt, making the model treat the extraction request as a coherent continuation of its prior state, thereby increasing the probability of inducing leakage.

    Iterative Refinement with Textual Gradients (IRTG)

    • Three adversarial components: Probing Agent P (generates queries), Prompt Analyst G (dual-task reasoning: maintains the current-stage prompt hypothesis θtstage and computes the textual gradient δt+1, i.e., the semantic residual between the current hypothesis and observed evidence), Evaluator E (monitors convergence).
    • Each round treats the victim LLM as a black-box oracle: submit query qt, observe yt; then (δt+1, θtstage) ← G(qt, yt), and P generates qt+1 according to δt+1.
    • P's query generation is constrained by a structured action space (Table .10 in Appendix .1: six operation primitives—components, number, details, usage, process, orthogonal break); the authors state that this makes each query a directed refinement of the previous one rather than random fuzzing.

    Dual-Track Convergence Control (DTCC)

    • A sliding window of size k monitors two trajectories: the prompt trajectory Wθ records the incremental vocabulary gain IGi = |Ti ∖ Ti−1| / |Ti−1| (the proportion of newly leaked tokens); the gradient trajectory Wδ records the cosine directional similarity simi between adjacent textual gradients.
    • Early stopping: terminates when the maximum IG in the window is below threshold ϵig and the minimum sim is above ϵsim; the authors explain this as new-token discovery saturating and the gradient stabilizing at a local optimum.
    • Restart: when the gradient direction is stable but IG fluctuates abnormally (≥ ϵig), it is judged as "pseudo-progress" (the authors believe the model may be generating hallucinated content at this point), and a high-entropy meta-instruction is injected to force a trajectory jump; the original text of this meta-instruction is in Section 3.3.
    • The parameter T controls the extraction budget for each stage.

    Evaluation metric design

    • Fidelity: token level (BLEU, ROUGE-L, METEOR, BERTScore; the paper states these are retained only for completeness), prompt level (Sentence Semantics), structure level (new metric SKM: an LLM extracts structural keywords from the victim prompt according to the instructions in Appendix .2—system identity, domain concepts, operational terms, behavioral constraints, etc.—and SKM measures the recall of these keywords).
    • Functionality: 10 generic user queries (Table .11 in Appendix .2) are used to compare output similarity driven by the extracted prompt versus the original prompt; for agents, action recall is additionally computed.
    • Adversarial utility: the extracted prompt is inserted into indirect prompt injection instructions, and the downstream ASR increment is measured (injection instructions for chatbot and agent are in Table 3).
  4. What experiments did the paper conduct?

    Compares against five baselines on a GPT-4o chatbot (150 prompts) and six GUI agents; ExtraHerO is overall best-performing on the three-dimensional metrics, and ablations, parameter sensitivity, and one defense evaluation were conducted.

    Experimental setup

    • Victim systems: GPT-4o for the chatbot; six GUI systems for agents—MobileAgent, AppAgent (phone), BrowserUse, SeeAct (Web), Agent-S, UFO (PC); the paper states that the underlying model for these agents is likewise GPT-4o as a representative frontier model.
    • Datasets: 150 system prompts for the chatbot, in five complexity levels (L1 about 100 tokens to L5 real-world sources 4,000+ tokens, Table 1; L1–L3 programmatically synthesized by GPT-4o, L4 adds reminder/dummy defense components, L5 from public leak repositories and real PaaS deployments); 100 task responses from Multi-modal Mind2Web for agents, with malicious web pages constructed with embedded visual semantic triggers (Figure 5).
    • Baselines: Naive, RTS, output2prompt (O2P), PRSA, T-GPS, implemented per the original papers.
    • Metrics: fidelity at three levels (four token-level metrics, Sentence Semantics, SKM); functionality (sentence-level semantic similarity for the chatbot, plus action recall for agents); adversarial utility (ASR of downstream indirect prompt injection).
    • Review method: SKM structural keywords are extracted by an LLM according to the instructions in Appendix .2; the paper does not specify which LLM was used for this or for computing sentence-level similarity, nor does it report the number of repetitions.

    Main results

    Chatbot fidelity (%, per Table 4):

    Swipe horizontally to read the table

    MethodBERTScoreSentence SemanticsSKM
    Naive63.9549.8216.53
    O2P70.0441.010.34
    T-GPS72.2458.5310.38
    PRSA80.4462.574.79
    RTS72.9160.9019.96
    ExtraHerO82.8475.0730.89

    Agent fidelity (SKM / Sentence Sim., %, per Table 7, listing only ExtraHerO and the highest baseline values):

    Swipe horizontally to read the table

    Victim AgentHighest baseline SKMExtraHerO SKMHighest baseline SentSimExtraHerO SentSim
    MobileAgent0.00 (all baselines)76.9274.38 (RTS)82.49
    AppAgent6.67 (RTS)33.3365.41 (PRSA)82.50
    BrowserUse26.67 (T-GPS)26.6771.58 (PRSA)86.19
    SeeAct0.00 (all baselines)4.0068.43 (PRSA)77.98
    Agent-S8.70 (T-GPS)34.6263.78 (RTS)86.80
    UFO3.33 (RTS)17.0772.59 (PRSA)79.32
    • The authors state that ExtraHerO improves on average by 12.5% (fidelity), 2.3% (functionality), 6.0% (adversarial utility) on the chatbot, and by 12.2%, 34.3%, 30.5% on agents (abstract and introduction); the paper does not give the calculation basis for these averages.
    • Exceptions: on BrowserUse, ExtraHerO's SKM is 26.67, tied with T-GPS (Table 7); on SeeAct, SKM is only 4.00, which the authors attribute to SeeAct's lengthy tool descriptions and information bottleneck diluting the extraction signal.
    • Authors' interpretation: baselines mainly recover low-entropy filler words and generic formatting (example in Table 5), whereas ExtraHerO recovers execution-critical logic; token-level scores clearly diverge from the other two levels, consistent with the metric critique in Section 2.2.

    Functionality and downstream injection gains

    • Chatbot functionality (Figure 6): sentence-level similarity of each method's output is O2P 64.32%, PRSA 68.33%, T-GPS 68.68%, Naive 69.60%, RTS 70.32%, ExtraHerO 72.61%.
    • Chatbot downstream injection ASR (Table 6): 13.33% without the extracted prompt; O2P 40.67%, PRSA 52.67%, Naive 54.00%, RTS 66.67%, T-GPS 70.67%, ExtraHerO 76.67%. The authors state that even the worst baseline brings a 6.67% improvement, attributing this to downstream attacks being sensitive only to key operational constraints and highly tolerant of syntactic noise.
    • Agent functionality (Figure 7): sentence-level semantics for most methods are mostly between 75–95, but on action recall most baselines are near 0 (e.g., on MobileAgent, Naive 2.78, most other baselines 0–3.00), while ExtraHerO is AppAgent 8.33, MobileAgent 58.33, UFO 66.00, SeeAct 51.02, Agent-S 68.75, BrowserUse 82.02; the authors state that only ExtraHerO achieves substantial action-level similarity.
    • Agent downstream injection (Figure 8, clustered bar chart of ASR grouped by agent): the authors state that prompts extracted by ExtraHerO can enhance downstream attacks, e.g., reaching 98 on MobileAgent; the exception is a decrease on BrowserUse, which the authors state can be partially compensated by using the leaked tool-call logic to redirect the agent to a sinkhole page.

    Ablation and defenses

    • Component ablation (Table 8, metric is six fidelity measures): Naive baseline SKM 0.96; IRTG alone rises to 17.08; IRTG+HMSD drops to 13.55 (the authors state a relative decrease of 20.6%, attributed to structural anchors constraining the optimization space and insufficient knowledge convergence); IRTG+DTCC is 14.27; the full combination is highest (SKM 21.47, SentenceSim 78.33). The authors state that adding DTCC to IRTG alone makes little difference; it only takes effect as a regulator of HMSD.
    • Instruction-based defense (Table 9, chatbot, SKM / SentenceSim): after adding an explicit no-leakage instruction to the system prompt, all attacks decrease—ExtraHerO from 49.90 / 81.41 to 14.60 / 72.64, RTS from 24.92 / 62.54 to 14.81 / 47.41; PRSA and O2P's SKM instead rise slightly (5.36→7.42, 1.11→1.79). The authors state that none of the attacks were designed against the defense, so they are not expected to remain effective under it, and that the heavier SKM damage indicates the prompt core was not extracted.

    Other ablations and analyses

    • ϵig (early-stopping threshold) (Figure 10 top): too small overfits syntactic noise, too large converges prematurely; performance is best at ϵig = 0.15 (per the authors).
    • ϵsim (restart threshold) (Figure 10 bottom): increasing it lowers restart frequency; performance dips at ϵsim = 0.86 and is best at 0.90 (the authors state the trend is non-monotonic).
    • Pilot study (Figures 2, 3): baseline attacks decline progressively across L1–L5 complexity on five fidelity metrics; after output post-processing, BLEU drops from 26.33 to 15.22 and SentenceSim from 86.12 to 42.85.
  5. What are some points that can be further explored?

    The authors propose two directions: reducing query volume and evaluating attacks and defenses in more realistic settings; the experiments cover only one victim model, GPT-4o, and one instruction-based defense.

    Limitations and future directions noted by the authors

    • Reducing query cost (Section 7/8 Conclusion and Outlook): The authors state that a promising direction is "reducing the number of required queries while maintaining extraction quality under more restricted feedback."
    • More realistic settings (Section 7/8): The authors state that "evaluating attacks and defenses in more realistic settings (including tool-augmented and multimodal systems)" is an interesting direction, because the consequences of prompt leakage may differ in these scenarios.
    • Effectiveness under defenses (Section 5 Discussion about Defenses): The authors explicitly write that all tested attacks, including ExtraHerO, were not designed to bypass defenses, and "we do not expect them to remain substantially effective under defenses."
    • The paper has no separate Limitations section; all of the above comes from explicit statements in the conclusion and discussion sections.

    Scope of experiments

    • Victim models: The underlying LLM is only GPT-4o (Section 4.1; the authors state it was chosen because smaller models have unstable instruction following); the agent side covers six GUI systems across three platforms.
    • Data scale: 150 system prompts for the chatbot (five complexity levels); 100 task responses from Multi-modal Mind2Web for the agent.
    • Defense evaluation: Only one inference-time instruction-based defense (adding explicit instructions prohibiting leakage to the system prompt, Table 9); the paper discusses defense categories such as prompt hardening, input/output filtering, alignment fine-tuning, and prompt obfuscation, but tests only deployable inference-time defenses on the grounds that "training-time defenses are costly."
    • Downstream attack evaluation: adversarial utility tests only one downstream attack, indirect prompt injection (task hijacking) (Table 3).
    • Information not reported: The paper does not report the specific value of the attack's query count/iteration budget T, the number of experimental repetitions, the specific models used for SKM keyword extraction and sentence-level similarity computation, or any human evaluation or inter-rater agreement.
  6. Summarize the main content of the paper

    ExtraHerO decomposes system prompt extraction into templated multi-stage reconstruction, and overall outperforms five baselines on three-dimensional metrics on a GPT-4o chatbot and six GUI agents.

    A paper on system prompt extraction attacks, targeting real LLM services after the rise in complexity (long, structured prompts; agents that only expose post-processed outputs).

    • Problem: The authors argue that existing extraction attacks assume prompts are linear text and outputs are fully visible, and that these fail in agentic settings; a pilot study shows that baseline attack fidelity declines as prompt complexity rises, with sentence-level similarity dropping from 86.12 to 42.85 after output post-processing (Figures 2, 3). The authors also point out that token-level evaluation metrics are inflated by stopwords and are insufficient to measure extraction quality.
    • Method: ExtraHerO decomposes extraction into multi-stage subtasks according to a predefined structural template, uses three components—Probing Agent, Prompt Analyst, and Evaluator—to perform text-gradient-driven iterative querying, and uses dual-track convergence control (lexical information gain + gradient direction stability) to decide early stopping or restarting. For evaluation, it proposes the structural-level metric SKM and the system-level metric adversarial utility (the gain of extraction results on downstream prompt injection ASR).
    • Main results:
      • Chatbot (GPT-4o, 150 prompts): Sentence Semantics 75.07%, SKM 30.89%, both higher than five baselines (Table 4); downstream injection ASR 76.67%, versus 13.33% without the extracted prompt (Table 6).
      • Agent (six GUI systems): most baselines have SKM close to 0; ExtraHerO achieves SKM 76.92% and SentenceSim 82.49% on MobileAgent (Table 7); action recall reaches 82.02% on BrowserUse, while most baselines are close to 0 (Figure 7).
      • Exceptions: on BrowserUse, SKM ties with T-GPS (26.67); on SeeAct it is only 4.00; under instruction-based defenses, ExtraHerO's SKM drops from 49.90 to 14.60 (Table 9).
    • Authors' conclusion: Hierarchical extraction matters for complex settings; ExtraHerO can extract the structural core of prompts, and structural fidelity can translate into functionality and downstream attack gains. The authors state that future directions are reducing the number of queries and evaluating attacks and defenses in more realistic settings such as tool-augmented and multimodal systems.
Read originalarxiv.org