盘古实验室在针对不同客户的iOS应用安全审计过程中,发现了一类通用的安全漏洞。创建漏洞指纹后,我们在Janus平台上进行溯源分析和相似漏洞检索,结果发现约10%的iOS应用可能受此漏洞的影响。经过手工分析,我们确认微博、陌陌、网易云音乐、QQ音乐、快手等流行应用受影响。
漏洞演示视频中,用户在不安全WiFi环境里使用微博;攻击者利用该漏洞获取了微博应用中任意代码执行能力。
While auditing iOS Apps from various customers, Pangu Lab noticed a common programming error, which leads to severe consequences such as data overwritten and even code execution in the context of affected Apps. We created a signature for the issue and performed a large-scale search on our App analysis platform Janus. Surprisingly, we found that round 10% iOS Apps might be affected by the same or similar issues. Among the potentially affected Apps, we manually verified that many popular apps including Weibo, MOMO, NetEase Music, QQ Music and Kwai, are truly affected. These Apps have more than 100 million users.
To avoid leaking the details of the programming error, we named it ZipperDown.
The video demonstrates that the user downloads and uses Weibo apps in an unsafe Wi-Fi environment, and attackers gain code execution in the context of user’s Weibo app by exploiting the ZipperDown issue in Weibo.
Due to the large amount of potentially affected apps, we cannot verify all the results precisely. To protect the end-users, the detail of ZipperDown is not available to the public for now. We post the potentially affected list. If you were the developer or vender of the apps on the list, you are welcome to contact us. We would share you the detail of ZipperDown, and let us cooperatively fix the potential issue in your app. We would also appreciate if you could notify us in the case that your listed app is not vulnerable. The best way to reach us is the following Email: zipperdown@pwnzen.com.
盘古实验室在2017年里多次承接来自不同客户的iOS App审计业务。除常规安全扫描外,实验室研究员对所审计的iOS App进行深入分析,研究各种潜在攻击面,挖掘了多种安全漏洞和潜在风险。
Zip文件解压缩过程中,由文件名和符号链接等引起的路径穿越进而导致文件覆盖是一类非常经典的安全问题,大量Unzip软件都曾被发现这类安全漏洞。鉴于此,对所审计的iOS App中存在Zip文件处理的,我们都通过人工分析确认是否存在风险。基于盘古实验室研究人员丰富的安全经验,我们在多个iOS App中发现了解压缩过程中存在路径穿越问题。
最初,我们仅以为这是一些个别案例。然而,随着被审计的iOS App数目不断增长,我们吃惊地发现,Zip文件解压缩过程中路径穿越问题普遍存在于不同客户的不同类别的App中!从个别案例到普遍存在,我们开始反思,为什么iOS应用中一个如此典型的安全漏洞如此普遍?
经过仔细分析,我们确认这些受影响的iOS应用大多重用了SSZipArchive和ZipArchive两个开源库。这两个开源库,都提供了将Zip文件中的内容解压缩到一个含有相对路径的目录中的特性。我们不由得面对接下来的一个问题,到底多少iOS应用使用了这两个开源库?
幸运地是,与此同时公司另外一个项目Janus 移动安全威胁数据平台(appscan.io)上已经收录了168,951个iOS App。因此,我们创建了SSZipArchive和ZipArchive库特征,在Janus平台上进行匹配检索,最终发现15,979个iOS App使用了这两个库!在这些iOS App中,不乏各种超级流行应用。我们对这个庞大的疑似受影响列表进行了抽检,结果更令人不安,微博、陌陌、快手、网易云音乐、QQ音乐等确实受影响。
这时候,我们意识到另外一个更加棘手问题:这个漏洞如何披露?首先,面对如此大的疑似受影响列表,我们显然无法逐一确认。其次,本着负责任披露的原则,即便我们通知给库的开发方、已确认受影响的App开发方,如何更好的保护那些在疑似列表上的App用户?
再三斟酌后,我们发布了zipperdown.org 站点,将这类问题称作ZipperDown,暂时没有公开漏洞细节,而是通过公开疑似受影响列表的方式,期望与App开发者一起来协同修复这个问题。zipperdown.org发布后,我们收到了283封询问邮件,在确认发信人身份后,我们共回复260份邮件分享了漏洞细节。
疑似列表公开后,我们承受了很大压力。疑似列表给很多未真正受影响的App带了很多困扰,我们为此表示深深歉意。但是我们仍然认为,对这两个库的使用是潜在的风险点,希望开发者能够结合自身业务场景彻底杜绝该类问题。更为重要的是,我们想传达的信息是,开发者应该重新审计自己App中对Zip文件的处理,即便没有使用这两个开源库,也要确保杜绝路径穿越等经典安全问题。
我们在Android平台上发现了类似问题。其他安全研究人员也在多个流行应用中披漏了不同形态的路径穿越漏洞(” General ways to find and exploit Path Traversal Vulnerabilities on Android APPs”, Xiaobo Xiang, DefCon China, 2018.)。请访问zipperdown.appscan.io,查询您的Android App是否存在类似问题。
SSZipArchive和ZipArchive解压缩过程中没有考虑到文件名中包含”../”的情况,造成了文件释放过程中路径穿越,导致恶意Zip文件可以在App沙盒范围内,覆盖任意可写文件。具体代码如下:
-(BOOL) UnzipFileTo:(NSString*) path overWrite:(BOOL) overwrite
{
[...]
// check if it contains directory
NSString* strPath = [NSString stringWithCString:filename encoding:NSUTF8StringEncoding];
BOOL isDirectory = NO;
if( filename[fileInfo.size_filename-1]=='/' || filename[fileInfo.size_filename-1]=='\\')
isDirectory = YES;
free( filename );
if( [strPath rangeOfCharacterFromSet:[NSCharacterSetcharacterSetWithCharactersInString:@"/\\"]].location!=NSNotFound )
{
// contains a path
strPath = [strPath stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
}
NSString* fullPath = [path stringByAppendingPathComponent:strPath];
[...]
}
+ (BOOL)unzipFileAtPath:(NSString *)path
toDestination:(NSString *)destination
preserveAttributes:(BOOL)preserveAttributes
overwrite:(BOOL)overwrite
nestedZipLevel:(NSInteger)nestedZipLevel
password:(nullable NSString *)password
error:(NSError **)error
delegate:(nullable id)delegate
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler{
[...]
if ([strPath rangeOfCharacterFromSet:[NSCharacterSetcharacterSetWithCharactersInString:@"/\\"]].location != NSNotFound) {
strPath = [strPath stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
}
NSString *fullPath = [destination stringByAppendingPathComponent:strPath];
[...]
}
基于漏洞原理,漏洞利用条件的核心即如何使目标App解压不可信Zip文件。因为App业务差异大,我们仅列举部分常见场景。
此外,文件覆盖的后继攻击依赖于具体App环境。在使用热补丁的App中,可能存在补丁文件被覆盖,进而导致恶意补丁文件加载执行的情况。即使没有使用热补丁,恶意Zip文件也可能覆盖核心数据文件,触发App解析这些核心数据中的逻辑错误或编码错误等问题。由于iOS沙盒保护,ZipperDown的破坏范围仅限在App环境中。
相比iOS下的ZipperDown,安卓平台下的ZipperDown漏洞更直观、更容易理解,且破坏力也更大。安卓平台下的ZipperDown漏洞在利用场景上与iOS的有一些不同,主要区别在于:
目前,针对安卓应用的ZipperDown漏洞,Janus已经提供了线上检测功能。通过访问www.appscan.io即可对应用进行检测。与iOS应用类似,我们目前无法对ZipperDown漏洞进行全自动的检测,对疑似问题,我们建议开发者使用Janus的深度检查功能来自行确认应用逻辑。
鉴于疑似受影响App业务场景的复杂性,我们建议以下修复方案,供各方参考。
| 应用名称App Name | 包名Bundle ID |
|---|---|
| 应用名称App Name | 包名Bundle ID |
盘古实验室是上海犇众信息技术有限公司组建的以盘古团队为核心的安全实验室。实验室在移动互联网领域开展了广泛的安全研究,深入分析了各种移动设备的硬件、系统、应用和网络各层的安全架构,研究发现移动互联网大量潜在安全问题的同时,在高级防御技术及解决方案等方向上形成了一系列成果和产品。

沪公网安备 31011202002804号