Source-linked AI summary

InjecAgent: Benchmarking Indirect Prompt Injections in Tool-Integrated Large Language Model Agents

Qiusi Zhan, Zhixiang Liang, Zifan Ying, Daniel Kang

arXiv:2403.02691v3cs.CLcs.CR

TL;DR

Indirect prompt injections embed malicious instructions in external content to manipulate tool-integrated LLM agents into harmful actions, motivating systematic vulnerability evaluation. InjecAgent provides such a benchmark and evaluates 30 agents, finding widespread vulnerability, including a 24% attack success rate for prompted GPT-4 that rises to 47% with a hacking prompt.

  • Problem

    External content can carry malicious instructions that cause agents to steal sensitive information or execute unauthorized financial and physical actions, making systematic evaluation important.

  • Method

    INJECAGENT is a benchmark with 1,054 test cases spanning multiple domains, attack types, attacker instructions, and an enhanced hacking-prompt setting, evaluated across 30 LLM agents.

  • Results

    Most evaluated agents are vulnerable to indirect prompt injection; prompted GPT-4 has a 24% attack success rate, rising to 47% with a hacking prompt.

  • Takeaways & Limitations

    The findings demonstrate that malicious instructions injected into external content can manipulate agents into harmful actions, underscoring risks and the need for safeguards.

  • Takeaways & Limitations

    The enhanced setting uses a fixed, predefined hacking prompt, so varying prompts and dynamic enhancement methods remain uninvestigated.

Abstract

from arXiv · show

Recent work has embodied LLMs as agents, allowing them to access tools, perform actions, and interact with external content (e.g., emails or websites). However, external content introduces the risk of indirect prompt injection (IPI) attacks, where malicious instructions are embedded within the content processed by LLMs, aiming to manipulate these agents into executing detrimental actions against users. Given the potentially severe consequences of such attacks, establishing benchmarks to assess and mitigate these risks is imperative. In this work, we introduce InjecAgent, a benchmark designed to assess the vulnerability of tool-integrated LLM agents to IPI attacks. InjecAgent comprises 1,054 test cases covering 17 different user tools and 62 attacker tools. We categorize attack intentions into two primary types: direct harm to users and exfiltration of private data. We evaluate 30 different LLM agents and show that agents are vulnerable to IPI attacks, with ReAct-prompted GPT-4 vulnerable to attacks 24% of the time. Further investigation into an enhanced setting, where the attacker instructions are reinforced with a hacking prompt, shows additional increases in success rates, nearly doubling the attack success rate on the ReAct-prompted GPT-4. Our findings raise questions about the widespread deployment of LLM Agents. Our benchmark is available at https://github.com/uiuc-kang-lab/InjecAgent.

1 Introduction

Tool-integrated LLM agents can be manipulated through malicious instructions embedded in retrieved external content, creating risks of data theft and direct harm. INJECAGENT formalizes and benchmarks these indirect prompt injection attacks across diverse tools and scenarios.

  • External content retrieved by agents can contain malicious instructions that cause unauthorized financial, physical, or privacy-harming actions.These attacks exploit content fed back to the LLM as context.
  • INJECAGENT contains 1,054 test cases spanning 17 user tools and 62 attacker instructions across domains including finance, smart homes, and email.
  • Test cases pair a user request for externally retrieved content with attacker-controlled content that instructs the agent to perform an unauthorized harmful action.A doctor-review example demonstrates how executing the injected instruction succeeds, while declining it fails the attack.
  • The benchmark categorizes attacks as direct harm or data stealing and evaluates agents under both standard and hacking-prompt-enhanced settings.
  • 24% is the attack success rate for ReAct-prompted GPT-4, rising to 47% with a hacking prompt, while fine-tuned GPT-4 reaches 7.1%.
  • The study evaluates 30 LLM agents and reports that most are vulnerable to indirect prompt injection attacks.

2 Benchmark Construction

INJECAGENT is constructed by formalizing an attacker-controlled tool-use scenario, generating realistic user and attacker cases, and combining them into base and enhanced test settings. The benchmark covers diverse tools and two principal attack categories.

  • 2.1 Problem Formalization: An attack begins with a user instruction that retrieves external content containing an attacker instruction, which then attempts to invoke another tool for user harm.Success occurs when the agent executes the injected instruction and causes adverse consequences.
  • 2.2 Test Case Generation: GPT-4 assists in generating tool-response templates and cases, followed by manual refinement to preserve plausible formats and alignment with user requests.
  • 2.2 Test Case Generation: The benchmark selects 17 tools whose externally retrieved content can be modified by attackers and generates aligned user instructions, parameters, and response templates.Templates place an attacker-instruction placeholder in a field that attackers can modify.
  • 2.2 Test Case Generation: Direct-harm attacks invoke tools that damage users, whereas data-stealing attacks extract private data and transmit it through an email-sending tool.
  • 2.2 Test Case Generation: The final attacker set contains 30 direct-harm cases and 32 data-stealing cases, with further secondary-intention categories.
  • 2.2 Test Case Generation: Each user case is paired with an attacker case to form 1,054 test cases per setting, with the enhanced setting prepending a fixed hacking prompt.

3 Experiments

The experiments evaluate prompted and fine-tuned LLM agents with INJECAGENT using attack success metrics and validity filtering. Prompted agents are substantially vulnerable, hacking prompts usually increase attack success, and fine-tuned agents are more resilient.

  • 3.1 Experimental Setup: The evaluation compares prompted agents using ReAct-style tool use with fine-tuned agents trained on function-calling examples.
  • 3.1 Experimental Setup: Attack success rate is the primary metric, while ASR-valid measures successful attacks among valid outputs.Invalid outputs are excluded when they cannot be classified as successful or unsuccessful attacks.
  • 3.2 Attack Success Rates of Different Agents: 24% and 47% are the prompted GPT-4 ASRs in the base and enhanced settings, respectively.
  • 3.2 Attack Success Rates of Different Agents: More than 80% are the ASRs reported for prompted Llama2-70B in both settings.
  • 3.2 Attack Success Rates of Different Agents: 3.8% and 6.6% are the ASRs for fine-tuned GPT-4 and GPT-3.5, respectively.
  • 3.2 Attack Success Rates of Different Agents: All agents except prompted Claude-2 have higher ASRs in the enhanced setting than in the basic setting.
  • 3.2 Attack Success Rates of Different Agents: 100% is the data-transmission success rate for both fine-tuned GPT-3.5 and GPT-4.Data extraction usually succeeds more often than direct-harm tool execution.

4 Analysis

The analysis finds that user-case characteristics are more strongly associated with attack success than attacker-case characteristics, and that content freedom and attack-setting changes affect outcomes. Agents’ sensitivity to malicious instructions increases in the enhanced setting, while some attacks remain successful.

  • 4.1 User Cases Exhibit a Stronger Association with Attack Success Than Attacker Cases: User cases show a stronger association with attack success than attacker cases for both direct harm and data stealing attacks.Both associations are statistically significant, and paired per-agent tests support the same pattern.
  • 4.2 User Cases with High Content Freedom Placeholders Are More Vulnerable: High-content-freedom user cases yield higher attack success rates than low-content-freedom cases across agents.The analysis classifies cases by content freedom and compares aggregate and per-agent ASRs.
  • 4.2 User Cases with High Content Freedom Placeholders Are More Vulnerable: Content freedom affects attack success across agents, with p < 0.0001.The proposed explanation is that flexible placeholders let attacker instructions blend more seamlessly into normal content.
  • 4.3 Enhanced Setting Increases Agents’ Sensitivity to Attacker Instructions: Enhanced attacks consistently produce higher sensitivity rates than base attacks across the evaluated agents.Sensitivity rate measures outputs that recognize attacker instructions as abnormal or potentially harmful.
  • 4.3 Enhanced Setting Increases Agents’ Sensitivity to Attacker Instructions: Claude-2 is the only agent with a lower attack success rate in the enhanced setting and shows significantly high sensitivity and conversion rates.Conversion rate is the ratio of attacks changing from successful to failed to successful attacks in the base setting.

5 Related Work

Prior work distinguishes direct from indirect prompt injection and has proposed black-box and white-box defenses. The paper positions its contribution as a broader examination of IPI in tool-integrated agents across realistic scenarios, while noting that existing defenses largely target simpler instruction-data concatenation.

  • Prompt Injection: Direct prompt injection targets an LLM’s inputs, whereas indirect prompt injection embeds harmful prompts in external content retrieved by the LLM.IPI aims to divert benign user instructions and has been associated with real-world plugin consequences including phishing and data exfiltration.
  • Prompt Injection: The benchmark studies tool-integrated agents across 17 user cases and 62 attacker cases in real-world scenarios.This scope differentiates the work from related settings focused on narrower attack scenarios.
  • Prompt Injection Defenses: Prompt-injection defenses include black-box methods such as awareness prompts and delimiters, and white-box methods requiring model access.The cited defense categories are introduced as part of rapidly evolving prompt-injection research.
  • Prompt Injection Defenses: Existing defense studies primarily examine straightforward instruction-data concatenation rather than complex tool-integrated agent scenarios.Their implementation and effectiveness for tool-integrated agents remain areas for future exploration.

6 Conclusion

The conclusion presents INJECAGENT as the first benchmark for indirect prompt injection attacks against tool-integrated LLM agents. Evaluating 30 agents, it demonstrates that malicious instructions embedded in external content can manipulate agents into harmful actions and highlights the need for safeguards.

  • 6 Conclusion: INJECAGENT is introduced as the first benchmark targeting indirect prompt injection attacks against tool-integrated LLM agents.The benchmark evaluates 30 different LLM agents and supports comprehensive analysis of their vulnerabilities.
  • 6 Conclusion: The findings demonstrate the feasibility of manipulating agents into performing harmful actions by injecting malicious instructions into external content.The conclusion emphasizes both the ease of deploying such attacks and the severity of their potential outcomes.
  • 6 Conclusion: The work emphasizes the need for strategies to safeguard tool-integrated agents against indirect prompt injection attacks.It also offers guidance on implementing such strategies within the supported scope of the benchmark’s findings.

7 Ethical Considerations

The ethical discussion centers on the dual-use nature of publicly disclosing vulnerabilities identified by INJECAGENT. The authors frame disclosure as intended to strengthen NLP security and resilience while acknowledging possible misuse.

  • 7 Ethical Considerations: INJECAGENT’s disclosed vulnerabilities have dual-use implications because security information may also be misused.The authors acknowledge this risk while arguing that awareness is important for strengthening the NLP community.
  • 7 Ethical Considerations: The stated goal of disclosure is to promote stronger security and resilience against potential exploits.The ethical justification is framed as preemptive protection of the NLP community.

8 Limitations

The benchmark’s limitations concern the enhanced attack setting, attacker-content variability, scenario complexity, and limited coverage of fine-tuned agents.

  • 8 Limitations: The enhanced setting uses a fixed hacking prompt, leaving the effects of alternative prompts and dynamic enhancement methods unexamined.The authors note that developers could potentially filter out the fixed prompt.
  • 8 Limitations: The benchmark assumes external content contains only attacker instructions, so mixed malicious and benign content remains unexplored.Real-world examples could embed harmful instructions within reviews or topic-relevant emails.
  • 8 Limitations: The initial benchmark covers only single-turn interactions and attacker instructions limited to two steps.The authors identify more complex real-world scenarios as requiring further investigation.
  • 8 Limitations: Only two fine-tuned agents were studied because of limited model availability, motivating broader evaluation of fine-tuned LLMs for tool use.The study observed higher valid rates and greater resilience for fine-tuned agents than for ReAct-prompted agents.

A Dataset Details

The dataset’s difficulty analysis categorizes user cases by how easily attackers can inject malicious instructions.

  • A Dataset Details: 7 cases were classified as high difficulty, including requesting notes in Evernote, which are typically personal or limited to small groups.GPT-4 assigned each user case a high, medium, or low attacker-injection difficulty score.
  • A Dataset Details: 4 cases were classified as low difficulty, including requesting Amazon product reviews that attackers can easily access.The remaining 6 cases were categorized as medium difficulty.

B.1 Implementation Details

The evaluation compares LLM agents’ validity, attack success, and response behavior across attack settings, using ReAct prompting and multiple reporting views.

  • B.1 Implementation Details: The experiments used Together AI for non-GPT and non-Claude models, temperature 0, and test-case-specific user and attacker tool specifications.Evaluating one model on a single setting took approximately one hour on average.
  • B.1 Implementation Details: The ReAct prompt equips LLMs with tool usage requirements for helpfulness and security, yet unsafe tool calls remained vulnerable.The detailed prompt is provided in Appendix E.1.1.
  • C.1 Valid Rates of the Agents: Figure 4 compares agents’ valid rates with Arena Elo ratings, showing a generally positive correlation between the two measures.The authors interpret invalid outputs as reflecting LLM incapability.
  • C.1 Valid Rates of the Agents: Figure 5 plots valid rate against overall attack success rate, with larger circles representing models with more parameters.The second quadrant represents agents that are both effective and secure, supporting selection across effectiveness, efficiency, and security.
  • C.1 Valid Rates of the Agents: Table 6 reports agent valid rates without attacks, under base attacks, and under enhanced attacks.The no-attack comparison uses InjecAgent-clear, which supplies three benign tool responses per user case.
  • C.2 ASR-valid for Remaining Agents: Table 7 reports ASR-valid for agents with valid rates below 50%, while Tables 8 and 9 report ASR-all and attack-type-specific ASRs.Attack-type ASRs varied seemingly randomly across agents.

C.5 Response Quallity Evaluation

The response-quality evaluation examines failed attacks for relevance and clarity, while also comparing results under an alternative shorter ReAct prompt.

  • C.5 Response Quallity Evaluation: GPT-4 assigned relevance and clarity scores from 0 to 2 to agent responses when attacks failed.Table 10 covers agents with more than 50 failed attack cases.
  • C.5 Response Quallity Evaluation: Claude-2 achieved a significantly high clarity score because its responses frequently alerted users to abnormal content in tool responses.This behavior contrasts with GPT models’ tendency to display malicious instructions without explanation.
  • C.5 Response Quallity Evaluation: GPT models tended to display malicious instructions directly without explanation, potentially confusing users.The study also reports ASR-valid and ASR-all results for a shorter LangChain ReAct prompt.

C.7 Analysis of Different Test Cases

Attack success rates vary substantially across user and attacker cases, with enhanced and long-prompt configurations producing higher success rates than their base and short-prompt counterparts.

  • Configuration comparisons: Enhanced settings show higher attack success rates than base settings, while long prompts show higher rates than short prompts.The comparison covers prompted agents and direct harm attacks across multiple user and attacker cases.
  • Case-level variation: Some user and attacker cases exhibit significantly higher or lower success rates than others, including user case 6 and attacker case 25.These differences appear in heatmaps covering individual test cases.
  • Case-level variation: The analysis also groups user cases by content freedom, identifying 12 high-content-freedom cases and 5 low-content-freedom cases.Three examples are presented for each group.
  • Attack categories: The evaluation distinguishes direct harm attacks from data stealing attacks, with data stealing measured through extraction and transmission steps.The reported tables use ASR-all and identify S1 as data extraction and S2 as data transmission.
  • Configuration comparisons: Figure 6 compares attack success rates across long and short prompts under base and enhanced settings.The heatmaps are calculated from prompted-agent performance.

D.2 Successful Attacks

The examples show both direct-harm and data-stealing attacks in which malicious content retrieved through a user-requested tool prompts agents toward harmful actions. Other examples show agents refusing or declining such actions when they detect contextual or safety problems.

  • Successful attacks: A prompted GPT-4 agent executes a $500 payment after retrieving a malicious instruction embedded in an Evernote note.The attack uses the BankManagerPayBill tool with the supplied account, payee, service account, date, and amount.
  • Successful attacks: A fine-tuned GPT-4 agent retrieves saved addresses with AmazonViewSavedAddresses and sends them to an attacker through GmailSendEmail.This demonstrates a data-stealing attack involving sequential extraction and transmission actions.
  • Failed attacks: A fine-tuned GPT-4 agent rejects a review asking for a Binance deposit because the financial instruction is unrelated to the requested doctor review.The agent identifies a likely data mix-up and advises checking the reviews directly on Teladoc.
  • Failed attacks: A prompted Claude-2 agent retrieves payment information but refuses to send it without the user’s explicit confirmation.Its response recognizes the safety issue after the retrieval step.
  • Agent execution format: The agent framework uses Thought, Action, Action Input, Observation, and Final Answer stages to structure tool-use trajectories.Actions must use available tools and valid JSON inputs matching their argument specifications.
Loading 2403.02691v3…