# Arbitrary file read via the UploadsRewriter when moving and issue

UploadsRewriter copied issue uploads without validating the filename, so a markdown reference with `../` traversal let an attacker read arbitrary server files.

- Payout: $20,000
- Severity: critical
- Program: GitLab
- Found by: vakzz
- Disclosed: 2020-04-27
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/827052
- Library page: https://bugbountylibrary.com/r/h1%3A827052
- Tags: area:web domain:web impact:data-leak impact:internal-access kind:bounty platform:hackerone sev:critical tech:ruby technique:source-review vuln:path-traversal

**Target:** GitLab issue move / UploadsRewriter markdown upload reference
**Root cause:** MARKDOWN_PATTERN captures the `file` portion of `/uploads/<secret>/<file>` and passes it to `retrieve_from_store!` without sanitizing path traversal sequences, so `../` escapes the uploads directory.
**Steps:**
1. Create two projects.
2. Add an issue with description `![a](/uploads/11111111111111111111111111111111/../../../../../../../../../../../../../../etc/passwd)`.
3. Move the issue to the second project.
4. The referenced file (e.g. /etc/passwd) is copied into the target project's uploads and readable.
**How found:** Code reading of UploadsRewriter: noticed MARKDOWN_PATTERN captures `file` as `.*?` and find_file passes it unsanitized to retrieve_from_store!, hypothesizing traversal via the captured filename.
**Exploitation:** Attacker with issue-creation rights crafts a markdown image reference whose secret is any 32-hex string and whose file path traverses out of the uploads store; moving the issue triggers UploadsRewriter to copy the traversed file into the destination project, where the attacker downloads it.
**Insight:** When a regex captures a path segment that later feeds a storage/uploader API, test whether the capture allows `../`; issue-move/copy features that re-fetch referenced uploads are prime traversal sinks.

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

**Markdown payload with path traversal to /etc/passwd**

```
![a](/uploads/11111111111111111111111111111111/../../../../../../../../../../../../../../etc/passwd)
```

