Wordpress 插件 Media Library Assistant 2.81(LFI和XSS)

前言

(申请Wiki账号)
个人觉得漏洞威胁不算太大,但也作为一个弱鸡的学习经历将其记录下来

Media Library Assistant用于进行图像和文件管理

影响版本

<2.82

漏洞版本下载地址:https://downloads.wp.xz.cn/plugin/media-library-assistant.2.81.zip

LFI

漏洞位置:

/media-library-assistant/includes/mla-file-downloader.php

引入class-mla-file-downloader.php,且注意下文的两个参数: mla_download_filemla_download_type 以及方法: mla_process_download_file()

跟入 mla_process_download_file() ,注意到:

$file_name = $args['mla_download_file'];
$match_name = str_replace( '\\', '/', $file_name );
$base_dir = pathinfo( __FILE__, PATHINFO_DIRNAME );
$match_dir = str_replace( '\\', '/', $base_dir );
$allowed_path = substr( $match_dir, 0, strpos( $match_dir, 'plugins' ) );
​
if ( 0 !== strpos( $match_name, $allowed_path ) ) {
$message = 'ERROR: download path out of bounds.';
} elseif ( false !== strpos( $match_name, '..' ) ) {
$message = 'ERROR: download path invalid.';
}
} else {
$message = 'ERROR: download argument(s) not set.';




可以看出为了防止目录穿越对 .. 进行了过滤,只能读取plugin目录下的内容,这么来看,可能可以读取插件目录下的某些信息但利用效果似乎不大

然后就可以进行下载:

if ( empty( $message ) ) {
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Last-Modified: '.gmdate ( 'D, d M Y H:i:s', filemtime ( $file_name ) ).' GMT');
header('Cache-Control: private',false);
header('Content-Type: '.$args['mla_download_type']);

poc:

http://127.0.0.1/wordpress/wp-content/plugins/media-library-assistant/includes/mla-file-downloader.php?mla_download_type=text/html&mla_download_file=C:\phpstudy\PHPTutorial\WWW\wordpress\wp-content\plugins\rest-api\extras.php

该漏洞不需要授权

修复

在2.82版本中,直接禁止了这一行为:

xss

前提: admin角色

设置/Media Library Assistant 的所有标签的搜索框存在xss

views 标签:includes/class-mla-settings-view-tab.php:

image-20200502104150209

s参数即是注入点,无过滤

触发:

同理在uploads等的标签中的搜索框也存在:

image-20200502104656085

修复

image-20200502115510172

在2.82版本中增加了wordpress内置函数 esc_attr 进行过滤操作

参考链接:

2 个赞