# RCE when removing metadata with ExifTool

GitLab Workhorse passed uploaded files to ExifTool, which evaled DjVu annotation tokens; a crafted file achieved RCE as git user.

- Payout: $20,000
- Severity: critical
- Program: GitLab
- Found by (vendor credit): vakzz
- Found by: vakzz
- Disclosed: 2021-05-14
- CVE: CVE-2021-22204
- Write-up quality: 9/10
- Original: https://hackerone.com/reports/1154542
- Library page: https://bugbountylibrary.com/r/h1%3A1154542
- Tags: area:web domain:web impact:rce kind:bounty platform:hackerone sev:critical technique:parser-differential technique:source-review vuln:command-injection vuln:rce

**Target:** GitLab Workhorse file upload / ExifTool DjVu parser
**Root cause:** ExifTool's DjVu parser evals quoted strings to convert C escape sequences; a backslash-newline bypasses escaping, allowing arbitrary Perl code injection.
**Steps:**
1. Craft a DjVu file with ANTa chunk containing `(metadata (Copyright "\
" . qx{echo vakzz >/tmp/vakzz} . \
" b ") )`
2. Rename file to .jpg and upload via GitLab snippet attachment
3. GitLab Workhorse passes file to ExifTool, which parses DjVu and evals injected Perl
4. Verify /tmp/vakzz created on server
**How found:** Noticed ExifTool used for metadata stripping; searched for eval calls in source; found DjVu ParseAnt evals quoted strings; tested backslash-newline to break out of escaping and inject Perl.
**Exploitation:** Upload crafted DjVu file renamed as .jpg to any GitLab feature that processes images via Workhorse (e.g., snippet attachment). ExifTool evals the injected Perl, executing commands as the git user. For reverse shell, use `qx{...}` with a Perl reverse shell payload.
**Insight:** When reviewing Perl code, look for eval on user-controlled strings; backslash-newline can bypass regex end-of-string anchors, enabling quote escape.

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

**DjVu metadata payload executing qx command**

```
(metadata
	(Copyright "\
" . qx{echo vakzz >/tmp/vakzz} . \
" b ") )
```

**DjVu metadata payload running date command**

```
(metadata
 (Author "\
" . return `date`; #")
)
```

