# Design and Implementation of Virtual Security Function Based on Multiple Enclaves
## 1 Introduction  
In traditional solutions, network functions (NF) are usually deployed in proprietary hardware devices. They are increasingly unable to meet the flexible and scalable requirements for the emerging platform, such as cloud computing, edge computing, 5G [1], and Internet of Things. Network function virtualization (NFV) [2] as a new type of network technology can meet these challenges. NFV refers to the use of standard IT virtualization technology to implement network functions in software and deploy on general purpose servers, switches, and storage. Security function virtualization (SFV) has also been proposed to provide agile security functions. Although the simplicity and low cost of NFV accelerate the innovation and market speed of network products, VNFs (virtual network functions), especially virtual security functions, face more security challenges [3, 4] than traditional network functions because VNFs typically operate in a shared, open environment, away from the protection of proprietary hardware. Insiders have malicious access to sensitive information such as virtual network function (VNF) codes and states. Moreover, there is an isolation problem in the NFV architecture itself. Attackers may steal and damage the data of other virtual machines through VM escape. Recently, Software Guard Extensions (SGX) [5] proposed by Intel has provided a promising way to solve the security issues of VNF [6, 7]. SGX only trusts the CPU. Even the operating system, driver, BIOS, or virtualmachine monitor (VMM) cannot access the data and code in the enclave. Therefore, the VNF can be put into the enclave to ensure its runtime security. However, previous works [6; 8; 9] place multiple VNFs in a single SGX enclave which loses the scalability advantage of NFV. First, users cannot scale in/out a single network function because multiple VNFs run in an enclave as a whole. Then, users cannot dynamically modify network functions because the network functions protected by SGX need to be recompiled and redeployed once they are modified. Finally, it makes it difficult to combine new security services by using the existing modules due to the monolithic design with a single enclave. To address these issues, we propose a multi-enclave-based virtual security function architecture by using the security features of SGX and the modularity of Click [10], which is a new software architecture for building flexible and configurable network middle-boxes. In our architecture, the virtual security functions are decomposed into many small elements and modules and then put into multiple enclaves to provide strong confidentiality and integrity guarantees. The system can freely combine these modules according to user requirements, and increase the scalability of the system while protecting its code and running state security. In addition, we design a new hot-swapping scheme to enable the system to dynamically modify the configuration function at run time, so that the original VNFs do not need to stop when the function of VNFs is modified. We implement an intrusion detection system (IDS) based on our architecture to verify the feasibility of our system and evaluate its performance. The results show that the overhead introduced by the system architecture is within an acceptable range. To our knowledge, our work firstly designs and implements a multi-enclave-based virtual security function architecture to enable the VNFs to be scaled dynamically with enclave protection. In this work, we make the following contributions. (1) Propose a multi-enclave-based virtual security function architecture so that the different modules running inside enclaves can be freely combined to new security service according to user requirements. (2) Design a new hot-swapping scheme to enable users to dynamically modify the configuration of VNFs at runtime without stopping the original VNFs when the function of VNFs is modified. (3) Implement an IDS based on our architecture and evaluate its performance.