-
-
[原创]某知名PDF阅读器,存在异形文档解析错误,可能导致触发异常访问风险
-
发表于: 2022-4-10 15:57 9807
-
先看引发异常处代码:
1 2 3 4 5 6 7 8 9 10 11 | 0146CB77 . 899C24 880000>mov dword ptr ss:[esp+0x88],ebx 0146CB7E . E8 2DF40A00 call Re.0151BFB0 :此函数解析调用中会存在递归解析错误,导致第7行代码处栈内存变量返回值为0;0146CB83 > 85DB test ebx,ebx0146CB85 . 7C 0F jl short Re.0146CB960146CB87 . 3B5C24 4C cmp ebx,dword ptr ss:[esp+0x4C]:此处,正常情况下不会发生跳转,但存在一种很罕见的情况,是ebx==ss:[esp+0x4C]==0的情况;0146CB8B . 7D 09 jge short Re.0146CB96 :如果均为0,则执行跳转;0146CB8D . 8B4424 48 mov eax,dword ptr ss:[esp+0x48]0146CB91 . 8D04D8 lea eax,dword ptr ds:[eax+ebx*8]0146CB94 . EB 02 jmp short Re.0146CB980146CB96 > 33C0 xor eax,eax :此时,eax清零; 0146CB98 > 8B48 04 mov ecx,dword ptr ds:[eax+0x4]:发生非法内存访问错误,报出异常; |
回溯查看call Re.0151BFB0处函数执行过程,在此函数内,解析过程成功后,会对栈变量赋值ss:[esp+0x4C]为非零,如果解析错误,此处为0,从而导致触发非法地址访问异常。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 0151BFB0 /$ 83EC 18 sub esp,0x180151BFB3 |. 53 push ebx0151BFB4 |. 55 push ebp0151BFB5 |. 56 push esi0151BFB6 |. 57 push edi0151BFB7 |. 8BF1 mov esi,ecx0151BFB9 |. E8 D211FEFF call Re.014FD190 :解析 ASCII "Rotate"属性;0151BFBE |. 8BCE mov ecx,esi0151BFC0 |. 894424 10 mov dword ptr ss:[esp+0x10],eax0151BFC4 |. E8 67040100 call Re.0152C430 :解析 ASCII "QuadPoints"属性,解析成功时eax置0;而失败时却返回1,导致eax非零,在下处直接退出函数,并不返回QuadPoints渲染参数;0151BFC9 |. 85C0 test eax,eax 0151BFCB |. 74 63 je short Re.0151C0300151BFCD |. 8BCE mov ecx,esi0151BFCF |. E8 FCFEFFFF call Re.0151BED0 :再次尝试解析,仍然失败;0151BFD4 |. 8BF8 mov edi,eax0151BFD6 |. 85FF test edi,edi :edi返回数据地址;0151BFD8 |. 74 56 je short Re.0151C0300151BFDA |. 8B47 10 mov eax,dword ptr ds:[edi+0x10]0151BFDD |. A8 07 test al,0x70151BFDF |. 75 4F jnz short Re.0151C0300151BFE1 |. D1E8 shr eax,10151BFE3 |. 0F84 EB020000 je Re.0151C2D4 :退出函数; |
跟踪call Re.0152C430执行:在011B0D50函数处会存在递归解析,Bug正是在这里产生的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 011B0D50 /$ 51 push ecx011B0D51 |. 8B4424 08 mov eax,dword ptr ss:[esp+0x8]011B0D55 |. 53 push ebx011B0D56 |. 55 push ebp011B0D57 |. 56 push esi011B0D58 |. 85C0 test eax,eax011B0D5A |. 57 push edi 011B0D5B |. 8BF1 mov esi,ecx011B0D5D |. 75 38 jnz short Re.011B0D97011B0D5F |. 8B7C24 1C mov edi,dword ptr ss:[esp+0x1C] 011B0D63 |. 8B46 08 mov eax,dword ptr ds:[esi+0x8]011B0D66 |. 0FBF56 04 movsx edx,word ptr ds:[esi+0x4]011B0D6A |. 8B0F mov ecx,dword ptr ds:[edi]011B0D6C |. 2BC1 sub eax,ecx011B0D6E |. 3BC2 cmp eax,edx011B0D70 |. 7E 02 jle short Re.011B0D74011B0D72 |. 8BC2 mov eax,edx011B0D74 |> 8B5424 24 mov edx,dword ptr ss:[esp+0x24]011B0D78 |. 03C8 add ecx,eax011B0D7A |. 890F mov dword ptr ds:[edi],ecx011B0D7C |. 8B4C24 28 mov ecx,dword ptr ss:[esp+0x28] 011B0D80 |. 51 push ecx011B0D81 |. 52 push edx011B0D82 |. 50 push eax011B0D83 |. 8B4424 2C mov eax,dword ptr ss:[esp+0x2C]011B0D87 |. 50 push eax011B0D88 |. 8BCE mov ecx,esi011B0D8A |. E8 71FFFFFF Re.011B0D00011B0D8F |. 5F pop edi 011B0D90 |. 5E pop esi 011B0D91 |. 5D pop ebp 011B0D92 |. 5B pop ebx 011B0D93 |. 59 pop ecx 011B0D94 |. C2 1400 retn 0x14011B0D97 |> 8A46 06 mov al,byte ptr ds:[esi+0x6]011B0D9A |. C74424 10 000>mov dword ptr ss:[esp+0x10],0x0011B0DA2 |. 84C0 test al,al011B0DA4 |. 76 50 jbe short Re.011B0DF6011B0DA6 |. 8B4C24 20 mov ecx,dword ptr ss:[esp+0x20] 011B0DAA |. 8B7C24 28 mov edi,dword ptr ss:[esp+0x28] 011B0DAE |. 8B5C24 24 mov ebx,dword ptr ss:[esp+0x24]011B0DB2 |. 8B6C24 1C mov ebp,dword ptr ss:[esp+0x1C] 011B0DB6 |. 894C24 20 mov dword ptr ss:[esp+0x20],ecx011B0DBA |> 8B5424 20 /mov edx,dword ptr ss:[esp+0x20] 011B0DBE |. 8B02 |mov eax,dword ptr ds:[edx]011B0DC0 |. 85C0 |test eax,eax011B0DC2 |. 74 15 |je short Re.011B0DD9011B0DC4 |. 57 |push edi 011B0DC5 |. 53 |push ebx011B0DC6 |. 50 |push eax011B0DC7 |. 8B4424 24 |mov eax,dword ptr ss:[esp+0x24]011B0DCB |. 48 |dec eax011B0DCC |. 55 |push ebp011B0DCD |. 50 |push eax011B0DCE |. 8BCE |mov ecx,esi011B0DD0 |. E8 7BFFFFFF |call Re.011B0D50 :递归调用,但是存在对退出递归条件设置不当,导致会在处理异形数据时,直接退出递归,而返回数据地址,从而导致解析错误。011B0DD5 |. 85C0 |test eax,eax011B0DD7 |. 75 1F |jnz short Re.011B0DF8011B0DD9 |> 8B4C24 20 |mov ecx,dword ptr ss:[esp+0x20] 011B0DDD |. 8B4424 10 |mov eax,dword ptr ss:[esp+0x10] 011B0DE1 |. 83C1 04 |add ecx,0x4011B0DE4 |. 40 |inc eax011B0DE5 |. 894C24 20 |mov dword ptr ss:[esp+0x20],ecx011B0DE9 |. 33C9 |xor ecx,ecx011B0DEB |. 8A4E 06 |mov cl,byte ptr ds:[esi+0x6]011B0DEE |. 894424 10 |mov dword ptr ss:[esp+0x10],eax011B0DF2 |. 3BC1 |cmp eax,ecx011B0DF4 |.^ 7C C4 \jl short Re.011B0DBA011B0DF6 |> 33C0 xor eax,eax011B0DF8 |> 5F pop edi 011B0DF9 |. 5E pop esi 011B0DFA |. 5D pop ebp 011B0DFB |. 5B pop ebx 011B0DFC |. 59 pop ecx 011B0DFD \. C2 1400 retn 0x14 |
结论:此异常会被阅读器异常链拦截处理,暂时不可被利用;但也会引发潜在的利用风险。例如:如果0146CB98 地址处 可以被改写为shellcode;或改写阅读器异常链,并由此触发异常链的访问。
阅读器名称:无
版本号:无
赞赏
他的文章
- 怎么提取微软补丁? 6166
- [求助]来啊,一起看看这是不是个洞? 11300
- [讨论]xor r9d r9d ;这条指令执行完后,r9的值是多少? 11947
- 010editor版本V13.0.1暴力破解过程 8793
- [原创]syzkaller内核黑盒测试环境搭建中,内存不足的解决办法 10450
赞赏
雪币:
留言: