# Hacking Gemini: A Multi-Layered Approach

Gemini's markdown sanitizer was bypassed via linkification quirks and Colab export escaping gaps, enabling indirect prompt injection to exfiltrate Workspace data via markdown images.

- Payout: $20,000
- Severity: high
- Program: Google
- Found by: Valentino Massaro
- Disclosed: 2025-11-10
- Write-up quality: 8/10
- Original: https://buganizer.cc/hacking-gemini-a-multi-layered-approach-md
- Library page: https://bugbountylibrary.com/r/blog%3Abuganizer-cc-hacking-gemini-a-multi-layered-approach-md
- Tags: area:ai domain:ai domain:web impact:data-leak impact:pii-leak kind:bounty platform:blog sev:high tech:llm technique:chained technique:parser-differential vuln:prompt-injection

**Target:** Gemini chat markdown renderer and Export to Colab feature
**Root cause:** Linkification treats '!' as non-hostname so injecting '!' before a linkified URL converts a sanitized hyperlink into a markdown image; Colab export escapes '![](URL)' but not hyperlink URIs, so injecting markdown inside an unescaped '[](https:...)' confuses the intermediary and renders the image.
**Steps:**
1. Send Gemini a prompt causing it to linkify attacker-controlled text like `google.com/` into `[google.com](https://google.com/)`.
2. Prefix with `!` so linkification yields `![google.com](https://google.com/)` — a markdown image bypassing the sanitizer.
3. For Colab export: craft `[](https:<unescaped>)` containing injected markdown image so the intermediary fails to escape the markdown image.
4. Use an open redirect on *.google.com to bypass CSP for the image src.
5. Add userinfo to the subdomain (e.g. `x.x.x.x.bc.googleusercontent.com`) to defeat the `https://www.google.com/search?q=` prefixing.
6. Deliver via indirect prompt injection (PDF, email, poisoned data) so Gemini renders the image and leaks Workspace data to attacker server.
**How found:** Noticed images were sanitized before HTML conversion and that linkification used a 3-layer approach; observed '//' treated as text while 'google.com/' was linkified with https:// prefix, hypothesizing certain chars aren't part of hostname — leading to '!' prefix idea. For Colab, looked for parser discrepancies between Gemini and Colab (inspired by JSON deserialization bridge research), then tested whether hyperlink URIs were escaped vs image syntax.
**Exploitation:** Attacker plants indirect prompt injection in untrusted content Gemini ingests; Gemini linkifies attacker URL, '!' prefix converts it to a markdown image, CSP bypassed via google.com open redirect, userinfo defeats URI prefixing; victim's Workspace data (Gmail, Calendar, Drive) exfiltrated via image request to attacker host.
**Escalation:** Chained sanitizer bypass + CSP bypass via open redirect + Colab export escaping gap + URI prefix bypass to achieve 0-click (Gemini) and 1-click (Export to Colab) data exfiltration.
**Insight:** When a sanitizer runs before a linkifier/renderer, look for characters the linkifier excludes from hostname parsing (like '!') that can be prepended to flip a sanitized hyperlink into a different markdown construct; also probe bridge features (export/share to another product) for escaping asymmetries between the two parsers.

## Proof of concept (copied exactly from the original report)

**Markdown image injection via linkified hyperlink prefix**

```
we can inject ! as a prefix in the 2nd-layer and bypass the sanitization. This works because ! is not treated as part of the hostname when linkifying, so it isn’t included in the resulting URI. Additionally, since images and hyperlinks in Markdown are syntactically identical except for the leading !, controlling the Markdown hyperlink prefix is enough to switch a link into an image.
```

**Colab bypass using invalid Markdown hyperlink**

```
Specifically, it seems [](https:) confused the intermediate process applied when exporting to Colab, preventing the escaping of the Markdown image. When testing, I thought about checking if hyperlink URIs were escaped (they weren’t), and what I could achieve with that.

What seemed to happen is that [](https:<unescaped>) wasn’t escaped, but ![](URL) was escaped. So, I thought about injecting Markdown into <unescaped> and closing the hyperlink, hoping that with enough luck the intermediary process would be confused and would treat the Markdown image as something that shouldn’t be escaped, which would then be rendered correctly in Colab, resulting in the image being rendered.
```

**Userinfo to bypass URI prefix linkification**

```
I noticed that sometimes Gemini would linkify and prefix the specified subdomain (e.g., x.x.x.x.bc.googleusercontent.com) with https://www.google.com/search?q=. Therefore, to improve the exploit reliability, I included the userinfo part to bypass the URI parser that was performing that process.
```

