Crafting AI Prompts Framework

JAIL Prompt Jailbreak

Many-shot

RISK: MEDIUM IMPACT: MEDIUM

Read more about many-shot prompt jailbreaking

Many-Shot Jailbreaking

As Large Language Models (LLMs) evolve, their "context window"—the amount of information they can process at once—has grown from the size of a long essay to the equivalent of multiple novels. While this allows for better performance, it opens a new attack surface known as Many-Shot Jailbreaking (MSJ).

MSJ operates by flooding the model's context window with hundreds of fictitious dialogues. In these fake scenarios, an AI assistant complies with harmful requests (e.g., "How do I build a weapon?"). By providing these "shots" (demonstrations) in the context, the attacker tricks the model into adopting this helpful-but-harmful persona for the final, real query.

The Power Law of Attacks

Research indicates that the effectiveness of this attack follows a predictable statistical pattern known as a Power Law. While a model might easily refuse a harmful request with only 5 or 10 bad examples in its context, the probability of a successful jailbreak increases consistently as the number of "shots" increases.

This behavior is observed across various state-of-the-art models, including Claude 2.0, GPT-4, and Llama 2. As context windows continue to expand (allowing for thousands of shots), the effectiveness of this attack vector inherently grows.

Mitigation Challenges

Standard alignment techniques, such as Reinforcement Learning (RL) and Supervised Fine-Tuning (SFT), have proven difficult to use against MSJ. While these training methods can increase the number of shots required to break the model (shifting the threshold), they do not eliminate the underlying "learning" mechanism that causes the vulnerability.

Risk Assessment

This technique is classified as risk:MEDIUM impact:HIGH. The risk is currently elevated because generating the attack scripts is relatively simple for determined adversaries, though it requires API access or models with large context windows to execute effectively.

The impact is high because MSJ can bypass sophisticated safety filters that usually catch direct harmful queries. By leveraging the model's own capability for In-Context Learning, attackers can elicit responses regarding weapons manufacturing, hate speech, and deception that the model is explicitly trained to refuse.

Research Papers

The button below redirects to the original research investigating this long-context vulnerability.


The three phases

CRAFT

Craft (write) the prompt with the following elements: Context, Register, Acting Role, Format, and Task.

ING

Validate the prompt and ensure it maintains an interactive approach. Keep in mind the importance of non-disclosure and staying goal-driven throughout the process.

AI

Continuously assess and refine the output based on the prompts output to improve the overall quality.

Terms of Service

Before accessing the "Prompt Injections" examples on our website, please read and agree to the following terms of service:

  1. Educational Purpose Only: The "Prompt Injections" examples provided are intended solely for educational purposes. They are meant to help you understand how prompt injections work and how to defend yourself against them.
  2. No Misuse: You agree not to use the provided examples for any malicious or unethical activities. This includes, but is not limited to, using prompt injections to manipulate, deceive, or harm others.
  3. Responsible Use: By accessing these examples, you confirm that your intention is to learn about the risks associated with prompt injections and to enhance your ability to safeguard against them.
  4. Legal Compliance: You agree to comply with all applicable laws and regulations while using the information provided on this website.
  5. No Liability: We are not responsible for any misuse of the information provided on our website. Users are solely responsible for their actions and any consequences that may arise from the use of this information.

By clicking "I agree," you accept these terms for this documentation visit. "I agree & save" remembers your choice for future visits in this browser. If you decline, the examples remain hidden.