[论文解读] Stack Overflow Considered Harmful? The Impact of Copy&Paste on Android Application Security
本文研究了将 Stack Overflow 中的代码片段复制粘贴到 Android 应用中所带来的安全影响。通过自动化静态分析和机器学习技术,研究发现,在分析的 130 万个 Android 应用中,有 15.4% 包含了来自 Stack Overflow 的安全相关代码片段,其中 97.9% 的代码片段存在安全隐患,揭示了由于广泛存在不安全的代码重用,Android 生态系统面临重大安全风险。
Online programming discussion platforms such as Stack Overflow serve as a rich source of information for software developers. Available information include vibrant discussions and oftentimes ready-to-use code snippets. Anecdotes report that software developers copy and paste code snippets from those information sources for convenience reasons. Such behavior results in a constant flow of community-provided code snippets into production software. To date, the impact of this behaviour on code security is unknown. We answer this highly important question by quantifying the proliferation of security-related code snippets from Stack Overflow in Android applications available on Google Play. Access to the rich source of information available on Stack Overflow including ready-to-use code snippets provides huge benefits for software developers. However, when it comes to code security there are some caveats to bear in mind: Due to the complex nature of code security, it is very difficult to provide ready-to-use and secure solutions for every problem. Hence, integrating a security-related code snippet from Stack Overflow into production software requires caution and expertise. Unsurprisingly, we observed insecure code snippets being copied into Android applications millions of users install from Google Play every day. To quantitatively evaluate the extent of this observation, we scanned Stack Overflow for code snippets and evaluated their security score using a stochastic gradient descent classifier. In order to identify code reuse in Android applications, we applied state-of-the-art static analysis. Our results are alarming: 15.4% of the 1.3 million Android applications we analyzed, contained security-related code snippets from Stack Overflow. Out of these 97.9% contain at least one insecure code snippet.
研究动机与目标
- 评估不安全的 Stack Overflow 代码片段在真实世界 Android 应用中被复制的程度。
- 量化安全相关代码片段从公共开发者论坛传播到生产环境 Android 应用的规模。
- 评估常在 Stack Overflow 上分享的 Android 开发代码片段的安全质量。
- 设计并实现一个可扩展的自动化流水线,用于检测从社区平台向闭源软件的代码重用。
- 提出实用的缓解策略,例如开发浏览器插件,实现实时标记不安全的代码片段。
提出的方法
- 爬取并提取了来自与 Android 相关的 Stack Overflow 帖子中的 4,019 个安全相关代码片段。
- 应用基于标记的已知安全/不安全代码片段训练的随机梯度下降分类器,为代码片段分配安全评分。
- 生成程序依赖图(PDGs)作为高效克隆检测的抽象表示。
- 使用最先进的静态分析技术,在 Google Play 上的 130 万个 Android 应用中检测精确匹配和近似匹配的代码片段。
- 构建了一个完全自动化、可扩展的流水线,用于大规模测量公共论坛到生产软件的代码流动。
- 开发了浏览器插件原型,以实现在网络平台上实时对代码片段进行安全分类。
实验结果
研究问题
- RQ1来自 Stack Overflow 的安全相关代码片段在多大程度上被复制到生产环境的 Android 应用中?
- RQ2在从 Stack Overflow 复制到 Android 应用中的代码片段中,不安全代码片段的普遍程度如何?
- RQ3机器学习能否有效分类社区提供的代码片段的安全质量?
- RQ4开发者在选择和重用公共论坛中的安全相关代码时,其行为模式是怎样的?
- RQ5自动化工具能否在不安全代码片段被集成到生产软件之前检测并标记它们?
主要发现
- 在分析的 130 万个 Android 应用中,有 15.4% 包含至少一个从 Stack Overflow 复制的安全相关代码片段。
- 在包含 Stack Overflow 代码片段的应用中,97.9% 包含至少一个不安全的代码片段,表明存在缺陷代码的广泛传播。
- 本研究识别出 196,000 个应用包含来自 Stack Overflow 的漏洞代码片段,凸显了大规模安全风险。
- 研究人员检测到 73,000 个应用使用了来自 Stack Overflow 的安全代码片段,表明高质量代码也广泛被重用。
- 元数据分析显示,不安全的代码片段通常获得较高的点赞数,表明受欢迎程度与安全质量无关。
- 研究发现,某些领域(如金融和游戏)倾向于使用特定的安全库,表明应用类型可能与潜在攻击面模式相关。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。