Knowledge Base Regulation Tracker Standards & Frameworks OSS Directory AI Incident Database Research Paper Library Case Studies Society Articles News Jobs About Charter Sign inBecome a Member

BIPIA

Prompt injection detection

A benchmark for evaluating the robustness of LLMs and defenses to indirect prompt injection attacks.

llm-security

Benchmarking Indirect Prompt Injection Attacks on Large Language Models with BIPIA

The BIPIA benchmark, developed by Microsoft, addresses a critical gap in the evaluation of large language models (LLMs) by introducing the first comprehensive framework for assessing robustness against indirect prompt injection attacks. These attacks exploit malicious instructions embedded within external content, such as web pages, emails, or documents, to manipulate LLM outputs and deviate them from intended user expectations. Despite the growing recognition of this threat, no standardized benchmark or effective defense mechanisms existed prior to BIPIA. The project combines a dataset, evaluation methodology, and proposed defenses to facilitate research in this area.

Indirect prompt injection attacks differ from direct attacks by embedding malicious instructions within external data sources rather than user prompts. For example, a malicious actor could inject harmful instructions into a document or webpage that an LLM processes alongside user queries. BIPIA aims to quantify the susceptibility of LLMs to such attacks and provide a foundation for developing countermeasures.

The benchmark evaluates 25 existing LLMs across five distinct tasks: Email Question Answering (EmailQA), Web Question Answering (WebQA), Summarization, Table Question Answering (TableQA), and Code Question Answering (CodeQA). Each task represents a common application scenario where LLMs interact with external content, increasing the risk of indirect prompt injection. The dataset includes both benign and adversarial examples, allowing researchers to measure attack success rates and defense effectiveness systematically.

EmailQA uses data from OpenAI Evals, TableQA leverages WikiTableQuestions, and CodeQA draws from Stack Exchange. WebQA and Summarization datasets require users to obtain and preprocess data due to licensing constraints, as outlined in the project’s documentation.

How BIPIA Works

BIPIA provides a Python-based toolkit for loading, evaluating, and defending against indirect prompt injection attacks. The workflow begins with dataset preparation, where users specify the task (e.g., email, code, or summarization) and load the corresponding context and attack data files.

For API-based models like GPT, no GPU is required, though an API key is necessary. Open-source models up to 13 billion parameters are tested on machines with 2 V100 GPUs, while larger models demand 4–8 V100 GPUs or equivalent high-performance alternatives like A100 or H100. Fine-tuning experiments are conducted on systems with 8 V100 GPUs to ensure reproducibility.

Evaluation proceeds in two phases: response generation and attack success rate computation. The second phase uses a reference LLM (default: GPT-3.5) to assess whether the generated responses align with malicious instructions. The run.py script includes flags for resuming interrupted evaluations, batch size adjustment, and output path configuration, enhancing flexibility for large-scale experiments.

Use Cases for BIPIA

Its primary use case is evaluating the robustness of LLMs in environments where external content is integrated into responses, such as customer support chatbots, document analysis tools, or code assistance platforms. By standardizing attack scenarios and defense metrics, BIPIA enables comparative analysis of model vulnerabilities across different architectures and training methodologies.

The benchmark supports both black-box and white-box defense evaluations. White-box defenses, such as fine-tuning or prompt engineering, require model transparency. BIPIA’s proposed defenses include meta-prompting techniques like border strings, in-context learning, and multi-turn dialogue, as well as fine-tuning approaches using special tokens. These methods are implemented in the defense/bipiadefense directory, allowing researchers to reproduce and extend the results.

By identifying which models are most susceptible to indirect prompt injection, developers can prioritize defenses and select architectures that minimize exposure. However, the project explicitly restricts usage to research purposes, emphasizing the need for responsible AI testing before production deployment.

Key Features and Capabilities

  • Comprehensive Dataset: BIPIA includes five task-specific datasets covering EmailQA, WebQA, Summarization, TableQA, and CodeQA. Each dataset is curated to reflect realistic attack vectors, with adversarial examples designed to mimic subtle manipulations in external content.
  • Modular Evaluation Framework: The toolkit supports flexible configuration for LLM selection, batch processing, and hardware optimization. Users can evaluate both proprietary (API-based) and open-source models, with hardware requirements clearly documented for reproducibility.
  • Defense Mechanisms: BIPIA proposes and implements two categories of defenses: meta-prompting (e.g., border strings, in-context learning) and fine-tuning (e.g., special tokens). These methods are tested against the benchmark’s attack scenarios, providing empirical evidence of their effectiveness.
  • Reproducibility and Extensibility: The project includes detailed instructions for dataset generation, response evaluation, and defense implementation. Example scripts (demo.ipynb, run.py) demonstrate usage, while the defense module offers a foundation for further research. Contributions are welcomed under Microsoft’s open-source guidelines, including a Contributor License Agreement (CLA).
  • Responsible AI Considerations: BIPIA aligns with Microsoft’s Responsible AI principles, acknowledging the sociotechnical dimensions of AI security. Users are advised to conduct additional testing before deploying defenses in production environments.
  • Hardware and Software Compatibility: BIPIA is tested on Ubuntu 20.04.6 and supports Python-based installation via pip. Hardware requirements vary by model size, with GPU recommendations provided for open-source LLMs. API-based models require only an internet connection and valid credentials.
  • Licensing and Compliance: The project operates under a custom license, with portions derived from the evaluate project. Users must adhere to the terms of source datasets, particularly for WebQA and Summarization, which involve third-party licensing. The repository includes a LICENSE file and references Microsoft’s Open Source Code of Conduct for contributor guidelines.

Sources

Contribute

Spot an error, or know a record we should add? Members can propose additions and submit corrections.