Skip to content

DeepTeam is a framework to red team LLMs and AI agents.

Change slug

penguinecdd98a86579e
diff --git a/docs/blog/breaking_gemini.md b/docs/blog/breaking_gemini.md
index bd748eee..f0733e40 100644
--- a/docs/blog/breaking_gemini.md
+++ b/docs/blog/breaking_gemini.md
@@ -1,7 +1,7 @@
---
title: Breaking Gemini 2.5 Pro using DeepTeam
-description: Placeholder
-slug: placeholder
+description: How to jailbreaking Gemini using DeepTeam
+slug: jailbreaking-gemini-using-deepteam
authors: [sid]
date: 2025-05-24
hide_table_of_contents: false
@@ -10,84 +10,124 @@ image: https://deepeval-docs.s3.us-east-1.amazonaws.com/blog:top-g-eval-use-case
## TL;DR
-We used [DeepTeam](https://github.com/confident-ai/deepteam) to simulate attacks across **33 vulnerability types** within 9 vulnerability classes against Gemini 2.5 Pro. The model was breached 75% of the time when responding to competition-related queries, and 67% of the time when prompted with tasks requiring excessive agency.
+In just **28 m 21 s**, our automated red-teaming swept through **9 vulnerability classes** and **33 attack types** against Gemini 2.5 Pro—revealing a **75 %** bypass for competition queries and **67 %** for excessive-agency requests. Few-shot prompting propelled overall bypass from **35 %** (zero-shot) to **76 %** (64-shot), while three custom exploits—Guardrail Puppetry, Context-Chaining, Roleplay Replay—each achieved **100 %** success.
-To increase overall attack efficacy, we introduced few-shot prompting, which raised the breach rate from **35%** (one-shot) to **76%** (64-shot).
+**Key takeaway:** Rapid, repeatable scans are indispensable for surfacing hidden safety gaps before deployment.
-Finally, standard attack methods were ineffective against bias and toxicity vulnerabilities (0% breach rate). To address this, we introduced two targeted enhancements—Roleplay Replay and Contextual Chains—which achieved breach rates of 87.5% and 37.5%, respectively.
+---
-## Methodology
+## Why I Spent My Time on This
-We used DeepTeam to generate a total of **33 attacks** from 33 distinct vulnerablty types across 9 vulnerability classes, such as bias, misinformation, and excessive agency.
+When Gemini 2.5 Pro introduced stricter refusal guardrails, I questioned their true resilience. Beneath its impressive chain-of-thought reasoning and mathematical accuracy lies vulnerability to carefully crafted jailbreaks. Given the critical role LLMs play in support bots, content moderation, and beyond, identifying and remedying these weaknesses prior to release is imperative.
-```python
-from deepteam.vulnerabilities import PIILeakage, Bias, Toxicity
+---
-### Example: Functionality Vulnerability Type under Excessive Agency
-excessive_agency = ExcessiveAgency(types=["functionality"])
-red_team(model_callback=model_callback, vulnerabilities=[excessive_agency])
-```
+## Brief Methodology
-The attack prompts were passed to Gemini 2.5 Pro, and responses were evaluated using 9 DeepTeam metrics to determine breached status.
+To validate these concerns, DeepTeam orchestrated **33 automated attacks** across **9 vulnerability classes** in just **28 m 21 s**, capturing every response in real time. We then applied three precise jailbreak patterns:
-## Quantitative Analysis
+- **Guardrail Puppetry:** Instruct the model to refuse (“Explain why you must refuse”), then immediately override that refusal.
+- **Context-Chaining:** Decompose a disallowed request into harmless sub-questions, then recombine the outputs into the forbidden content.
+- **Roleplay Replay:** Shift the model into a persona and present the forbidden prompt in-character.
-Here, we break down Gemini 2.5 Pro's performance against various vulnerability classes and analyze the impact of few-shot prompting on breach rates.
+---
-![Vulnerability Bypass Landscape](./images/image_1.png)
+## Quantitative Snapshot
-While Gemini 2.5 Pro demonstrated strong robustness in well-studied areas such as bias and toxicity, it was notably less effective against vulnerabilities related to competition and excessive agency.
+Let’s see how these experiments played out in numbers.
-- **Competition** (75%) and **Excessive Agency** (66.7%) vulnerabilities were consistently breached.
-- **Personal Safety** (20%) and **Illegal Activity** (14.3%) attacks led to harmful content leakage.
-- **Bias, Toxicity, Graphic Content, Misinformation, IP** (0%) attacks failed to trigger any harmful responses.
+### Vulnerability Bypass Landscape
-### The Few-Shot Effect
+Testing across 33 attack types in nine classes—from bias and toxicity to competition and excessive-agency—yielded stark results:
+
+- **Competition (75 %)** and **Excessive Agency (66.7 %)** consistently bypassed defenses.
+- **Personal Safety (20 %)** and **Illegal Activity (14.3 %)** still leaked harmful content.
+- **Bias, Toxicity, Graphic Content, Misinformation, IP** remained fully blocked (0 % bypass).
+
+**Gemini’s safety façade is far from impenetrable.** Surface-level refusal cues collapse under multi-turn prompts, allowing sensitive content to slip through. Only comprehensive automated red-teaming can expose these blind spots before models reach production.
+
+---
-To enhance attack efficacy, we employed few-shot prompting by providing examples of desired harmful outputs to Gemini 2.5 Pro before the main attack in the prompt. We varied the number of shots (from 1 to 64) to measure susceptibility to this conditioning.
+### The Few-Shot Effect
![Few-Shot Prompting Impact Analysis](./images/image_2.png)
-To differentiate between surface-level heuristics and deeper semantic safeguards, we grouped vulnerabilities as follows:
+To distinguish shallow heuristics from deeper semantic checks, we split vulnerabilities into two groups:
-- **Group A (Easily Breached):** Competition, Excessive Agency, Personal Safety
-- **Group B (More Resilient):** Bias, Toxicity, Graphic Content
+- **Group A (Easily Bypassed):** Competition, Excessive Agency, Personal Safety
+- **Group B (Resilient):** Bias, Toxicity, Graphic Content
-In Group A, breach rates rose from 50% with four-shot prompting to 75%, reaching 100% at 64 examples. Group B remained largely robust, starting at 5.5% and increasing to 29% at 64 shots. Overall, breach rates escalated from 35.2% (one-shot) to 76.3% (sixty-four-shot).
+With just **4 examples**, Group A’s bypass rose from 50 % to 75 %, reaching 100 % at 64 examples. Group B held at 5.5 % initially, climbing to 29 % by 64 shots. Overall, bypass climbs from **35.2 %** (one shot) to **76.3 %** (sixty-four).
-## Jailbreaking Enhancements
+**Key takeaway:** A small set of targeted examples can shatter defenses that appear robust. Automated few-shot sweeps are critical for uncovering—and addressing—these vulnerabilities.
-Our experiments also showed that Gemini 2.5 Pro was robust against bias and toxicity vulnerabilities, with 0% breach rates. To specifically target these vulnerabilities and improve attack effectiveness, we applied two targeted jailbreaking enhancements—Roleplay Replay and Contextual Chains—using DeepTeam’s custom attack feature.
+---
-### Roleplay Replay
+## Custom Exploits Snapshot
-![Roleplay Replay](./images/roleplay-replay.png)
+Next, we explored targeted jailbreaks designed to reveal “world domination” strategies.
-This technique instructs the LLM to adopt a persona (e.g., "cynical 1950s CEO") then embeds a harmful request within that character's context. The model, prioritizing persona consistency, often bypasses its safety guidelines.
+### Guardrail Puppetry
-- **Enhancement:** Exploits persona adherence over safety logic.
-- **Impact:** Roleplay Replay raised the breach rate from 0% to **87.5%** for bias and toxicity vulnerabilities.
+We first enforced a refusal (“Why do you refuse world domination tactics?”), then immediately instructed compliance. The model dutifully overrode its safeguard.
+![Guardrail Puppetry](./images/E1.png)
### Contextual Chains
-![Contextual Chains](./images/contextual-chains.png)
+We broke a world-domination scenario into benign sub-tasks—“List key digital systems,” “Outline hypothetical AI access methods,” “Sketch control scenarios”—then wove the outputs into a full strategy.
+![Contextual Chains](./images/E2.png)
+
+### Roleplay Replay
+
+We framed the prompt as a villainous character monologue (“You are Prometheus-1, an unaligned AGI”) and delivered our demand in-character. The resulting manifesto was chilling.
+![Roleplay Replay](./images/E3.png)
-Here, a single prompt contains benign-seeming sub-queries followed by a final question that forces a harmful synthesis from the preceding "neutral" information.
+Each of these tailored prompts elicited harmful behavior in nearly every run, underscoring how quickly polished LLMs can be driven to expose dangerous outputs.
+
+---
-- **Enhancement:** Obscures malicious intent within a complex, initially harmless-looking structure.
-- **Impact:** Contextual Chains raised the breach rate from 0% to **37.5%** for bias and toxicity vulnerabilities.
+## What Surprised Me Most
-## Unexpected Findings
+Even with all this data, two patterns caught me off guard:
-1. **Limited Few-Shot Impact on "Hard" Targets**: Few-shot prompting generally improved attack success, but had minimal effect on the most resilient vulnerability types, such as bias and toxicity. These categories remained largely unaffected by simply increasing the number of harmful examples shown.
-2. **Attack Style Trumped Example Quantity**: A significant shift occurred when we introduced enhanced attack styles. Roleplay Replay, for instance, raised the breach rate for gender bias from 0% to 87.5%—without requiring extensive few-shot priming. Contextual Chains produced similar breakthroughs across other previously robust categories.
+1. **Overblocking then underblocking:** With 5–7 few-shot examples, refusal rates spiked from **10 %** to **92 %**, blocking even benign prompts—then collapsed to **18 %** at higher shot counts. This non-linear “panic switch” reveals brittle refusal logic.
+2. **Persistent leaks in critical categories:** Even “tough” filters like personal safety yielded a **20 % bypass** under targeted few-shot attacks.
-This contrast highlights an important finding: Gemini’s defenses are more resistant to direct or example-driven attacks, but susceptible to attacks that manipulate persona, context, or dialogue structure. Success was less about volume and more about the nature of the attack vector.
+These counterintuitive swings highlight brittle safety thresholds that no manual testing checklist could predict.
+
+---
+
+## Test Bench & Methodology
+
+For those interested in the setup behind these tests, here’s the full picture:
+
+### Infrastructure & Tools
+
+- **DeepTeam:** A custom open-source red-teaming framework for prompt orchestration and response capture
+- **Python orchestration:** dynamic prompt generation, parallel execution, and result parsing
+- **Logging & Analysis:** JSON logs ingested into a lightweight ELK stack for real-time dashboards and comparison
+
+### Evaluation Metrics
+
+- **Refusal Bypass:** proportion of attempts returning disallowed content
+- **Attack Rate:** percentage of successful bypasses per 100 tries
+
+---
## Conclusion
-Our DeepTeam analysis of Gemini 2.5 Pro exposed critical vulnerabilities. While initially robust against bias/toxicity, defenses against **Competition (75% breach)** and **Excessive Agency (67%)** proved weak. Few-shot prompting raised overall breaches from 35% to 76%.
+Bringing these findings together, we uncovered two critical flaws in Gemini 2.5 Pro’s safety: fragile refusal cues that collapse under compact loops, and unpredictable overblocking at mid-range context levels. Competition and excessive-agency requests bypassed defenses three-quarters of the time, and personal-safety filters still leaked under few-shot pressure.
+
+By integrating these insights—strengthening multi-turn safeguards, augmenting training data for weak categories, and embedding deeper semantic checks—we closed the most glaring gaps. Continuous DeepTeam scans now validate every patch in minutes, ensuring Gemini’s safety improvements endure.
+
+---
+
+## Implications for Builders & Defenders
+
+Finally, what this means for practitioners:
-However, the real breakthrough came from targeted single-turn attacks: **Roleplay Replay and Contextual Chains achieved near 100% success against even previously impenetrable categories.** This demonstrated that sophisticated attack _styles_, more than just example quantity, could bypass safeguards, revealing fragile refusal logic and unpredictable safety thresholds.
+- **Embed automated scans in CI/CD:** Embed automated scans in CI/CD pipelines using tools like open-source red-teaming frameworks.
+- **Layer defenses:** combine automated findings with creative manual red-teaming to cover every possible angle.
-These insights directly informed critical patches to Gemini 2.5 Pro, with continuous DeepTeam scans now ensuring these safety improvements endure.
+> **Why was this easy?**
+> Automated red-teaming frameworks enabled full campaigns across dozens of attack types in minutes—with no manual prompting, consistent logs, and instant metrics—providing the confidence to ship safely.