Netinfo Security ›› 2024, Vol. 24 ›› Issue (5): 682-693.doi: 10.3969/j.issn.1671-1122.2024.05.003

Previous Articles     Next Articles

Python Sandbox Escape Defense Mechanism Based on Third-Party Library Isolation

YANG Zhipeng1,2, WANG Juan1,2(), MA Chenjun1,2, KANG Yunfeng3   

  1. 1. School of Cyber Science and Engineering, Wuhan University, Wuhan 430072, China
    2. Key Laboratory of Aerospace Information Security and Trusted Computing of Ministry of Education, Wuhan University, Wuhan 430072, China
    3. Beijing Huawei Digital Technologies Co., Ltd., Beijing 100085, China
  • Received:2023-05-04 Online:2024-05-10 Published:2024-06-24
  • Contact: WANG Juan E-mail:jwang@whu.edu.cn

Abstract:

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%.

Key words: Python sandbox, third-party library isolation, sandbox escape defense mechanism, Hook technology

CLC Number: