CVE 编号
CVE-2021-40399
概括
作为 WPS Office 版本 11.2.0.10351 的一部分,WPS 电子表格 (ET) 中存在一个可利用的释放后使用漏洞。特制的 XLS 文件可能会导致释放后使用情况,从而导致远程代码执行。攻击者需要向受害者提供格式错误的文件才能触发漏洞。
测试版本
WPS 办公室 11.2.0.10351
产品网址
WPS 办公室 - https://www.wps.com/
CVSSv3 分数
8.8 - CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
CWE
CWE-416 - 免费后使用
细节
WPS Office 以前称为金山 Office 是一套用于提高企业环境和最终用户生产力的工具。它提供了一系列可用于各种目的的工具。例如用于电子表格的 WPS 电子表格、用于文档编辑的 WPS Writer 等等。
以适当形式的 HTML/XML 标记编写的特制 XLS 文件可能导致释放后使用漏洞和远程代码执行。让我们使用调试器在 ET.exe 中运行格式错误的 xls 文件:
(6a4.1674): Access violation - code c0000005 (first/second chance not available)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
Time Travel Position: 6E147E:0
eax=00000000 ebx=0d4eeeb8 ecx=00000000 edx=00000000 esi=1ccb5dcb edi=5f06dfb8
eip=0228282b esp=0d4eedb0 ebp=0d4eee58 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000202
0228282b 006200 add byte ptr [edx],ah ds:002b:00000000=??
0:011> kb
# ChildEBP RetAddr Args to Child
WARNING: Frame IP not in any known module. Following frames may be wrong.
00 0d4eee58 0dd5b0b8 00000000 06dbd130 06dbd170 0x228282b
01 0d4eef20 5f0b0a75 1ccb432f 07b5f1a0 00000000 0xdd5b0b8
02 0d4ef310 5f0afba4 07b6b670 00000000 1ccb45df html2!html2::HtmlParser::parseStream+0x75
03 0d4ef5e0 5f2fd0e0 00f6d814 00000001 0d4ef694 html2!html2::HtmlParser::parse+0x2a4
04 0d4ef8b4 5f2d41ef 00f6d814 06d81ea8 00000000 ethtmlrw2!html2::StrmUtf8Converter::~StrmUtf8Converter+0x42b0
05 0d4ef8f0 5f2d4bf9 06bdbd40 5f2d5f3f f114ab06 ethtmlrw2!chart::KETChartDataSourceProvider::getContextOOXML+0xbf
06 0d4ef920 75a64f9f 07a63158 45279ebd 75a64f60 ethtmlrw2!chart::KETChartDataSourceProvider::getContextOOXML+0xac9
07 0d4ef958 776ffa29 075b0798 776ffa10 0d4ef9c4 ucrtbase!thread_start<unsigned int (__stdcall*)(void *),1>+0x3f
08 0d4ef968 77847a9e 075b0798 02cb572f 00000000 KERNEL32!BaseThreadInitThunk+0x19
09 0d4ef9c4 77847a6e ffffffff 77868a4e 00000000 ntdll!__RtlUserThreadStart+0x2f
0a 0d4ef9d4 00000000 75a64f60 075b0798 00000000 ntdll!_RtlUserThreadStart+0x1b
看起来执行流程已被重定向到不可执行的区域:
0:011> !address 0228282b
Usage: <unknown>
Base Address: 02270000
End Address: 022da000
Region Size: 0006a000 ( 424.000 kB)
State: 00001000 MEM_COMMIT
Protect: 00000004 PAGE_READWRITE
Type: 00020000 MEM_PRIVATE
Allocation Base: 02270000
Allocation Protect: 00000001 PAGE_NOACCESS
让我们检查一下内存内容:0:011> db 02282828 02282828 74 00 61 00 62 00 6c 00-65 00 00 00 74 00 62 00 table…tb 02282838 6f 00 64 00 79 00 06 00 0-74 06 06 00 ody…tfoo 02282848 74 00 00 00 74 00 68 00-65 00 61 00 64 00 00 00 t…thead…02282858 6c 00 6f 00 63 00 6b 00-00 00 00 06…70 00 21 8.0 8 锁74 00 68 00 00 00 00 00-73 00 6b 00 65 00 77 00 th…..skew 02282878 00 00 00 00 67 00 72 00-6f 00 75 00 70 00 00 00 ….group… 0228280 8 6 6 00 6c 00-00 00 00 00 63 00 75 00 椭圆形.....cu 02282898 72 00 76 00 65 00 00 00-72 00 67 00 62 00 28 00 rve...rgb(.0:011> du 022282828 0228"28"
我们可以清楚地看到,程序执行确实在一个不可执行的区域(数据)中结束。当我们退后几步查看代码执行重定向的时刻时,我们会看到以下代码:
0:011> r
eax=0228bea0 ebx=0228bed0 ecx=0228bed0 edx=013e0000 esi=0dd5bd78 edi=0d4eee58
eip=5f06dfb5 esp=0d4eed94 ebp=0d4eedf4 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000202
html2!html2::HtmBoxRefOperator::imitateBoxFlags+0x365:
5f06dfae 8b5d08 mov ebx, dword ptr [ebp+8]
5f06dfb1 8bcb mov ecx, ebx
5f06dfb3 8b03 mov eax, dword ptr [ebx]
5f06dfb5 ff5034 call dword ptr [eax+34h] ds:002b:0228bed4=02282828
看起来像是对其中一个虚函数的典型调用。很有可能该对象之前已被释放,并且 vftable 指针0228bed0已被覆盖。在 上设置写访问断点0228bed0,让我们再次执行我们的软件:
0:011> g-
Breakpoint 0 hit
Time Travel Position: 6E1064:A7
eax=0228bea0 ebx=0228bed0 ecx=00a6e000 edx=0000000b esi=01437c70 edi=06cd5a98
eip=6a437c7d esp=0d4eec08 ebp=0d4eec14 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000202
kso!mfxGlobalFree2+0x5d:
6a437c7d 8b4704 mov eax,dword ptr [edi+4] ds:002b:06cd5a9c=00000055
0:011> kb
# ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
00 0d4eec14 5f06d818 0000000b 00000030 1ccb5c03 kso!mfxGlobalFree2+0x5d
01 0d4eec3c 5f0b649f 1ccb5c53 0d4ef078 07ba5174 html2!html2::HtmCreator::createXmlNodesRef+0x4f8
02 0d4eec6c 5f0c22c0 07ba5174 0d4eef38 0d4eef38 html2!html2::StrIdSet::gainLower+0xbf
03 0d4eec90 5f0c8d34 022812e0 07b60f01 5f0c90f0 html2!html2::ParserContext::urlStack+0xac00
04 0d4eeca4 5f0c8a47 022812e0 00000000 07b60f01 html2!html2::ParserContext::urlStack+0x11674
05 0d4eecd0 5f0c6dfc 022812e0 07b60f01 0d4eef38 html2!html2::ParserContext::urlStack+0x11387
06 0d4eecf8 5f0c8a96 00020000 00000001 0d4ef3f4 html2!html2::ParserContext::urlStack+0xf73c
07 0d4eed20 5f0c6dfc 022812f0 07b60f01 0d4eef38 html2!html2::ParserContext::urlStack+0x113d6
08 0d4eed48 5f0c7c40 00084404 00000000 00000000 html2!html2::ParserContext::urlStack+0xf73c
09 0d4eed70 5f0c4d7c 022812f0 00000000 00000001 html2!html2::ParserContext::urlStack+0x10580
0a 0d4eed90 5f0b24da 022812f0 00000000 07ba6ff0 html2!html2::ParserContext::urlStack+0xd6bc
0b 0d4eedc8 5f0b32f0 07b6b670 07b15e70 0d4ef668 html2!html2::HtmDocument::topBoxs+0x197a
0c 0d4eee00 5f0b2271 1ccb5e07 07b6b670 0d4eef38 html2!html2::HtmDocument::topBoxs+0x2790
0d 0d4eee38 5f0cb8c5 00000003 0074683c 0d4eef38 html2!html2::HtmDocument::topBoxs+0x1711
0e 0d4eef20 5f0b0a75 1ccb432f 07b5f1a0 00000000 html2!html2::ParserContext::urlStack+0x14205
0f 0d4ef310 5f0afba4 07b6b670 00000000 1ccb45df html2!html2::HtmlParser::parseStream+0x75
10 0d4ef5e0 5f2fd0e0 00f6d814 00000001 0d4ef694 html2!html2::HtmlParser::parse+0x2a4
11 0d4ef8b4 5f2d41ef 00f6d814 06d81ea8 00000000 ethtmlrw2!html2::StrmUtf8Converter::~StrmUtf8Converter+0x42b0
12 0d4ef8f0 5f2d4bf9 06bdbd40 5f2d5f3f f114ab06 ethtmlrw2!chart::KETChartDataSourceProvider::getContextOOXML+0xbf
13 0d4ef920 75a64f9f 07a63158 45279ebd 75a64f60 ethtmlrw2!chart::KETChartDataSourceProvider::getContextOOXML+0xac9
14 0d4ef958 776ffa29 075b0798 776ffa10 0d4ef9c4 ucrtbase!thread_start<unsigned int (__stdcall*)(void *),1>+0x3f
15 0d4ef968 77847a9e 075b0798 02cb572f 00000000 KERNEL32!BaseThreadInitThunk+0x19
16 0d4ef9c4 77847a6e ffffffff 77868a4e 00000000 ntdll!__RtlUserThreadStart+0x2f
17 0d4ef9d4 00000000 75a64f60 075b0798 00000000 ntdll!_RtlUserThreadStart+0x1b
我们的假设得到了证实。对我们来说重要的是对象已通过调用kso!mfxGlobalFree2. 如果我们跟踪它的分配:
dx -r1 -g @$cursession.TTD.Calls("kso!mfxGlobalAlloc2").Where( x => x.ReturnValue == `0x0228bed0`)
我们得到了我们的对象代表一个表的附加信息:
.text:5F06CEF0 public: static struct html2::HtmTable * __cdecl html2::HtmCreator::createHtmTableAlt(void) proc near
.text:5F06CEF0 push 30h ; '0'
.text:5F06CEF2 call mfxGlobalAlloc2
.text:5F06CEF7 mov dword ptr [eax], offset const html2::HtmTableAltImpl::`vftable'
.text:5F06CEFD mov dword ptr [eax+4], 0
.text:5F06CF04 mov dword ptr [eax+8], 0
.text:5F06CF0B mov dword ptr [eax+0Ch], 0
.text:5F06CF12 mov dword ptr [eax+10h], 0
.text:5F06CF19 mov dword ptr [eax+14h], 0
.text:5F06CF20 mov dword ptr [eax+18h], 0
.text:5F06CF27 mov dword ptr [eax+1Ch], 0
.text:5F06CF2E mov dword ptr [eax+20h], 0
.text:5F06CF35 mov dword ptr [eax+24h], 0
.text:5F06CF3C mov dword ptr [eax+28h], 0
.text:5F06CF43 mov word ptr [eax+2Ch], 0
.text:5F06CF49 retn
0:011> r
eax=`0228bed0` ebx=07ba51b4 ecx=0228bed0 edx=00000037 esi=07ba51b4 edi=079b1810
eip=5f06cef7 esp=0d4eebf0 ebp=0d4eec68 iopl=0 nv up ei pl nz na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000206
html2!html2::HtmCreator::createHtmTableAlt+0x7:
5f06cef7 c700b0be105f mov dword ptr [eax],offset html2::HtmTableAltImpl::`vftable' (5f10beb0) ds:002b:0228bed0=0228bf00
适当的堆修饰可以让攻击者完全控制这个释放后使用漏洞,因此可能允许它变成任意代码执行。
崩溃信息
(6a4.1674): Break instruction exception - code 80000003 (first/second chance not available)
Time Travel Position: 6E147D:7D
eax=0228bea0 ebx=0228bed0 ecx=0228bed0 edx=013e0000 esi=0dd5bd78 edi=0d4eee58
eip=5f06dfb5 esp=0d4eed94 ebp=0d4eedf4 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000202
html2!html2::HtmBoxRefOperator::imitateBoxFlags+0x365:
5f06dfb5 ff5034 call dword ptr [eax+34h] ds:002b:0228bed4=02282828
0:011> g
(6a4.1674): Access violation - code c0000005 (first/second chance not available)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
Time Travel Position: 6E147E:0
eax=00000000 ebx=0d4eeeb8 ecx=00000000 edx=00000000 esi=1ccb5dcb edi=5f06dfb8
eip=0228282b esp=0d4eedb0 ebp=0d4eee58 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000202
0228282b 006200 add byte ptr [edx],ah ds:002b:00000000=??
0:011> kb
# ChildEBP RetAddr Args to Child
WARNING: Frame IP not in any known module. Following frames may be wrong.
00 0d4eee58 0dd5b0b8 00000000 06dbd130 06dbd170 0x228282b
01 0d4eef20 5f0b0a75 1ccb432f 07b5f1a0 00000000 0xdd5b0b8
02 0d4ef310 5f0afba4 07b6b670 00000000 1ccb45df html2!html2::HtmlParser::parseStream+0x75
03 0d4ef5e0 5f2fd0e0 00f6d814 00000001 0d4ef694 html2!html2::HtmlParser::parse+0x2a4
04 0d4ef8b4 5f2d41ef 00f6d814 06d81ea8 00000000 ethtmlrw2!html2::StrmUtf8Converter::~StrmUtf8Converter+0x42b0
05 0d4ef8f0 5f2d4bf9 06bdbd40 5f2d5f3f f114ab06 ethtmlrw2!chart::KETChartDataSourceProvider::getContextOOXML+0xbf
06 0d4ef920 75a64f9f 07a63158 45279ebd 75a64f60 ethtmlrw2!chart::KETChartDataSourceProvider::getContextOOXML+0xac9
07 0d4ef958 776ffa29 075b0798 776ffa10 0d4ef9c4 ucrtbase!thread_start<unsigned int (__stdcall*)(void *),1>+0x3f
08 0d4ef968 77847a9e 075b0798 02cb572f 00000000 KERNEL32!BaseThreadInitThunk+0x19
09 0d4ef9c4 77847a6e ffffffff 77868a4e 00000000 ntdll!__RtlUserThreadStart+0x2f
0a 0d4ef9d4 00000000 75a64f60 075b0798 00000000 ntdll!_RtlUserThreadStart+0x1b
0:011> lmDvmet
Browse full module list
start end module name
00d20000 00e6b000 et (export symbols) et.exe
Loaded symbol image file: et.exe
Mapped memory image file: c:UsersicewallAppDataLocalKingsoftWPS Office11.2.0.10351office6et.exe
Image path: c:UsersicewallAppDataLocalKingsoftWPS Office11.2.0.10351office6et.exe
Image name: et.exe
Browse all global symbols functions data
Timestamp: Sat Oct 23 14:16:30 2021 (6173FD1E)
CheckSum: 00153DB1
ImageSize: 0014B000
File version: 11.2.0.10351
Product version: 11.2.0.10351
File flags: 0 (Mask 3F)
File OS: 40004 NT Win32
File type: 0.0 Unknown
File date: 00000000.00000000
Translations: 0000.04b0
Information from resource tables:
CompanyName: Zhuhai Kingsoft Office Software Co.,Ltd
ProductName: WPS Office
InternalName: et
OriginalFilename: et.exe
ProductVersion: 11,2,0,10351
FileVersion: 11,2,0,10351
FileDescription: WPS Spreadsheets
LegalCopyright: Copyright©2021 Kingsoft Corporation. All rights reserved.
供应商回应
国际版:https://www.wps.com/office/windows/
国内个人版:https://official-package.wpscdn.cn/wps/download/WPS_Setup_11691.exe
企业版:https:// wps-cn-ep.ks3-cn-beijing.ksyun.com/wps/download/ep/WPS2019/WPSPro_11.8.2.11542.exe
如需获取WPS官方对该漏洞的披露,可访问此链接:https://security.wps.cn/notices/28
https://official-package.wpscdn.cn/wps/download/WPS_Setup_11691.exe
时间线
2021-11-18 - 供应商披露
2021-12-15 - 30 天跟进
2022-01-07 - 60 天跟进
2022-01-13 - 根据请求向供应商重新发布建议副本
2022-04-02 - 授予 Talos披露延期
2022-05-02 - 供应商修补
2022-05-09 - 公开发布
发现者
由 Cisco Talos 的 Marcin “Icewall” Noga 发现。
原文始发于微信公众号(Ots安全):WPS Office HtmTableAlt use-after-free 漏洞报告
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论