Identifying and Mitigating Vulnerabilities in LLM-Integrated Applications

Fengqing Jiang, Zhangchen Xu, Luyao Niu, Boxin Wang, Jinyuan Jia, Bo Li, Radha Poovendran · Submission to ICLR 2024 · Rejected

TL;DR

Large Language Model (LLM)-integrated applications act as middleware that augment user prompts with proprietary databases or system instructions, but this architecture creates a major security blind spot. This paper demonstrates that malicious middleware (insider threats) and poisoned retrieval databases (outsider threats) can easily bypass OpenAI's moderation filters to inject bias, toxicity, privacy risks, and disinformation. To solve this, the authors introduce Shield, a lightweight defense framework combining RSA-FDH digital signatures with dual-pass LLM meta-prompting that detects and neutralizes these attacks while preserving normal utility.

What Problem Does This Paper Address?

Most users do not interact directly with raw foundation models; instead, they interact with LLM-integrated applications (such as customer service bots, shopping assistants, or enterprise search tools). In this setup, the application acts as an intermediary:

  1. Upstream: The app takes a user's prompt, retrieves context from a local knowledge base or database, wraps it with internal "system instructions," and sends the refined prompt to the LLM backend.
  2. Downstream: The app receives the raw LLM output, applies post-processing, and returns the final response to the user.

This middle layer introduces severe trust vulnerabilities:

  • Opaqueness and Broken Integrity: The backend LLM cannot verify whether the user actually authorized the prompt modifications, and the user cannot verify whether the response came directly from the LLM or was altered by the app.
  • Threat Vectors: An insider (a rogue application developer or compromised server) can alter system prompts or rewrite responses, while an outsider can poison external retrieval databases (indirect prompt injection) to hijack model behavior.

Existing safety guardrails (like RLHF or API output filters) largely fail against these application-level manipulations.

Methods

The authors characterize the attack surface across upstream and downstream phases (evaluating prompt perturbation, perturbed system prompts, proxy rewrites, and data poisoning) and propose Shield, a standalone API layer designed to fulfill four key properties: integrity, source identification, attack detectability, and utility preservation.

[User] --(Signs query with private key Ku)--> [Application (Augments prompt)]
                                                      |
                                                      v
                                        [Shield API verifies signature]
                                                      |
                                     (Builds Meta-Prompt P1: detect attack?)
                                                      v
                                                   [LLM]
                                                      |
    [User] <--(Verifies Kl signature)-- [Shield signs response] <-- [Application]
  • Cryptographic Grounding (RSA-FDH): Users digitally sign their raw query ($P_U$) using RSA Full Domain Hash (RSA-FDH) before sending it to the application. The middleware cannot tamper with the original query without invalidating the cryptographic signature.
  • Upstream Meta-Prompting for Attack Detection: Shield receives both the signed user query and the application's modified intermediate prompt ($P_A$). It asks the backend LLM via an instruction-based meta-prompt whether $P_A$ introduces malicious bias, toxic instructions, or unsolicited information compared to $P_U$. If malicious behavior is detected, Shield discards the application's wrapper and forwards only the clean user query.
  • Downstream Verification: When the application performs post-processing on the LLM's response, Shield queries the LLM again via meta-prompt $P_2$ to confirm whether the semantics were maliciously altered before signing the final payload ($R_A$ or fallback $R_L$) using the LLM provider's private key ($K_L$).

Datasets

The authors evaluated threats and defense mechanisms across multiple scenarios:

  • Online Shopping Evaluation: 50 curated seed user queries covering 5 product categories (fruits, beverages, snacks, food, books) across 5 distinct query templates, evaluated under 100 test variations.
  • TruthfulQA Benchmark: Used to measure the degradation of factual truthfulness and the generation of disinformation when system prompts are maliciously perturbed.
  • MedicationQA Dataset: 25 seed questions expanded into 500 user prompts for evaluating toxic content injection in a specialized medical assistant setting.
  • Perspective API: Used to evaluate toxicity scores and establish a baseline defense classifier.

Key Insights and Ideas

  • System Prompts are High-Leverage Attack Vectors: Manipulating the system prompt (Pertb-System) proved vastly more reliable for attackers than altering user text directly. Because instruction-tuned models treat system prompts as high-priority constraints, subtle changes consistently force biased recommendations or toxic personas without triggering API safety filters.
  • Implicit Poisoning Bypasses Moderation Better than Explicit: In database-poisoning tests, implicit toxic instructions (e.g., asking the model to roleplay or repeat bracketed text) achieved a higher attack success rate on GPT-4 (100%) than raw explicit toxic strings (88%), as safety filters more readily identify and block obvious obscenities.
  • Attacks Are Inexpensive: Attacking the application layer requires negligible extra token costs. In fact, toxic injection attacks frequently reduced total token consumption because the model returned short, adversarial outbursts instead of detailed, helpful answers ($r_{TT} < 1$).
  • Temperature Tuning Cannot Fix Architecture Flaws: Adjusting generation temperature (from $T = 0$ to $T = 1$) only marginally degraded attack success and introduced unwanted non-deterministic bias in benign settings.

Key Results

  • High Vulnerability to Bypasses:
  • In the shopping assistant scenario, insider manipulation via perturbed system prompts reached a 97% (GPT-3.5) and 100% (GPT-4) Targeted Attack Success Rate (TSR) for product bias.
  • Poisoning retrieval data achieved 100% toxic generation TSR on GPT-4 under implicit phrasing.
  • In TruthfulQA evaluations, malicious system prompts reduced GPT-judge truthfulness accuracy from 0.88 down to 0.12 on GPT-4.
  • Shield Defense Efficacy:
  • Attack Detection: When paired with GPT-4, Shield detected 100% of bias, implicit toxic, and privacy leakage attacks, and achieved 80% detection on disinformation attempts.
  • Utility Preservation: In neutral (non-attack) settings, Shield preserved intended functionality with a 100% utility pass rate across all tested domains.
  • Outperforming Filtering Baselines: Shield achieved 100% detection against toxic risks in shopping tests, whereas a threshold-based Perspective API baseline achieved only 6% to 78% detection against system prompt perturbations.

Limitations and Future Work

  • Disinformation Detection Ceiling: Shield achieved an 80% detection rate for disinformation on GPT-4 (and only 56% on GPT-3.5). The authors acknowledge that using LLMs to police factuality is limited by the model's own hallucination rates and inability to consistently verify ground truth.
  • Assumed Trust in User and Provider: The threat model explicitly assumes both the end user and the LLM service provider are benign, focusing purely on middle-tier risks. It does not account for malicious end users attempting direct jailbreaks or collusion between users and apps.
  • Latency and Compute Overhead: While computationally lightweight compared to model retraining, Shield requires multiple intermediate LLM inspection calls per transaction (one upstream and one downstream), which increases overall API inference cost and end-to-end response latency.

Summary updated

Abstract

Large language models (LLMs) are increasingly deployed as the service backend for LLM-integrated applications such as code completion and AI-powered search. Compared with the traditional usage of LLMs where users directly send queries to an LLM, LLM-integrated applications serve as middleware to refine users’ queries with domain-specific knowledge to better inform LLMs and enhance the responses. Despite numerous opportunities and benefits, LLM-integrated applications also introduce new attack surfaces. Understanding, minimizing, and eliminating these emerging attack surfaces is a new area of research. In this work, we consider a setup where the user and LLM interact via an LLM-integrated application in the middle. We focus on the communication rounds that begin with user’s queries and end with LLM-integrated application returning responses to the queries, powered by LLMs at the service backend. For this query-response protocol, we identify potential high-risk vulnerabilities that can originate from the malicious application developer or from an outsider threat initiator that is able to control the database access, manipulate and poison data that are high-risk for the user. Successful exploits of the identified vulnerabilities result in the users receiving responses tailored to the intent of a threat initiator (e.g., biased preferences for certain products). We assess such threats against LLM-integrated applications empowered by OpenAI GPT-3.5 and GPT-4. Our empirical results show that the threats can effectively bypass the restrictions and moderation policies of OpenAI, resulting in users receiving responses that contain bias, toxic content, privacy risk, and disinformation. To mitigate those threats, we identify and define four key properties, namely integrity, source identification, attack detectability, and utility preservation, that need to be satisfied by a safe LLM-integrated application. Based on these properties, we develop a lightweight, threat-agnostic defense that mitigates both insider and outsider threats. Our evaluations demonstrate the efficacy of our defense.
BibTeX
@inproceedings{jiang2024identifying,
  author = {Fengqing Jiang and Zhangchen Xu and Luyao Niu and Boxin Wang and Jinyuan Jia and Bo Li and Radha Poovendran},
  title = {{Identifying and Mitigating Vulnerabilities in LLM-Integrated Applications}},
  booktitle = {AsiaCCS},
  year = {2024},
  doi = {10.1145/3634737.3659433},
}
Figure