MS16-063 IE11 jscript9.dll TypedArray UAF漏洞分析及利用(Windows 10 Bypass CFG) 发表于 2017-03-04 | 分类于 漏洞利用 | 暂无评论 # 1. 漏洞分析 由于是关于堆的漏洞,为了调试方便开启`HPA`和`UST`,打开POC页面 ```html ``` 立即造成Crash ![image_1bac26g3c1vuks2tdvcpnrgq19.png-9.9kB][1] [1]: http://static.zybuluo.com/birdg0/3zkkrawhg3j9bm0vy2j3vsmi/image_1bac26g3c1vuks2tdvcpnrgq19.png [2]: http://static.zybuluo.com/birdg0/9c5ow6v0bt8bgzh5qrh68sgw/image_1bac2at774jqn2s1imh1sf41p1q13.png [3]: http://static.zybuluo.com/birdg0/iy5jjgutgc8p14cjeiznah5j/image_1bac2hi8d1vak106alsg10ul19411t.png [4]: http://static.zybuluo.com/birdg0/h8qxbwt6m9cazhxedjvww3mp/image_1bac35vj51i4igrc63d10174h2a.png [5]: https://github.com/theori-io/jscript9-typedarray-cfg [6]: http://static.zybuluo.com/birdg0/n3lmeejy6gezy9tpfzgdzvwo/image_1bac5nnke1o9b53v15g5vep1oam2n.png [7]: https://github.com/birdg0/exp/blob/master/browser/ie11-ms16-063-bypass-cfg-exp.html [8]: http://theori.io/research/jscript9_typed_array [9]: http://theori.io/research/chakra-jit-cfg-bypass 看下`esi`指向的堆 ![image_1bac2at774jqn2s1imh1sf41p1q13.png-43.5kB][2] 可以看到`esi`指向了释放的堆,并从释放时的栈回溯来看是由`postMessage("", "*", [ab])`释放的,再看下Crash时的栈回溯,从这大概可以猜到是由于`ia[100] = 0x41414141`向释放后的堆赋值导致Crash ![image_1bac2hi8d1vak106alsg10ul19411t.png-29.5kB][3] 看下`Js::TypedArray::DirectSetItem`函数可以发现在赋值时并没有检测本身是否已经释放,这样就可能导致UAF,同样这个问题也存在于`DirectGetItem`函数中 ![image_1bac35vj51i4igrc63d10174h2a.png-8.8kB][4] # 2. 漏洞利用 Windows 7下的利用较简单,这里主要分析下Windows 10下利用Chakra JIT绕过CFG的EXP, Chakra JIT主要是为多次调用的函数或循环生成优化的JIT代码,在最后会通过Encoder生成本地代码,在这期间会用一个buffer来临时存放本地代码,再将buffer存到可执行内存,最后按照CFG的机制执行,如果在buffer存到可执行内存前修改其内容,这样就可以绕过CFG,下面是参考[https://github.com/theori-io/jscript9-typedarray-cfg][5]的EXP ```html ``` 最后利用成功执行notepad.exe ![image_1bac5nnke1o9b53v15g5vep1oam2n.png-229.2kB][6] 测试环境 1. 操作系统:Windows 10 x86 专业版 2. IE版本:11.0.10240.16384 完整EXP下载:[https://github.com/birdg0/exp/blob/master/browser/ie11-ms16-063-bypass-cfg-exp.html][7] # 3. 参考 1. [http://theori.io/research/jscript9_typed_array][8] 2. [http://theori.io/research/chakra-jit-cfg-bypass][9]