Authority management method and device during container operation

By judging the execution of instrumentation code when the container is running and notifying the permission management plug-in, and adjusting process permissions based on security policies, the problem of container escape attacks is solved, the security isolation capability of the container is improved, and data leakage and system paralysis are prevented.

CN118734284AActive Publication Date: 2024-10-01ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410815463.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-10-01
Estimated Expiration
2044-06-21

AI Technical Summary

Technical Problem

The high permission level when the container runtime interacts with the container instance leads to weak security protection and is prone to container escape attacks, leading to data leakage and system paralysis.

Method used

By executing the target process when the container is running, it determines whether the execution of the instrumentation code is triggered, and sends a notification signal to the permission management plug-in. The process permissions are managed based on the preset security policy, and the process permissions are adjusted in real time to avoid interference and complete control. .

Benefits of technology

It effectively strengthens the security isolation capability of the container runtime, prevents information leakage and privilege abuse, and ensures system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734284A_ABST
    Figure CN118734284A_ABST
Patent Text Reader

Abstract

One or more embodiments of the invention provide an authority management method and device during container running, and the method comprises the steps: determining whether to trigger the execution of an instrumentation code or not in a process of executing a target process during container running; wherein the instrumentation code is a code snippet inserted for a code corresponding to an interaction process, and the interaction process is a process interacting with a container instance when the container runs; if the execution of the instrumentation code is triggered, the container sends a notification signal to a plug-in used for performing authority management on a process when running; the plug-in responds to the received notification signal, performs process tracking on the target process, and performs authority management on the target process based on a preset security policy; after the permission management of the target process is completed, the target process after the permission management continues to be executed when the container runs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present application relate to the field of container technology, and in particular, to a method and device for managing permissions during container runtime. Background Art

[0002] Container technology is a lightweight virtualization technology that allows applications and their dependencies to be packaged together to form a portable, self-contained operating environment. By sharing the host machine's operating system kernel resources, containers have the advantages of fast startup, lightweight, and portability.

[0003] Container Runtime refers to the system software responsible for managing and executing the container lifecycle. It is the core component of the container technology stack, responsible for converting packaged container images into running container instances, managing container creation, start, stop, and destruction, and usually providing underlying support functions such as networking, storage, and resource restrictions.

[0004] A container instance is a specific container service unit running on a cloud service platform. It represents a running container, including the container image, configuration parameters, and resources allocated to it (such as CPU, memory, storage, and network).

[0005] The container runtime provides a variety of functions for interacting with container instances. Although these functions enhance the flexibility and operability of container applications, most container escape security incidents are directly related to these functions, forming a weak link in security protection. Specifically, attackers in the container can use the communication and data exchange mechanism between the container and the host to bypass the established security boundary. Through the designed attack strategy, the attacker can not only illegally invade the host's file system and obtain sensitive information, but also execute malicious code at the host level to implement deeper attack operations. The reason why such attacks are possible is largely due to the high privilege level adopted by the container runtime by default when interacting with the container instance, usually the root privilege level. Therefore, such attacks have powerful destructive power and may cause data leakage, service interruption and even comprehensive system paralysis. In view of this, how to manage permissions for the container runtime while maintaining the convenience and efficiency of container technology and strengthen the security isolation capability of the container runtime has become an urgent problem to be solved. Summary of the invention

[0006] One or more embodiments of the present application provide the following technical solutions:

[0007] The present application provides a permission management method for a container runtime, the method comprising:

[0008] The container runtime determines whether to trigger the execution of the plug-in code during the execution of the target process; wherein the plug-in code is a code fragment inserted into the code corresponding to the interactive process, and the interactive process is a process in which the container runtime interacts with the container instance;

[0009] If the execution of the instrumentation code is triggered, the container runtime sends a notification signal to a plug-in for performing permission management on the process;

[0010] The plug-in performs process tracking on the target process in response to the received notification signal, and performs permission management on the target process based on a preset security policy;

[0011] After completing the permission management of the target process, the container continues to execute the target process after the permission management when running.

[0012] The present application also provides a permission management device for a container runtime, the device comprising a container runtime and a plug-in for performing permission management on a process;

[0013] in:

[0014] The container runtime determines whether to trigger execution of the plug-in code during execution of the target process; wherein the plug-in code is a code snippet inserted into the code corresponding to the interactive process, and the interactive process is a process in which the container runtime interacts with the container instance;

[0015] If the execution of the instrumentation code is triggered, the container runtime sends a notification signal to the plug-in;

[0016] The plug-in performs process tracking on the target process in response to the received notification signal, and performs permission management on the target process based on a preset security policy;

[0017] After completing the permission management of the target process, the container continues to execute the target process after the permission management when running.

[0018] The present application also provides an electronic device, comprising:

[0019] processor;

[0020] a memory for storing processor-executable instructions;

[0021] The processor implements the steps of any of the above methods by running the executable instructions.

[0022] The present application also provides a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of any of the methods described above.

[0023] In the above technical solution, during the execution of the target process, the container runtime can determine whether to trigger the execution of the stub code inserted for the code corresponding to the interactive process, where the interactive process is the process in which the container runtime interacts with the container instance. If so, the container runtime can send a notification signal to a plug-in for performing permission management on the process. The plug-in can track the target process in response to the received notification signal and perform permission management on the target process based on a preset security policy. After completing the permission management of the target process, the container runtime can continue to execute the target process after permission management.

[0024] By adopting the above method, through the collaboration between the container runtime and the plug-in used to manage the permissions of the process, the permissions of the processes that interact with the container instance during the container runtime can be managed, and the permissions of such processes can be adjusted in real time and dynamically to prevent such processes from being interfered with or completely controlled, resulting in information leakage and privilege abuse. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The following is a description of the accompanying drawings required for describing the exemplary embodiments, wherein:

[0026] Figure 1 It is a flowchart of a permission management method for container runtime shown in an exemplary embodiment of the present application.

[0027] Figure 2 It is a schematic diagram of a permission management process when a container is running, shown as an exemplary embodiment of the present application.

[0028] Figure 3 It is a structural schematic diagram of a device shown in an exemplary embodiment of the present application.

[0029] Figure 4 It is a block diagram of a permission management device for container runtime shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0030] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description relates to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of the present application. On the contrary, they are only examples consistent with some aspects of one or more embodiments of the present application.

[0031] It should be noted that in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this application. In some other embodiments, the steps included in the method may be more or less than those described in this application. In addition, a single step described in this application may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this application may also be combined into a single step for description in other embodiments.

[0032] In container technology, container runtime refers to the system software responsible for managing and executing the container lifecycle. It is the core component of the container technology stack, responsible for converting packaged container images into running container instances, managing operations such as container creation, starting, stopping, and destroying, and usually providing underlying support functions such as network, storage, and resource restrictions. A container instance refers to a specific container service unit running on a cloud service platform. It represents a running container, including the container image, configuration parameters, and resources allocated to it (such as CPU, memory, storage, and network).

[0033] The container runtime is responsible for background work, such as creating an execution environment, starting containers, managing container lifecycles, and stopping or destroying containers, etc. The container instance is the foreground presentation, corresponding to a specific running container application, which is an execution instance of the container image under specific configuration and resource constraints.

[0034] Specifically, the container runtime is the underlying software that provides a mechanism for creating, running, managing, and destroying containers. It works closely with the operating system kernel and uses technologies such as namespaces and control groups (cgroups) to implement resource isolation, restriction, and measurement to ensure that containers can run in a secure and resource-constrained environment. Common container runtimes include runc, containerd, CRI-O, etc.

[0035] That is, the entire life cycle management of the container instance, from creation, startup, running status monitoring to stopping and destroying, is performed by the container runtime. It provides a series of APIs or command-line tools that make it easy to interact with container instances and control the running status of container instances. The container runtime uses technologies such as namespaces and control groups to create an independent operating environment for each container instance. This not only means that each container instance has its own file system view, network configuration, process ID space, etc., but also can accurately control resource usage (such as CPU shares and memory limits) to prevent a container instance from over-consuming resources and affecting the stability of other container instances or the host. In addition, the container runtime is also responsible for the management of container images, including downloading images from remote repositories to local, decompressing image layers, creating executable root file systems, etc., which is the basis for starting container instances.

[0036] A container instance is a specific entity created and managed by the container runtime. It is created based on a container image and contains an application and its dependent environment. Each container instance represents an independent, portable runtime environment with its own file system, network configuration, process space, etc. Users can customize the behavior of container instances by defining configurations such as container images, environment variables, port mappings, and volume mounts.

[0037] The process of interaction between the container runtime and the container instance may include: providing parameters such as the image name, environment variables, resource limits, etc. through the container runtime's API, and requesting the creation of a container instance; after receiving the request, the container runtime obtains the container image and configures the container's execution environment based on the request parameters; then, the container runtime creates namespaces and control groups on the operating system to isolate and limit container resources, and starts the container instance; during the operation of the container instance, the container runtime continuously monitors the status of the container instance and reports status changes, such as performance indicators, health check results, etc., to the management system through the API; when the container instance is no longer needed, the container runtime responds to stop or delete instructions, cleans up resources, and ends the life cycle of the container instance.

[0038] As the core component for managing and executing containers, the container runtime provides a variety of functions for interacting with container instances to ensure that the running status of container instances can be effectively managed and controlled. The functions of the container runtime interacting with container instances may include: the container runtime allows users to start new container instances or stop running container instances as needed; the container runtime allows users to execute commands inside running container instances, which is very useful for debugging, data query or script execution; the container runtime provides the function of viewing the output log of the container instance, which is crucial for monitoring the running status of the application and troubleshooting; the container runtime can monitor the CPU, memory, disk I / O and other resources used by the container instance, and set resource usage limits to ensure that the container instance does not over-consume host resources; the container runtime supports the configuration of container networks, including assigning IP addresses, setting port mappings, and creating network isolation. The container runtime can mount storage volumes to container instances to persist or share data, as well as share data volumes between container instances; the container runtime can set up a health check mechanism to regularly check whether the container instance is running normally, and decide whether to restart the container instance based on the check results; the container runtime needs to be able to pull, store, and clean up container images to ensure that the container instance has the correct image base when it starts; the container runtime allows files to be copied between the container instance and the host machine to facilitate data exchange or backup; the container runtime provides interactive shell access to the container instance, just like logging directly into the container, which is convenient for manual operation and troubleshooting; and so on.

[0039] A process is the basic unit for resource allocation and scheduling in the operating system. A process can be seen as an instance of a program being executed, which includes the program code itself, the current activity status (such as which line of code is being executed), and the resources allocated to it. When a program is to be executed, the operating system will create a process, allocate memory, CPU time slices, and other necessary resources to the program, and maintain its execution status. Each process has independent memory space, open files, and other resources required for execution.

[0040] Similarly, in the container runtime, processes are the basic unit of resource management and execution. The container runtime interacts with the container instance through processes at the operating system level. Some of the main processes that the container runtime interacts with the container instance can include: the process of starting the container instance; the container runtime daemon process, which is responsible for operations such as creating, running, and stopping container instances; allowing users to execute new commands in the running container without interrupting the original process of the container; allowing users to directly connect to the standard input, output, and error streams of the container to achieve real-time interaction; the process of copying files between the container instance and the host; the process of viewing the process list inside the container instance; the process of displaying the resource usage statistics of the container instance; and so on.

[0041] Since the container runtime is responsible for creating, running, and managing container instances to ensure that they can efficiently and securely access various resources of the underlying system, and since container instances need to interact closely with the host's operating system to utilize operating system kernel resources (such as CPU, memory, I / O, etc.), the container runtime is usually granted root permissions to enable smooth configuration of necessary system services and resources.

[0042] Correspondingly, processes that interact with container instances during container runtime are also granted the same root privileges in order to perform management tasks or pass data. However, this design choice also introduces significant security risks such as container escape. Container escape refers to an attacker exploiting vulnerabilities or configuration flaws in container technology to allow processes or codes that were originally confined to the container to break through the isolation boundary of the container and gain access to the host or other containers. Specifically, malicious code may be hidden inside the container instance, which can interfere with or completely control the processes that interact with the container instance during container runtime through various attack strategies such as code injection and privilege escalation. Once successful, attackers can use the advanced privileges of such processes to leak or tamper with sensitive information on the host, or even execute malicious code in the host's own execution environment or running state, seriously threatening the security and stability of the entire system.

[0043] Although a large number of security checks are introduced during the development of the container runtime to prevent such malicious activities, these security checks cannot cover all process behaviors during the interaction process due to the complexity and dynamic nature of the interaction between the container runtime and the container instance, resulting in the emergence of the above security issues. In addition, during the development of the container runtime, a large number of third-party libraries may be used to expand functions or improve compatibility, and these third-party libraries usually do not contain relevant security checks, which further leads to the above security issues.

[0044] The present application provides a technical solution for implementing permission management for container runtime. In this technical solution, during the execution of the target process, the container runtime can determine whether to trigger the execution of the plug-in code inserted for the code corresponding to the interactive process, and the interactive process is the process in which the container runtime interacts with the container instance. If so, the container runtime can send a notification signal to the plug-in used to manage the permissions of the process. The plug-in can track the target process in response to the received notification signal, and perform permission management on the target process based on the preset security policy. After completing the permission management of the target process, the container runtime can continue to execute the target process after the permission management.

[0045] By adopting the above method, through the collaboration between the container runtime and the plug-in used to manage the permissions of the process, the permissions of the processes that interact with the container instance during the container runtime can be managed, and the permissions of such processes can be adjusted in real time and dynamically to prevent such processes from being interfered with or completely controlled, resulting in information leakage and privilege abuse.

[0046] The technical solution provided in this application can be applied to a server. The server can be a server including an independent physical host, or a server cluster composed of multiple independent physical hosts; or the server can be a virtual server, cloud server, etc. hosted by a host cluster.

[0047] It should be noted that the container runtime and the plug-in for managing permissions of the process are deployed on the above server.

[0048] In this application, in order to implement permission management for the container runtime, strengthen the security isolation capabilities of the container runtime, and avoid container escape security incidents, it is first necessary to capture the processes that interact with the container instance during the execution of the container runtime, and then perform permission management on such executing processes.

[0049] The following describes the process of capturing the interaction between the executing container runtime and the container instance.

[0050] In some embodiments, the process of the container runtime interacting with the container instance may include: a process executed by the container runtime to access the internal file system of the container instance; and / or a process executed by the container runtime to access the network resources of the container instance. Accordingly, the key behaviors that occur during the execution of the process of the container runtime interacting with the container instance may include: opening the internal file of the container instance; and / or connecting to the network resources of the container instance.

[0051] In some embodiments, instrumentation may be used to capture the process of interacting with the container instance during the execution of the container runtime.

[0052] Instrumentation is a software engineering technique that involves inserting additional code snippets (i.e., "stubs") into program code to collect runtime information, monitor program behavior, or modify program execution flow. Instrumentation is divided into static instrumentation and dynamic instrumentation. Static instrumentation occurs during the program compilation phase. It directly modifies the source code or bytecode and inserts the stub code into the target program during compilation. Once the compilation is completed, the stub code becomes a permanent part of the program. Dynamic instrumentation is performed while the program is running and does not modify the original program code. It inserts the stub code after the program is loaded into memory by modifying the program's memory image, using a special runtime environment, or using virtual machine technology.

[0053] During the execution of a process that interacts with a container instance at a container runtime, if an instrumentation code is executed (also referred to as triggering the execution of the instrumentation code), the execution flow can be changed based on the characteristics of the instrumentation code, and permission management can be performed on the process that interacts with the container instance at a container runtime, thereby achieving the capture of the process that interacts with the container instance at a container runtime that is being executed.

[0054] In actual applications, security issues may usually arise from critical behaviors that occur during the execution of processes that interact between the container runtime and the container instance. Therefore, by detecting whether critical behaviors occur during the execution of processes that interact between the container runtime and the container instance, a specific process that is being executed and interacts with the container instance can be captured. In other words, a plugging method can be used to detect whether critical behaviors occur during the execution of processes that interact between the container runtime and the container instance, thereby capturing processes that interact between the container runtime and the container instance that have critical behaviors during the execution.

[0055] In some embodiments, for a process in which a container runtime interacts with a container instance, the code corresponding to the interactive process may include: a source code snippet corresponding to the interactive process in the source code of the container runtime; and / or a source code snippet corresponding to the interactive process in the source code of a third-party library used in the container runtime.

[0056] In some embodiments, in static instrumentation, since the stub code is determined at compile time, the runtime overhead is relatively low. Therefore, taking static instrumentation as an example, the process of detecting whether a critical behavior occurs during the execution of a process that interacts with a container instance when the container is running is described.

[0057] Specifically, the behavior indicated by the source code snippet corresponding to the process of the container runtime interacting with the container instance in the source code of the container runtime and / or the source code of the third-party library used in the container runtime can be statically analyzed. By analyzing the parameter list of the function in the source code snippet, the key behavior of the process of the container runtime interacting with the container instance during execution is identified; for example, the parameter container_path / files of the function open("container_path / files") indicates the internal file of the container instance, and the function indicates opening the internal file of the container instance, which belongs to the key behavior; for another example, the parameter container_network_address of the function connect(container_network_address) indicates the network resource of the container instance, and the function indicates connecting to the network resource of the container instance, which also belongs to the key behavior. In this case, the static stub code can be inserted at the position corresponding to the key behavior, so that when the container runtime is executing the process of interacting with the container instance, if the execution of the stub code is triggered, it can be determined that the process of the container runtime interacting with the container instance has a key behavior during execution.

[0058] In some embodiments, during the instrumentation process, a variety of call graph generation methods can be used, including Rapid Type Analysis (RTA) and pointer analysis, to generate a directed graph that reflects the calling relationship between functions in the above source code, so that the directed graph can be used to assist in identifying key behaviors of processes that interact with container instances during execution when the container is running, thereby completing instrumentation.

[0059] The following describes the permission management of processes that interact with container instances during the execution of the container runtime.

[0060] Please refer to Figure 1 , Figure 1 It is a flowchart of a permission management method for container runtime shown in an exemplary embodiment of the present application.

[0061] The above container runtime permission management method may include the following steps:

[0062] Step 102: The container runtime determines whether to trigger execution of the instrumentation code during execution of the target process; wherein the instrumentation code is a code snippet inserted into the code corresponding to the interactive process, and the interactive process is a process in which the container runtime interacts with the container instance.

[0063] In this embodiment, as mentioned above, the instrumentation method can be used to determine whether the process that interacts with the container instance during the container runtime has a critical behavior during the execution process. That is, during the execution of a process (which can be called the target process) by the container runtime, it can be determined whether to trigger the execution of the instrumentation code; wherein the instrumentation code is a code snippet inserted into the code corresponding to the interactive process, and the interactive process can refer to the process that the container runtime interacts with the container instance.

[0064] Step 104: If the execution of the instrumentation code is triggered, the container runtime sends a notification signal to a plug-in for performing permission management on the process.

[0065] In this embodiment, if the execution of the above-mentioned plug-in code is triggered, it can be determined that the process interacting with the container instance during the container runtime has a critical behavior during execution. In this case, the container runtime can send a notification signal to the plug-in for performing permission management on the process.

[0066] It should be noted that a plug-in is a program written in accordance with a certain standard API, and thus has its corresponding process. The above notification signal may refer to a mechanism for notifying a process of certain events or conditions, which may be a signal itself or other forms of inter-process communication (IPC) mechanisms.

[0067] Step 106: The plug-in performs process tracking on the target process in response to the received notification signal, and performs permission management on the target process based on a preset security policy.

[0068] In this embodiment, the plug-in may perform process tracking on the target process in response to the received notification signal. After the process tracking starts, the plug-in may perform permission management on the target process based on a preset security policy.

[0069] In some embodiments, the notification signal may include the execution context of the target process. When the plug-in performs process tracking on the target process, the plug-in may attach the plug-in to the target process (specifically attach the plug-in process to the context of the target process) based on the system call for process tracking and the execution context of the target process to perform process tracking on the target process.

[0070] System call is a mechanism provided by the operating system for applications to interact with the operating system kernel. It allows programs in user space to request the operating system kernel to perform some privileged operations or access protected resources. In simple terms, when an application needs to perform tasks that only the kernel can perform, such as file I / O operations, process control, memory management, network communication, etc., it needs to be implemented through system calls.

[0071] System calls are not ordinary callable functions, although they may be used in a similar way to function calls, but in fact, system calls involve a transition from user mode to kernel mode. This means that when a system call occurs, the processor changes its working mode and gives the executing code higher permissions so that it can directly access hardware resources and execute privileged instructions.

[0072] That is, the above plug-in can work in user mode and has good adaptability to the expansion of kernel mode data structure and function.

[0073] In some embodiments, the system call for process tracing may be a ptrace (full name: ProcessTrace) system call.

[0074] The main function of the ptrace system call is to allow a process (usually called the debugging process) to monitor and control the execution of another process (the debugged process). The ptrace system call can attach the debugging process to the debugged process. When the debugging process successfully attaches to the debugged process using the ptrace system call, it can monitor and control the execution of the debugged process.

[0075] In some embodiments, when the plug-in performs permission management on the target process based on a preset security policy, the plug-in may specifically perform permission management on the target process based on a system call for process control and the security policy.

[0076] In some embodiments, the system call for process control may be a prctl (full name: ProcessControl) system call.

[0077] The prctl system call is used to control the behavior of a process. This call allows user-mode programs to modify or query certain properties and behaviors of the process in which they are located, thereby enhancing the flexibility and security of process management.

[0078] For the above plug-in, since the plug-in uses the ptrace system call to attach to the above target process, the plug-in can use the prctl system call to modify or query certain properties and behaviors of the target process.

[0079] In some embodiments, the above security policy includes one or more of the following policies: performing process cleanup on the target process when the parent process of the target process terminates; prohibiting the target process from generating a core dump file when it terminates abnormally; prohibiting the target process and its child processes from obtaining additional permissions; and enabling a secure computing mode for the target process.

[0080] Specifically, the PR_SET_PDEATHSIG option in the prctl system call allows a process to set a signal that will be sent to the process when its parent process terminates. This is very useful for ensuring that child processes do not become zombie processes after the parent process terminates unexpectedly. For example, if SIGTERM is set as the death signal, when the parent process ends, the child process will receive the SIGTERM signal and can clean up or terminate itself accordingly.

[0081] The PR_SET_DUMPABLE option in the prctl system call controls whether a core dump file is generated when the process terminates abnormally. A core dump is a snapshot of the process's memory image and is very useful when a program terminates abnormally because it can help developers diagnose the cause of the crash. If set to dumpable, a core dump can be generated even if the process has elevated permissions (such as set by set-user-ID or set-group-ID).

[0082] When the PR_SET_NO_NEW_PRIVS flag in the prctl system call is set to 1, the process and all its child processes will not be able to obtain additional permissions through subsequent operations (such as execve system calls, setting or changing their capabilities through set-user-ID or set-group-ID, etc.). This is a security enhancement that prevents malicious code from escalating permissions by executing other programs in the process. This is particularly important for sandbox environments or services that require strict permission control.

[0083] The PR_SET_SECCOMP option in the prctl system call allows a process to enable or configure secure computing mode (seccomp), which is a security mechanism provided by the Linux kernel that limits the system calls that a process can perform. This is very useful for improving the security of services, especially for applications that do not require a full set of system calls. By limiting system calls, you can reduce the attack surface and prevent potential security threats.

[0084] In actual applications, security policies can also be personalized according to specific operating environments and business needs to adapt to changing application scenarios, combat increasingly complex attack patterns, and ensure the continued security and stability of the system.

[0085] Step 108: After completing the permission management of the target process, the container runtime continues to execute the target process after the permission management.

[0086] In this embodiment, after completing the permission management of the target process, the container runtime may continue to execute the target process after the permission management.

[0087] In some embodiments, as described above, the plug-in can attach (Attach) the plug-in itself to the target process (specifically attaching the plug-in process to the context of another process) based on the system call for process tracking and the execution context of the target process to track the target process. Accordingly, after completing the permission management of the target process, the plug-in can detach (Detach) the target process (specifically detach from the context of the target process and restore to the context of the plug-in itself), and the container runtime can continue to execute the target process after the permission management.

[0088] In some embodiments, the above-mentioned plug-in code can be used to implement a plug-in breakpoint. At this time, if the execution of the plug-in code is triggered, the above-mentioned container runtime can suspend the execution of the above-mentioned target process and send a notification signal to the above-mentioned plug-in. Accordingly, after completing the rights management of the target process, the container runtime can continue to execute the target process after the rights management. In this way, security issues can be avoided in the process of performing rights management on the target process.

[0089] Please refer to Figure 2 , Figure 2 It is a schematic diagram of a permission management process when a container is running, shown as an exemplary embodiment of the present application.

[0090] like Figure 2As shown, first, the code corresponding to the interactive process can be instrumented, and the interactive process is the process that interacts with the container instance during the container runtime. Subsequently, the container runtime can interact with the container instance through the interactive process, and in the process of executing the interactive process, the execution of the instrumented code will be triggered. In the case of triggering the execution of the instrumented code, the interactive process in the container runtime can send a notification signal to the plug-in used to manage the permissions of the process. The plug-in can track the interactive process in response to the received notification signal, and perform permission management on the interactive process based on a preset security policy. After completing the permission management of the interactive process, the container runtime can continue to execute the interactive process after permission management, that is, the container runtime can continue to interact with the container instance through the interactive process after permission management.

[0091] In the above technical solution, during the execution of the target process, the container runtime can determine whether to trigger the execution of the stub code inserted for the code corresponding to the interactive process, where the interactive process is the process in which the container runtime interacts with the container instance. If so, the container runtime can send a notification signal to a plug-in for performing permission management on the process. The plug-in can track the target process in response to the received notification signal and perform permission management on the target process based on a preset security policy. After completing the permission management of the target process, the container runtime can continue to execute the target process after permission management.

[0092] By adopting the above method, through the collaboration between the container runtime and the plug-in used to manage the permissions of the process, the permissions of the processes that interact with the container instance during the container runtime can be managed, and the permissions of such processes can be adjusted in real time and dynamically to prevent such processes from being interfered with or completely controlled, resulting in information leakage and privilege abuse.

[0093] Corresponding to the aforementioned method embodiments, the present application also provides device embodiments.

[0094] Please refer to Figure 3 , Figure 3 It is a structural diagram of a device shown in an exemplary embodiment of the present application. At the hardware level, the device includes a processor 302, an internal bus 304, a network interface 306, a memory 308 and a non-volatile memory 310, and of course may also include other required hardware. One or more embodiments of the present application can be implemented based on software, such as the processor 302 reading the corresponding computer program from the non-volatile memory 310 into the memory 308 and then running it. Of course, in addition to the software implementation, one or more embodiments of the present application do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic module, but can also be hardware or logic devices.

[0095] Please refer to Figure 4 , Figure 4 It is a block diagram of a permission management device for container runtime shown in an exemplary embodiment of the present application.

[0096] The above container runtime permission management device can be applied to Figure 3 The device shown in the figure is used to implement the technical solution of the present application. The device includes a container runtime 402 and a plug-in 404 for performing permission management on a process;

[0097] in:

[0098] The container runtime determines whether to trigger execution of the plug-in code during execution of the target process; wherein the plug-in code is a code snippet inserted into the code corresponding to the interactive process, and the interactive process is a process in which the container runtime interacts with the container instance;

[0099] If the execution of the instrumentation code is triggered, the container runtime sends a notification signal to the plug-in;

[0100] The plug-in performs process tracking on the target process in response to the received notification signal, and performs permission management on the target process based on a preset security policy;

[0101] After completing the permission management of the target process, the container continues to execute the target process after the permission management when running.

[0102] In some embodiments, the notification signal includes an execution context of the target process;

[0103] The process tracking of the target process includes:

[0104] Based on the system call for process tracing and the execution context of the target process, attaching the plug-in to the target process to perform process tracing on the target process;

[0105] After completing the permission management of the target process, the container runtime continues to execute the target process after the permission management, including:

[0106] After completing the permission management of the target process, the plug-in is separated from the target process, and the container continues to execute the target process after the permission management when running.

[0107] In some embodiments, the system call for process tracing is a ptrace system call.

[0108] In some embodiments, the performing permission management on the target process based on a preset security policy includes:

[0109] Based on the system call for process control and the preset security policy, the target process is managed for rights.

[0110] In some embodiments, the system call for process control is a prctl system call.

[0111] In some embodiments, the security policy includes one or more of the following policies:

[0112] When the parent process of the target process is terminated, performing process cleanup on the target process;

[0113] Prohibiting the target process from generating a core dump file when terminating abnormally;

[0114] Prohibit the target process and its child processes from obtaining additional permissions;

[0115] A secure computing mode is enabled for the target process.

[0116] In some embodiments, the instrumentation code is used to implement instrumentation breakpoints;

[0117] If the execution of the plug-in code is triggered, the container runtime sends a notification signal to a plug-in for performing permission management on the process, including:

[0118] If the execution of the instrumentation code is triggered, the container runtime suspends the execution of the target process and sends a notification signal to a plug-in for performing permission management on the process.

[0119] In some embodiments, the process of the container runtime interacting with the container instance includes: a process executed by the container runtime to access the internal file system of the container instance, and / or a process executed by the container runtime to access the network resources of the container instance.

[0120] In some embodiments, the code corresponding to the process of interacting between the container runtime and the container instance includes: a source code snippet corresponding to the process of interacting between the container runtime and the container instance in the source code of the container runtime and / or the source code of a third-party library used in the container runtime; the instrumentation code is a static instrumentation code.

[0121] For the device embodiment, it basically corresponds to the method embodiment, so the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the technical solution of the present application.

[0122] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0123] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0124] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0125] Computer-readable media include permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0126] It should be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0127] The above specific embodiments of the present application are described. Other embodiments are within the scope of the present application. In some cases, the actions or steps recorded in the present application can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the process depicted in the accompanying drawings does not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0128] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings. The term "and / or" refers to and includes any or all possible combinations of one or more associated listed items.

[0129] The description of the terms "one embodiment", "some embodiments", "example", "specific example" or "an implementation method" etc. used in one or more embodiments of the present application means that the specific features or characteristics described in conjunction with the embodiment are included in at least one embodiment of the present application. The schematic description of these terms is not necessarily for the same embodiment. Moreover, the specific features or characteristics described can be combined in a suitable manner in one or more embodiments of the present application. In addition, different embodiments and specific features or characteristics in different embodiments can be combined without contradicting each other.

[0130] It should be understood that, although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determination".

[0131] The above description is merely a preferred embodiment of one or more embodiments of the present application and is not intended to limit one or more embodiments of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present application shall be included in the scope of protection of one or more embodiments of the present application.

[0132] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

Claims

1. A method for managing permissions when a container is running, the method comprising: The container runtime determines whether to trigger the execution of the plug-in code during the execution of the target process; wherein the plug-in code is a code fragment inserted into the code corresponding to the interactive process, and the interactive process is a process in which the container runtime interacts with the container instance; If the execution of the instrumentation code is triggered, the container runtime sends a notification signal to a plug-in for performing permission management on the process; The plug-in performs process tracking on the target process in response to the received notification signal, and performs permission management on the target process based on a preset security policy; After completing the permission management of the target process, the container continues to execute the target process after the permission management when running.

2. The method according to claim 1, wherein the notification signal includes an execution context of the target process; The process tracking of the target process includes: Based on the system call for process tracing and the execution context of the target process, attaching the plug-in to the target process to perform process tracing on the target process; After completing the permission management of the target process, the container runtime continues to execute the target process after the permission management, including: After completing the permission management of the target process, the plug-in is separated from the target process, and the container continues to execute the target process after the permission management when running.

3. According to the method of claim 2, the system call for process tracking is a ptrace system call.

4. According to the method of claim 1, the performing permission management on the target process based on a preset security policy comprises: Based on the system call for process control and the preset security policy, the target process is managed for rights.

5. The method according to claim 4, wherein the system call for process control is a prctl system call.

6. The method according to claim 5, wherein the security policy comprises one or more of the following policies: When the parent process of the target process is terminated, performing process cleanup on the target process; Prohibiting the target process from generating a core dump file when terminating abnormally; Prohibit the target process and its child processes from obtaining additional permissions; A secure computing mode is enabled for the target process.

7. The method according to claim 1, wherein the plug-in code is used to implement the plug-in breakpoint; If the execution of the plug-in code is triggered, the container runtime sends a notification signal to a plug-in for performing permission management on the process, including: If the execution of the instrumentation code is triggered, the container runtime suspends the execution of the target process and sends a notification signal to a plug-in for performing permission management on the process.

8. The method according to claim 1, wherein the interactive process comprises: A process executed by the container runtime to access the internal file system of the container instance, and / or a process executed by the container runtime to access the network resources of the container instance.

9. The method according to claim 1, wherein the code corresponding to the interactive process comprises: A source code snippet corresponding to a process of interaction between the container runtime and a container instance in the source code of the container runtime and / or the source code of a third-party library used in the container runtime; The instrumentation code is a static instrumentation code.

10. A rights management device for a container runtime, the device comprising a container runtime and a plug-in for performing rights management on a process; in: The container runtime determines whether to trigger execution of the plug-in code during execution of the target process; wherein the plug-in code is a code snippet inserted into the code corresponding to the interactive process, and the interactive process is a process in which the container runtime interacts with the container instance; If the execution of the instrumentation code is triggered, the container runtime sends a notification signal to the plug-in; The plug-in performs process tracking on the target process in response to the received notification signal, and performs permission management on the target process based on a preset security policy; After completing the permission management of the target process, the container continues to execute the target process after the permission management when running.

11. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 9 by running the executable instructions.

12. A computer-readable storage medium having computer instructions stored thereon, wherein the instructions are executed by a processor to implement the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Container processing method and device for cloud computing environment, electronic equipment and readable medium

    CN116225755A

  • Container permission detection method and device, equipment and storage medium

    CN116954811A

  • Method for detecting abnormal system call in container and related device

    CN116974685A

  • Container permission-based security control method, device and equipment and storage medium

    CN117931367A

  • Method And System For Automated Agent Injection In Container Environments

    US20180357068A1