# My first bug in Google Cloud: Command injection in Vertex AI

Unescaped image URI in Vertex AI prompt 'Get code' feature allowed command injection into generated shell/Python code, yielding arbitrary command execution if victim ran it.

- Payout: $3,134
- Severity: high
- Program: Google
- Found by: Valentino Massaro
- Disclosed: 2025-07-01
- Write-up quality: 6/10
- Original: https://blog.3133700.xyz/bug_vertex_ai
- Library page: https://bugbountylibrary.com/r/blog%3Ablog-3133700-xyz-bug-vertex-ai
- Tags: area:ai domain:ai domain:cloud impact:rce kind:bounty platform:blog sev:high tech:llm technique:source-review vuln:command-injection

**Target:** Google Cloud Vertex AI prompt management / 'Get code' code generation feature
**Root cause:** The 'Get code' generator interpolated the user-supplied image fileUri into generated shell/Python code without escaping, so a crafted URI containing shell metacharacters broke out of the heredoc.
**Steps:**
1. Open Vertex AI 'Create a prompt' feature.
2. Add an image part with fileUri set to `http://www.google.com/"\nEOF\nid\n<< EOF\n-`.
3. Use 'Get code' to generate shell code; observe injected `id` command breaks out of the `cat << EOF` heredoc.
4. Alternatively export a prompt JSON, edit the fileData.fileUri with the payload, and re-import via prompt management to trigger the same injection.
**How found:** Researcher targeted Google main products after reading VRP rewards and LLM-protection research; tested 'Create a prompt' and 'Get code', noticed inputs were escaped in normal fields, then hypothesized the image URI field might be missed and tried injecting shell metacharacters into fileUri.
**Exploitation:** Attacker crafts a prompt (or imports a malicious prompt JSON) whose image fileUri contains heredoc-breaking shell metacharacters; when the victim copies the generated 'Get code' shell/Python snippet and runs it, the injected commands execute on the victim's machine.
**Escalation:** Extended from manual chat input to file-import via prompt management export/import JSON, removing the need for the victim to paste content directly into chat.
**Insight:** When a feature generates code from user-controlled fields, test every field individually—especially less-obvious ones like image/file URIs—for escaping gaps; export/import JSON flows often let you inject the same payload without manual chat interaction.

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

**Image URI command injection payload**

```
http://www.google.com/"\nEOF\nid\n<< EOF\n-
```

**Generated shell code with injected id**

```
cat << EOF \> request.json
{
 "contents": [
 {
 "role": "user",
 "parts": [
 {
 "fileData": {
 "mimeType": "image/jpeg",
 "fileUri": "http://www.google.com/"
EOF
id
<< EOF
-"
```

**Prompt import JSON with injected fileUri**

```
{
 <..>
 "type": "multimodal_freeform",
 "prompt": {
 "parts": [
 {
 "fileData": {
 "mimeType": "image/jpeg",
 "fileUri": "http://www.google.com/\"\nEOF\nid\n<< EOF\n-"
```

