The Python Package Index (PyPI) has become a target for malicious actors, yet existing detection tools generate false positive rates of 15-30%, incorrectly flagging one-third of legitimate packages as malicious. This problem arises because current tools rely on simple syntactic rules rather than semantic understanding, failing to distinguish between identical API calls serving legitimate versus malicious purposes. To address this challenge, we propose PyGuard, a knowledge-driven framework that converts detection failures into useful behavioral knowledge by extracting patterns from existing tools' false positives and negatives. Our method utilizes hierarchical pattern mining to identify behavioral sequences that distinguish malicious from benign code, employs Large Language Models to create semantic abstractions beyond syntactic variations, and combines this knowledge into a detection system that integrates exact pattern matching with contextual reasoning. PyGuard achieves 99.50% accuracy with only 2 false positives versus 1,927-2,117 in existing tools, maintains 98.28% accuracy on obfuscated code, and identified 219 previously unknown malicious packages in real-world deployment. The behavioral patterns show cross-ecosystem applicability with 98.07% accuracy on NPM packages, demonstrating that semantic understanding enables knowledge transfer across programming languages.


翻译:Python包索引(PyPI)已成为恶意攻击者的目标,然而现有检测工具会产生15-30%的误报率,错误地将三分之一的合法包标记为恶意。此问题的根源在于当前工具依赖简单的语法规则而非语义理解,无法区分服务于合法目的与恶意目的的相同API调用。为解决这一挑战,我们提出PyGuard——一个知识驱动的框架,通过从现有工具的误报和漏报中提取模式,将检测失败转化为有用的行为知识。我们的方法采用分层模式挖掘来识别区分恶意代码与良性代码的行为序列,利用大语言模型创建超越语法变体的语义抽象,并将这些知识整合到检测系统中,实现精确模式匹配与上下文推理的结合。PyGuard实现了99.50%的准确率,仅产生2个误报(现有工具为1,927-2,117个),在混淆代码上保持98.28%的准确率,并在实际部署中识别出219个先前未知的恶意包。行为模式展现出跨生态系统的适用性,在NPM包上达到98.07%的准确率,证明语义理解能够实现跨编程语言的知识迁移。

0
下载
关闭预览

相关内容

《基于动态图神经网络的恶意软件检测》
专知会员服务
14+阅读 · 1月28日
【新书】异常检测 Python,562页pdf
专知会员服务
44+阅读 · 2024年12月27日
《使用静态污点分析检测恶意代码》CMU最新30页slides
专知会员服务
21+阅读 · 2023年10月11日
《基于高斯混合流和入包的异常检测》2023最新57页论文
专知会员服务
28+阅读 · 2023年5月15日
专知会员服务
19+阅读 · 2021年6月10日
深度学习赋能的恶意代码攻防研究进展
专知会员服务
30+阅读 · 2021年4月11日
异常检测(Anomaly Detection)综述
极市平台
20+阅读 · 2020年10月24日
Xsser 一款自动检测XSS漏洞工具
黑白之道
14+阅读 · 2019年8月26日
GitHub 热门:别再用 print 输出来调试代码了
Python开发者
27+阅读 · 2019年4月24日
动手写机器学习算法:异常检测 Anomaly Detection
七月在线实验室
11+阅读 · 2017年12月8日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
19+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
19+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员