PowerShell Remote Code Execution Vulnerability(CVE-2025-54100)

Windows PowerShell是微软为Windows系统开发的任务自动化和配置管理框架,包含命令行shell脚本语言。不同于传统 Shell 处理文本流,它基于 .NET 运行环境,直接操作结构化对象

12月份微软发布了更新,披露了PowerShell 远程代码执行漏洞(CVE-2025-54100), CVSS评分 7.8分(高)。

影响范围

Windows 10 Version 1607 < 10.0.20348.4529

Windows 10 Version 1809 < 10.0.17763.8146

Windows 10 Version 21H2 < 10.0.19044.6691

Windows 10 Version 22H2 < 10.0.19045.6691

Windows 11 Version 23H2 < 10.0.25398.2025

Windows 11 Version 24H2 < 10.0.26100.7462

Windows 11 Version 25H2 < 10.0.26200.7462

Windows Server 2008 SP2 < 6.0.6003.23666

Windows Server 2008 R2 < 6.1.7601.28064

Windows Server 2012 < 6.2.9200.25815

Windows Server 2012 R2 < 6.3.9600.22920

Windows Server 2016 < 10.0.14393.8688

Windows Server 2019 < 10.0.17763.8146

Windows Server 2022 < 10.0.20348.4529

Windows Server 2022 23H2 < 10.0.25398.2025

Windows Server 2025 < 10.0.26100.7462

漏洞描述

官方描述是”Improper neutralization of special elements used in a command (‘command injection’) in Windows PowerShell allows an unauthorized attacker to execute code locally.”

该漏洞源于powershell的curl命令底层是使用的Invoke-WebRequest,而Invoke-WebRequest命令默认使用IE的MSHTML引擎进行HTML解析,可能导致远程代码执行。

![image-20251226135342794](picture/PowerShell Remote Code Execution Vulnerability(CVE-2025-54100)/image-20251226135342794.png)

漏洞原理

通过查看微软的技术文档查看参数 UseBasicParsing

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.5

This parameter has been deprecated. Beginning with PowerShell 6.0.0, all Web requests use basic parsing only. This parameter is included for backwards compatibility only and any use of it has no effect on the operation of the cmdlet.

此参数已弃用。从PowerShell 6.0.0开始,所有Web请求只使用基本解析。此参数仅用于向后兼容性,对它的任何使用都不会影响cmdlet的操作。

也就是说在PowerShell的5.1版本中,Invoke-WebRequest默认使用 是会解析html代码的。UseBasicParsing 使用基本解析,它不执行任何javascript代码。它只是读取并解析文本。

如果未提供此参数,Invoke-WebRequest则会在底层启动 Internet Explorer,并尝试通过实际执行来解析 HTML 代码mshtml.HTMLDocumentClasscurl向托管 JavaScript 代码的网站发出请求会导致代码在客户端浏览器上执行。

MSHTML 是微软的一个核心COM组件,它的全称是 Microsoft HTML Engine,通常也被称为 Trident 渲染引擎。简单来说,它是Internet Explorer浏览器的“心脏”,负责网页的核心处理工作。

研究发现powershell在调用Invoke-WebRequest时默认使用一个名为Microsoft.Mshtml.dll的COM组件,该组件封装了老旧的MSHTML (Trident) 引擎。

不管系统有没有安装IE浏览器。本质是因为MSHTML是Windows组件,MSHTML(Trident)这个旧的网页渲染引擎。如果为了兼容目的而调用这个旧引擎时,其相关的安全漏洞就会被触发。

经过一番调查,我们发现12月前的版本的 Windows 11、Server 22 和 25 都附带了旧版本的 PowerShell(5.1,并且是默认版本)。

实际测试发现成功调用了mshtml.HTMLDocumentClass解析js代码

![image-20251226140415639](picture/PowerShell Remote Code Execution Vulnerability(CVE-2025-54100)/image-20251226140415639.png)

漏洞复现

验证环境:

  • Windows 10 Version 22H2 10.0.19045.6466

![image-20251226140808765](picture/PowerShell Remote Code Execution Vulnerability(CVE-2025-54100)/image-20251226140808765.png)

安全建议

  • Windows自动更新

    更新到系统对应最新版本

  • 手动安装补丁

    对于无法自动更新的系统,可以在下面的链接下载对应系统的安全补丁https://msrc.microsoft.com/update-guide/vulnerability/CVE-2025-54100

    ![image-20251225191841519](picture/PowerShell Remote Code Execution Vulnerability(CVE-2025-54100)/image-20251225191841519.png)

参考链接:

[1]https://msrc.microsoft.com/update-guide/vulnerability/CVE-2025-54100

[2]https://avd.aliyun.com/detail?id=AVD-2025-54100

[3]https://www.gm7.org/2025/12/19/11136.html

[4]https://github.com/ThemeHackers/CVE-2025-54100