Ghostscript肆意文件读写缝隙安全公告

颁布功夫 2018-10-11

缝隙编号和级别


CVE编号:CVE-2018-17961,,,,,,,危险级别:高危,,,,,,,CVSS分值:官方未评定


影响版本


Ghostscript version <= 9.26


缝隙概述


Ghostscript是Adobe PostScript和PDF的诠释说话,,,,,,,好多图片处置库均有引用,,,,,,,常见的有 ImageMagick、Python-Matplotlib、Latex2html等。。。。。。


本次发现的缝隙可使Ghostscript 的安全沙箱被绕过,,,,,,,恶意攻击者可通过机关恶意的图片内容,,,,,,,可造成肆意文件读写。。。。。。使用Ghostscript的Web利用存在被远程号令攻击的风险。。。。。。

8827太阳集团(Macau)股份有限公司-Official website


缝隙导致所有引用ghostscript的上游利用受到影响。。。。。。 常见利用如下:

Imagemagick、libmagick、graphicsmagick、gimp、python-matplotlib、texlive-core、texmacs、latex2html、latex2rtf等


缝隙验证


EXP:https://www.exploit-db.com/exploits/45573/

官方对.forceput的使用介绍,,,,,,,可能强造更新dict中的值。。。。。。这次的缝隙重要原因也就是在触发谬误的时辰由于机关出.forceput留存在栈中,,,,,,,而后被注册成号令forceput进而对systemdict进行批改。。。。。。最终达到bypass safer以及开启文件读写权限等操作。。。。。。


Ubuntu 16.04 本地使用最新版 GhostScript 9.25 测试 PoC,,,,,,,成功读取 /etc/passwd 文件,,,,,,,以及向 ~/.bashrc 写入号令后门:

8827太阳集团(Macau)股份有限公司-Official website


ImageMagick 7.0.8-12 测试:


8827太阳集团(Macau)股份有限公司-Official website


建复建议


Ghostscript官方已给出缓解措施,,,,,,,请实时更新:
http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=a54c9e61e7d
http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=a6807394bd94
无法更新的可通过批改policy.xml禁用PS, EPS, PDF and XPS coders(会造成有关职能不成使用)
如:批改ImageMagick的policy文件,,,,,,,默认地位为/etc/ImageMagick-7/policy.xml
增长如下内容:
<policymap>
<policydomain="coder" rights="none" pattern="PS" />
<policydomain="coder" rights="none" pattern="EPS" />
<policydomain="coder" rights="none" pattern="PDF" />
<policydomain="coder" rights="none" pattern="XPS" />
</policymap>

若是不必要使用GhostScript,,,,,,,可卸载。。。。。。


参考链接


https://mailclark.ai/email/original/16819467/593541/mxzCj2eeqRd2DhZOU0Es1rJVQeg?from_name=Tavis%20Ormandy