首页|基于第三方库隔离的Python沙箱逃逸防御机制

基于第三方库隔离的Python沙箱逃逸防御机制

扫码查看
PaaS平台由于可提供Python服务成为目前较受欢迎的云服务.PaaS平台应用Python沙箱解决安全问题,同时允许用户使用Python C化模块以降低Python对性能的影响.然而,攻击者能够利用Python沙箱策略的漏洞进行逃逸,导致危害底层系统.现有的Python沙箱大多在代码层进行防御,缺乏对Python C化模块的监管和防护.文章分析了Python C化模块的底层原理和Python沙箱逃逸的特点,针对沙箱逃逸后需要执行特定危险函数发起攻击的特征,提出一种基于第三方库隔离的Python沙箱逃逸防御机制,并实现了原型系统.该机制的原型系统利用GOT Hook技术对Python的C化模块导入行为和危险函数调用行为进行接管,在Python导入C化模块时,提前对该C化模块进行安全检查和隔离.另外,在Python调用危险函数时,对该函数的参数进行检查.实验结果表明,文章所提机制能够有效防御攻击者利用自定义的C化模块逃逸Python沙箱以及使用恶意参数调用危险函数.在正常使用时,文章所提机制的时间开销较低,平均时间开销小于5%.
Python Sandbox Escape Defense Mechanism Based on Third-Party Library Isolation
The PaaS platform has become a popular cloud service due to its ability to provide Python services.PaaS platform utilizes Python sandboxes to ensure security,while also allowing users to use optimized Python C-modules to reduce the impact of Python on performance.However,attackers can exploit vulnerabilities in Python sandbox policies to escape and harm the underlying system.Most of the existing Python sandboxes are used for defense at the code level,lacking supervision and protection of Python C-modules.This paper analyzed the underlying principles of Python C-modules and the characteristics of Python sandbox escapes.Targeting the specific dangerous functions executed after the sandbox escape,this paper proposed a Python sandbox escape defense mechanism based on third-party library isolation and implemented a prototype system.The prototype system leveraged GOT Hook technology to take over C-module import and dangerous function call in Python.Therefore,the system was capable of checking and isolating C-modules before they were imported.Moreover,when dangerous functions were called,the system checked the parameters.The experimental results demonstrate that the system effectively mitigates attacker's abusively use of custom C-modules to escape Python sandboxes and calling dangerous functions with malicious parameter.The mechanism has negligible overheads in normal Python applications,with an average time overhead of less than 5%.

Python sandboxthird-party library isolationsandbox escape defense mechanismHook technology

杨志鹏、王鹃、马陈军、亢云峰

展开 >

武汉大学国家网络安全学院,武汉 430072

武汉大学空天信息安全与可信计算教育部重点实验室,武汉 430072

北京华为数字技术有限公司,北京 100085

Python沙箱 第三方库隔离 沙箱逃逸防御机制 Hook技术

国家自然科学基金国家重点研发计划国家电网科技项目

618724302020AAA0107700520940210009

2024

信息网络安全
公安部第三研究所 中国计算机学会计算机安全专业委员会

信息网络安全

CSTPCDCHSSCD北大核心
影响因子:0.814
ISSN:1671-1122
年,卷(期):2024.24(5)
  • 1