# SSRF on project import via the remote_attachment_url on a Note

Project import failed to strip CarrierWave's remote_attachment_url on Note, letting an attacker make GitLab fetch arbitrary internal URLs and attach the response.

- Payout: $10,000
- Severity: high
- Program: GitLab
- Found by: vakzz
- Disclosed: 2020-06-07
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/826361
- Library page: https://bugbountylibrary.com/r/h1%3A826361
- Tags: area:web domain:web impact:data-leak impact:internal-access impact:rce kind:bounty platform:hackerone sev:high tech:ruby technique:chained technique:source-review vuln:ssrf

**Target:** GitLab project import (Note model attachment uploader)
**Root cause:** AttributeCleaner on project import did not remove CarrierWave seed attributes like remote_attachment_url and remote_attachment_request_header, so mount_uploader's remote_urls= triggered a server-side download of attacker-controlled URLs.
**Steps:**
1. Create project, issue, and a note; export the project
2. Extract export and edit project.json to add `remote_attachment_url` (and optionally `remote_attachment_request_header`) to the note hash
3. Recompress and import the project
4. View the note on the issue to read the fetched response
**How found:** Code reading: noticed Note mounts AttachmentUploader, recalled CarrierWave's remote_*_url seed feature, then checked AttributeCleaner and found it doesn't strip those attributes on import.
**Exploitation:** Attacker crafts a malicious project export and imports it (or tricks a victim into importing). CarrierWave's Kernel.open fetches the URL server-side; the response is attached to the note and viewable, exfiltrating internal service responses. Custom headers via remote_attachment_request_header enable GCP metadata (Metadata-Flavor: Google) and Redis payload delivery.
**Escalation:** Chain to internal services: Prometheus/Alertmanager on localhost, AWS instance metadata, GCP metadata via header, and potential Redis RCE by smuggling payload through a request header.
**Insight:** When auditing import/export features, enumerate every model attribute that maps to a framework 'magic' setter (CarrierWave remote_*_url, Paperclip, etc.) and verify the import sanitizer's denylist covers them—framework seed attributes are a recurring SSRF vector.

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

**Add remote_attachment_url to note in project.json**

```
Add  `remote_attachment_url` to the `note` hash with a url
1. Recompress the export and import it
```

