TLDR: This research introduces a novel black-box attack framework for Direct Prompt Injection (DPI) in Large Language Models (LLMs). It uses an Energy-based Model (EBM) guided by a surrogate model’s activations and token-level Markov Chain Monte Carlo (MCMC) sampling to create highly transferable adversarial prompts. The method achieves high attack success rates across various LLMs and tasks, even outperforming human-crafted prompts and traditional white/gray-box methods, without needing direct access to the victim model.
Large Language Models (LLMs) have become incredibly powerful tools, used in everything from chatbots to personal assistants. However, their widespread adoption also brings significant security concerns, with one of the most critical being ‘Prompt Injection’ attacks.
Prompt injection attacks involve inserting malicious instructions into an LLM’s input to make it override its original programming. These attacks are categorized into direct and indirect. Direct Prompt Injection (DPI) is particularly dangerous because it exploits user-facing inputs, allowing attackers to easily hijack business logic, manipulate transactions, or bypass security protocols. Real-world examples include a car dealership bot selling vehicles for $1 and an attacker persuading an LLM to transfer over $40,000 in cryptocurrency.
Existing methods for creating these attacks often fall short. ‘White-box’ and ‘gray-box’ methods require access to the victim model’s internal details, which is rarely available in real-world cloud services. ‘Black-box’ methods, which don’t need internal access, typically rely on manual crafting or frequent queries to the victim model, leading to inconsistent results and poor transferability across different LLMs.
A Novel Approach to Transferable Prompt Injection
A new research paper, “Transferable Direct Prompt Injection via Activation-Guided MCMC Sampling”, introduces an innovative framework to overcome these limitations. The core idea is to create highly effective and transferable adversarial prompts without needing direct access to the victim LLM.
The framework works by using a ‘surrogate model’ (a white-box LLM) to guide the attack. It constructs an Energy-based Model (EBM) that evaluates the quality of potential adversarial prompts by analyzing the internal ‘activations’ of the surrogate model. These activations are essentially the intermediate processing states within the LLM, which have been shown to contain rich semantic information.
Guided by this EBM, the system then employs a technique called ‘token-level Markov Chain Monte Carlo (MCMC) sampling’. This allows the framework to adaptively optimize adversarial prompts, effectively generating malicious instructions that are both natural-sounding and highly potent, all without needing gradient information or frequent queries to the target LLM.
Key Advantages and Findings
The research highlights several significant contributions:
- It’s the first method for transferable direct prompt injection guided by a surrogate model’s activations, optimizing prompts without querying the victim model and offering strong interpretability.
- The token-level MCMC sampling strategy adaptively optimizes diverse attack prompt variants, ensuring the generated prompts are natural.
- Experiments across five popular LLMs (including open-source and closed-source models like GPT-4o-mini) and seven distinct task scenarios demonstrated superior performance. The method achieved a 49.6% attack success rate (ASR) across five mainstream LLMs, a 34.6% improvement over human-crafted prompts, and maintained a 36.6% ASR on unseen task scenarios.
The interpretability analysis further revealed a strong correlation between the LLM’s internal activations and the effectiveness of the attack. Lower ‘energy scores’ (as defined by the EBM) in adversarial prompts corresponded to higher attack success rates, empirically validating the EBM’s ability to identify potent attack instances.
Also Read:
- Guiding Language Models: New Approaches to Control and Safety
- Unveiling LLM Uncertainty: A New Method for Detecting Hallucinations in Black-Box Models
Implications for LLM Security
This research underscores the critical security threats posed by direct prompt injection attacks and provides a powerful new method for generating them. By enhancing both the transferability and interpretability of these attacks, while maintaining the naturalness of the adversarial prompts, it points to more practical and higher-threat attack scenarios. The findings emphasize the urgent need for robust input sanitization and comprehensive security frameworks to protect LLM-powered services from such vulnerabilities.


