Container operation control method, device, electronic device and readable storage medium

By setting up monitoring points in the container environment and judging the legality of the process of file operation events, blocking illegal processes solves the problem of ransomware defense in the existing technology being difficult to ensure the security of data files, and realizes real-time monitoring of data files in the container environment. Protection and safety assurance.

CN117407118BActive Publication Date: 2024-09-27BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202210806756.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-08
Publication Date
2024-09-27
Estimated Expiration
2042-07-08

AI Technical Summary

Technical Problem

In a container environment, existing ransomware defense methods cannot ensure the security of data files. In particular, during and after detection, there is a risk of misjudgment and file encryption and tampering, and it is difficult to block attacks by illegal processes.

Method used

By collecting container asset information, setting up monitoring points to monitor file operation events, and judging the legality of the process based on pre-configured prevention and control strategies, blocking the operation of illegal processes, achieving prior defense and ensuring that data files are not maliciously encrypted and tampered with.

Benefits of technology

It effectively reduces the risk of misjudgment of ransomware attacks, realizes real-time monitoring and protection of data files in the container environment, and ensures the security of data files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117407118B
    Figure CN117407118B
Patent Text Reader

Abstract

The present invention discloses a container operation control method, device, electronic device and readable storage medium. The method includes: collecting container asset information of containers running on a host; determining the target container to be monitored and the prevention and control policy corresponding to the target container according to the container asset information through a policy controller, and setting a monitoring point in the file system namespace of the target container for the designated file directory of the target container; monitoring events related to the designated file directory of the target container through the monitoring point, and when a file operation event is monitored, calling the prevention and control policy corresponding to the target container to determine whether the process triggering the file operation event is an illegal process; when it is determined that the process of the file operation event is an illegal process, refusing to respond to the file operation event; when it is determined that the process of the file operation event is not an illegal process, allowing to respond to the file operation event. By implementing the present invention, pre-emptive defense against illegal processes such as ransomware is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data security technology, and in particular to a container operation control method, device, electronic device and readable storage medium. Background Art

[0002] Files in a container environment are volatile. Once the container is restarted, the previously modified file data will be lost and restored to the initial state of the image. To avoid this, a specific directory of the container is usually mounted on the host. For example, important sensitive files such as database files, pictures, videos, and documents are mounted on the host. Therefore, after the container is restarted, the previously modified file data will not be lost and will still be saved on the host's disk. Therefore, by monitoring the read and write of sensitive files mounted in a specific directory, the ransomware can be blocked from deleting or modifying sensitive files, thereby achieving the effect of defending against ransomware attacks.

[0003] At present, in the defense methods of ransomware, placing trap files in a specific directory of the host machine is difficult to ensure that the ransomware process is monitored; the defense methods based on behavioral analysis are prone to misjudgment of the ransomware process; the defense methods based on machine learning need to rely on a large number of training samples. Once the ransomware mutates, there is also the problem of misjudgment. Moreover, the defense methods in the above container environment are all in-process detection or post-detection. Before the analysis and judgment results are obtained, the ransomware attack will continue to occur, and there is still a risk of files being encrypted and tampered with. Therefore, the existing ransomware defense methods are still difficult to ensure the security of data files in the container environment. Summary of the invention

[0004] In view of this, embodiments of the present invention provide a container operation control method, device, electronic device and readable storage medium to solve the problem that the security of data files in a container environment is difficult to ensure.

[0005] According to a first aspect, an embodiment of the present invention provides a container operation control method, comprising: collecting container asset information of a container running on a host; determining a target container to be monitored and a prevention and control policy corresponding to the target container according to the container asset information through a policy controller, and setting a monitoring point in the file system namespace of the target container for a specified file directory of the target container, the monitoring point being used to monitor events related to the specified file directory of the target container; monitoring events related to the specified file directory of the target container through the monitoring point, and when a file operation event is monitored, calling the prevention and control policy corresponding to the target container to determine whether the process triggering the file operation event is an illegal process; when it is determined that the process of the file operation event is an illegal process, refusing to respond to the file operation event; when it is determined that the process of the file operation event is not an illegal process, allowing the response to the file operation event.

[0006] The container operation control method provided by the embodiment of the present invention sets a monitoring point for the file system namespace of the target container through a pre-configured prevention and control strategy that matches the target container, so as to monitor the designated file directory of the target container running on the current host. When a file operation event for the designated file directory is generated, it is determined whether the process executing the file operation event is an illegal process. If the process executing the file operation event is an illegal process, the file operation event is blocked. The method can achieve pre-emptive defense by detecting whether the file operation event that attempts to operate the designated file directory is an illegal process such as ransomware, thereby directly blocking the attack of the illegal process on the designated file directory, ensuring that the data files under the designated file directory of the target container are not maliciously encrypted and tampered with, and effectively ensuring the security of the data files in the container environment.

[0007] In combination with the first aspect, in a first implementation of the first aspect, collecting container asset information of a container running on a host includes: establishing a link with a container platform through an inter-process communication method, the container platform including at least one container; and synchronizing the container asset information of the container running on the host in full through a container interface service, the container asset information including at least a container main process number and a container name.

[0008] The container operation control method provided by the embodiment of the present invention fully synchronizes the container asset information of the container running on the current host, thereby facilitating the subsequent determination of the target container to be protected and avoiding the omission of the target container that needs to be protected.

[0009] In combination with the first implementation of the first aspect, in the second implementation of the first aspect, the method also includes: dynamically monitoring the startup event or deregistration event of the container on the container platform through the container's hook mechanism, and dynamically updating the corresponding container asset information based on the startup event or deregistration event of the container.

[0010] The container operation control method provided by the embodiment of the present invention dynamically monitors the startup events and / or deregistration events of the container on the current host through the container hook mechanism, thereby realizing the dynamic update of the container asset information, ensuring that the container running on the host can achieve full synchronization, and further ensuring the comprehensiveness of container protection.

[0011] In combination with the first implementation manner of the first aspect, in the third implementation manner of the first aspect, the policy controller determines the target container to be monitored and the prevention and control policy corresponding to the target container according to the container asset information, and sets a monitoring point in the namespace of the target container for the specified file directory of the target container, including: calling the policy controller to traverse the container asset information; querying the prevention and control policy set according to the container name of each container, and matching whether there is a corresponding prevention and control policy for the container; when a corresponding prevention and control policy exists, obtaining the main process number of the target container to be monitored, and obtaining the file system namespace descriptor of the target container according to the main process number of the target container; according to the file system namespace descriptor of the target container, switching from the host file namespace to the file system namespace of the target container, and calling the tracking function to set the tracking point of the monitoring point for the specified file directory of the target container.

[0012] The container operation control method provided by the embodiment of the present invention matches the corresponding prevention and control strategy from the prevention and control strategy set through the container name of the target container, so as to accurately identify the target container that needs to be protected, further reduce the scope of container asset protection, and reduce performance consumption. The file system namespace descriptor of the target container is determined by the main process number of the target container, and then the file system namespace descriptor is switched to the file system namespace that needs to be protected through the file system namespace descriptor, and then the corresponding monitoring point is set under the specified file directory of the target container, thereby realizing the protection of the specified file directory in the target container, and being able to perform pre-emptive defense on the protected data files to prevent the protected data files from being maliciously tampered with, and protecting the normal operation of the system where the container is located to the maximum extent.

[0013] In combination with the first implementation manner of the first aspect, in the fourth implementation manner of the first aspect, the events related to the designated file directory of the target container are monitored through the monitoring point, and when a file operation event is monitored, the prevention and control policy corresponding to the target container is called to determine whether the process triggering the file operation event is an illegal process, including: reporting the monitored file operation event to a blocking interceptor, parsing the file operation event through the blocking interceptor, and obtaining the file process number corresponding to the file operation event; comparing the file process number with the main process number of the target container to determine whether the process triggering the file operation event is an illegal process.

[0014] In combination with the fourth implementation of the first aspect, in the fifth implementation of the first aspect, the comparing the file process number with the main process number of the target container to determine whether the process triggering the file operation event is an illegal process includes: when the file process number is inconsistent with the main process number of the target container, determining that the process triggering the file operation event is an illegal process; when the file process number is consistent with the main process number of the target container, determining that the process triggering the file operation event is not an illegal process.

[0015] The container operation control method provided by the embodiment of the present invention effectively determines the legitimacy of the process started in the target container by comparing whether the file process number is consistent with the main process number of the target container, directly passes the file operation event of the legitimate process, and directly blocks the file operation time of the illegal process, effectively reducing the risk of misjudgment of the file operation event.

[0016] In combination with the first aspect, in a sixth implementation of the first aspect, the method further includes: when the container asset information changes, determining the container to be monitored currently running on the host based on the changed container asset information; and dynamically issuing a protection policy to the container to be monitored through the policy controller.

[0017] The container operation control method provided in the embodiment of the present invention dynamically issues protection policies to the monitored container running on the host, thereby realizing dynamic configuration of the protection policies without the need to restart the system to configure the protection policies. This ensures that the data files of the container to be protected can be secure during operation, thereby realizing precise protection of the container.

[0018] According to the second aspect, an embodiment of the present invention provides a container operation control device, including: a collection module, used to collect container asset information of containers running on a host; a monitoring module, used to determine the target container to be monitored and the prevention and control policy corresponding to the target container according to the container asset information through a policy controller, and set a monitoring point in the file system namespace of the target container for the specified file directory of the target container, and the monitoring point is used to monitor events related to the specified file directory of the target container; a judgment module, used to monitor events related to the specified file directory of the target container through the monitoring point, and when a file operation event is monitored, call the prevention and control policy corresponding to the target container to determine whether the process triggering the file operation event is an illegal process; a first response module, used to refuse to respond to the file operation event when it is determined that the process of the file operation event is an illegal process; a second response module, used to allow response to the file operation event when it is determined that the process of the file operation event is not an illegal process.

[0019] According to a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the container operation control method described in the first aspect or any embodiment of the first aspect by executing the computer instructions.

[0020] According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the container operation control method described in the first aspect or any embodiment of the first aspect.

[0021] It should be noted that, for the corresponding beneficial effects of the container operation control device, electronic device, and computer-readable storage medium provided in the embodiments of the present invention, please refer to the description of the corresponding contents in the container operation control method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 is an architectural diagram of a defender according to an embodiment of the present invention;

[0024] Figure 2is a flowchart of an implementation method of a container operation control method according to an embodiment of the present invention;

[0025] Figure 3 is a flowchart of a container operation control method according to an embodiment of the present invention;

[0026] Figure 4 is another flow chart of a container operation control method according to an embodiment of the present invention;

[0027] Figure 5 is another flow chart of a container operation control method according to an embodiment of the present invention;

[0028] Figure 6 is a flow chart of collecting container asset information according to an embodiment of the present invention;

[0029] Figure 7 is a flow chart of setting monitoring points based on a prevention and control strategy according to an embodiment of the present invention;

[0030] Figure 8 is a flow chart of a release / blocking file operation event according to an embodiment of the present invention;

[0031] Fig. 9 is a structural block diagram of a container operation control device according to an embodiment of the present invention;

[0032] Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0034] At present, there are several main methods for defending against ransomware in container environments: 1) placing trap files in a specific directory of the host machine; 2) detecting the behavioral characteristics of file operation events based on behavioral analysis methods; 3) building a classifier model based on machine learning. However, since trap files have certain characteristics compared to normal sensitive files, ransomware can bypass these trap files and not perform encryption attacks, thus avoiding being monitored and discovered; the method based on behavioral analysis is essentially anomaly detection, and if the threshold is not set reasonably, it is easy to make a misjudgment; the method based on machine learning relies on the number, completeness, scenario coverage and adaptability of training samples. Once the ransomware mutates, it is also easy to make a misjudgment.

[0035] Based on this, the technical solution of the present invention monitors the read and write operations of sensitive directories or files in a specific container. Once it is found that an illegal process such as ransomware deletes or modifies them, the operation is directly blocked. The purpose of defending against attacks by illegal processes such as ransomware is achieved through pre-emptive defense measures, ensuring that protected data files will not be maliciously tampered with or encrypted.

[0036] The embodiment of the present invention provides a defender architecture diagram of a container environment, such as Figure 1 As shown, the defender includes a container asset collector, a policy controller and a blocking interceptor. Among them, the asset collector is mainly responsible for collecting the asset information of the docker container running on the current host. These container asset information are the security protection objects; the policy controller is mainly responsible for the configuration of the prevention and control strategy, that is, setting the corresponding prevention and control strategy for the target container to be protected. Specifically, it can be done through the Fanotify mechanism of the Linux kernel (Fanotify is a mechanism for notifying file system changes, that is, a file monitoring mechanism. This mechanism supports technicians to determine whether to open or close files according to actual needs, and write the judgment result of opening or closing files into the Linux kernel, and the Linux kernel will execute the judgment result), and set monitoring points for the specified file directory in the container; the blocking interceptor is mainly responsible for monitoring file operation events for the specified file directory, and determining whether the process executing the file operation event is legal based on the prevention and control strategy. Once it is determined to be an illegal process, the current file operation event is directly blocked to achieve the defense purpose. For the above implementation process, please refer to Figure 2 shown.

[0037] By utilizing the single characteristic of container behavior, the legitimacy of newly started processes in the container can be accurately and effectively determined. Different from the defense method of ransomware attacks in traditional host environments, based on the Linux kernel Fanotify mechanism, a release strategy is adopted for file operation events of legitimate processes, and a blocking strategy is adopted for file operation events of illegal processes, effectively reducing the risk of misjudgment. Once a ransomware attack occurs, the attack behavior can be directly blocked, thereby achieving pre-emptive defense and ensuring that protected data files will not be maliciously encrypted or tampered with by ransomware.

[0038] According to an embodiment of the present invention, an embodiment of a container operation control method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0039] In this embodiment, a container operation control method is provided, which can be used for electronic devices having the above defender architecture, such as a host. Figure 3 is a flow chart of a container operation control method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:

[0040] S11, collecting container asset information of the container running on the host.

[0041] A container is an isolated operating system space formed at the host kernel operating system layer, used to run specific services. Container asset information is the metadata information corresponding to all containers running on the current host, which is used to characterize the relevant information of specific services running on each container. Container asset information includes information such as file mount path, container name, and main process number of the container.

[0042] Specifically, the host can deploy applications running in containers through container engine technology, such as Docker. There are usually one or more running containers on the host. The host can communicate with the container through the interface provided by the container engine to obtain the currently running containers and collect the container asset information of all containers, so as to facilitate the subsequent real-time monitoring of the running status of specific services in the container environment.

[0043] S12, determining the target container to be monitored and the prevention and control policy corresponding to the target container according to the container asset information through the policy controller, and setting a monitoring point in the file system namespace of the target container for the designated file directory of the target container.

[0044] The monitoring point is used to monitor events related to the specified file directory of the target container.

[0045] As mentioned above, the policy controller is mainly responsible for configuring the prevention and control policies of the containers running on the host. The collected container asset information is used to determine whether there is a target container to be monitored in the containers running on the host. The target container is a specific container that contains a specified file directory and needs to be protected. The target container can be one or more, and is not specifically limited here.

[0046] The prevention and control strategy is a pre-set security protection strategy based on whether the target container has a specified file directory that needs to be protected. The specified file directory is the mount path of sensitive files (such as database files, pictures, videos, and documents) in the container environment.

[0047] When the policy controller detects that a control policy is set for a container, it indicates that the container is a target container to be monitored. At this time, in order to prevent it from being modified, deleted or encrypted by malicious programs such as ransomware, the host can set a monitoring point in the file system namespace of the target container for the specified file directory in the container environment according to the control policy pre-configured in the target container, so as to monitor the relevant events generated for the specified file directory in real time.

[0048] S13, monitoring events related to the specified file directory of the target container through the monitoring point. When a file operation event is monitored, the prevention and control policy corresponding to the target container is called to determine whether the process triggering the file operation event is an illegal process.

[0049] Through the monitoring point, the events related to the specified file directory of the target container are listened to to determine whether a file operation event for the target file directory has been generated. When a file operation event for the target file directory is generated, it means that there is a process that performs read and write operations on the specified file directory of the target container, and the process may be an illegal process such as ransomware, or it may be a normal read and write operation of the main process of the target container. In order to avoid misjudgment and affect the normal read and write process of the container, the prevention and control strategy corresponding to the target container is called to detect the process that triggers the file operation event to determine whether it is an illegal process.

[0050] S14, when it is determined that the process of the file operation event is an illegal process, refusing to respond to the file operation event.

[0051] When it is determined that the process that triggers the file operation event is an illegal process, it means that the process currently executing the file operation event is not a normal operation of the target container on the specified file directory. At this time, you can directly refuse to respond to the file operation event without having to analyze it after it operates on the specified file directory. This achieves pre-emptive defense against the specified file directory, greatly reducing the possibility of the specified file directory in the target container being attacked.

[0052] S15: When it is determined that the process of the file operation event is not an illegal process, responding to the file operation event is allowed.

[0053] When it is determined that the process that triggers the file operation event is not an illegal process, it means that the process that executes the file operation event is a legal process. At this time, the response to the file operation event generated for the specified file directory is allowed, and the legal process is released smoothly to ensure the normal operation of the container.

[0054] The container operation control method provided in this embodiment sets a monitoring point for the file system namespace of the target container through a pre-configured prevention and control strategy that matches the target container, so as to monitor the specified file directory of the target container running on the current host. When a file operation event that attempts to operate the specified file directory is detected, it is detected to determine whether the file operation event is an illegal process such as ransomware, thereby achieving pre-emptive defense and directly blocking attacks on the specified file directory by illegal processes, ensuring that the data files under the specified file directory of the target container are not maliciously encrypted and tampered with, and effectively ensuring the security of data files in the container environment.

[0055] In this embodiment, a container operation control method is provided, which can be used for electronic devices having the above system architecture, such as a host, etc. This embodiment takes the host as an example. Figure 4 is a flow chart of a container operation control method according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:

[0056] S21, collecting container asset information of the container running on the host.

[0057] Specifically, the above step S21 may include:

[0058] S211, establishing a link with a container platform through an inter-process communication method, where the container platform includes at least one container.

[0059] During operation, the electronic device can establish data communication with the container platform through inter-process communication, and then monitor at least one container included in the container platform in real time through the data communication, and obtain the operating status of the container in real time.

[0060] S212, fully synchronize the container asset information of the container running on the host through the container interface service, where the container asset information at least includes the container main process number and the container name.

[0061] The container platform provides an interface service, through which the container asset information of all containers running on the current host node can be fully synchronized, and the container asset information of all containers can be stored in the form of a container list. The container asset information may include: container name, container main process, file mount path, image name, etc.

[0062] Specifically, Figure 1 Taking the system architecture shown in the figure as an example, the asset collector establishes a communication connection with the docker container platform through the Unix Socket communication file docker.sock, as shown in Figure 6As shown. All containers on the current host node are fully synchronized through the docker interface communication service (docker API) to obtain the container asset information of all containers on the current host node, including: container name Cname, container main process number Pid, ​​specified file directory (i.e. file mount path MountPath) and container image name ImageName, etc.

[0063] Optionally, the above step S21 may include:

[0064] S213, dynamically monitoring the startup event or deregistration event of the container on the container platform through the container hook mechanism, and dynamically updating the corresponding container asset information based on the startup event or deregistration event of the container.

[0065] The container startup event is an operation event for creating a container on the current host, and the container deregistration event is an operation event for destroying a container on the current host. Here, based on the container hook mechanism, the container startup event or deregistration event generated on the container platform can be dynamically monitored, and the container asset information can be dynamically updated according to the container startup event or container deregistration event. The update content includes: adding relevant information of the newly created container to the container asset information, or removing relevant information of the deregistered container from the container asset information.

[0066] Optionally, after the container asset information is dynamically updated, the updated container asset information is cached to the storage space, and the container asset information previously in the storage space is replaced, thereby updating all running containers on the current host, making it easier to view the container asset information currently running on the host.

[0067] Specifically, Figure 6 As shown in the figure, through the container hook mechanism, the startup event and deregistration event of the container during the running process are dynamically monitored. Once the container is dynamically started or deregistered, the container asset information of the container can be dynamically updated. The container asset information obtained in the above process is cached, and the container asset information of all running containers on the current host can be obtained.

[0068] S22, determining the target container to be monitored and the prevention and control policy corresponding to the target container according to the container asset information through the policy controller, and setting a monitoring point in the file system namespace of the target container for the designated file directory of the target container.

[0069] The monitoring point is used to monitor events related to a specified file directory of the target container.

[0070] Specifically, the above step S22 may include:

[0071] S221, calling the policy controller to traverse the container asset information.

[0072] For the target container, there is a corresponding prevention and control policy, that is, the container with the prevention and control policy is the target container that needs to be monitored. The electronic device can call the policy controller to traverse the container asset information of all containers running on the host.

[0073] S222, query the control policy set according to the container name of each container to match whether there is a corresponding control policy for the container.

[0074] The container names of various containers are different. The container name of each container is obtained by traversing the container asset information. The policy controller queries the prevention and control policy set according to the container name of each container to detect whether there is a prevention and control policy matching the container name in the prevention and control policy set.

[0075] S223: When a corresponding prevention and control strategy exists, the main process ID of the target container to be monitored is obtained, and the file system namespace descriptor of the target container is obtained according to the main process ID of the target container.

[0076] When the corresponding prevention and control policy is found in the prevention and control policy set, it means that the container with the prevention and control policy is the target container to be monitored. At this time, the main process number corresponding to the target container can be extracted from the container asset information. There is a one-to-one correspondence between the main process number of the target container and the file system namespace descriptor of the target container. Then, the corresponding file system namespace descriptor can be determined according to the main process number of the target container.

[0077] S224, according to the file system namespace descriptor of the target container, switch from the host file namespace to the file system namespace of the target container, and call the tracking function to set the tracking point of the specified file directory of the target container.

[0078] The file system namespace descriptor can represent the file system namespace of the target container. Through the file system namespace descriptor of the target container, the host file namespace can be switched to the file system namespace corresponding to the file system namespace descriptor.

[0079] The tracking function is used to set the tracking point of the monitoring point in the specified file directory. By calling the tracking function, the monitoring point is set in the specified file directory of the target container to monitor whether the specified file directory is subjected to abnormal operations. In this way, the protection of the specified file directory in the target container is realized, and the protected data files can be defended in advance to prevent the protected data files from being maliciously tampered with.

[0080] Specifically, Figure 1Taking the system architecture shown in the figure as an example, the control policy sent to the target container by the policy controller sets the monitoring point for the specified file directory in the target container to monitor the file operation events generated for the specified file directory in the target container. Figure 7 As shown, the specific implementation process is as follows:

[0081] 1) Traverse the container asset information, query the control policy set according to the container name, and determine whether there is a control policy matching the container name in the control policy set. If there is no control policy matching the container name, skip the container directly without processing; otherwise, proceed to step 2);

[0082] 2) Obtain the main process number Pid of the target container. According to the main process number Pid, ​​the file system namespace descriptor cfd of the target container can be obtained, and the file system namespace corresponding to the file system namespace descriptor cfd is determined. The specific method of obtaining the file system namespace descriptor cfd is as follows:

[0083] cfd=open( / proc / <pid> / ns / mnt,O_RDONLY)

[0084] 3) Call the namespace switching function setns() to switch the host file namespace to the file system namespace of the target container. The specific implementation method is as follows:

[0085] setns(cfd,0)

[0086] 4) Call the initialization function of Linux kernel Fanotify to perform monitoring initialization on the target container. The specific implementation method is as follows;

[0087] FD=fanotify_init(FAN_CLOEXEC|FAN_CLASS_CONTENT,O_RDONLY|O_CLOEXEC|O_LARGEFILE|O_NOATIME)

[0088] 5) Call the tracking function of Fanotify to set the tracking point of the specified file directory of the target container (for example: / data). The specific implementation method is as follows:

[0089] fanotify_mark(fd,FAN_MARK_ADD|FAN_MARK_MOUNT,FAN_CLOSE_NO WRITE|FAN_CLOSE_WRITE,AT_FDCWD," / data")

[0090] 6) Call the namespace switching function setns() to switch back to the host file namespace. The specific implementation is as follows:

[0091] setns(hostfd,0)

[0092] This completes the tracking point setting for the specified file directory of the target container.

[0093] 7) Repeat the above steps to complete the setting of monitoring points for the specified file directories of all target containers with prevention and control policies set.

[0094] As an optional implementation, the above method may further include:

[0095] When the container asset information changes, the container to be monitored currently running on the host is determined based on the changed container asset information, and the protection policy is dynamically issued to the container to be monitored currently running on the host through the policy controller.

[0096] Since the containers running on the host are not static, there is a process of container startup or container death. The collected container asset information is monitored to determine whether the container asset information has changed. When the container asset information has changed, the container currently running on the host is determined based on the changed container asset information, and whether a protection policy needs to be issued for a new container to be monitored, or whether a protection policy needs to be issued due to a change in the container execution task, is determined based on the changed container asset information. This allows the configuration of a dynamic protection policy set for each container to be monitored without the need to restart to configure the protection policy, ensuring that the containers that need to be protected can achieve the security of data files, thereby achieving precise protection of the container.

[0097] S23, monitor the events related to the specified file directory of the target container through the monitoring point, and when a file operation event is monitored, call the prevention and control policy corresponding to the target container to determine whether the process that triggers the file operation event is an illegal process. For detailed description, please refer to the relevant description of the above embodiment, which will not be repeated here.

[0098] S24, when it is determined that the process of the file operation event is an illegal process, the file operation event is refused to be responded to. Detailed descriptions refer to the corresponding descriptions of the above embodiments, which will not be repeated here.

[0099] S25, when it is determined that the process of the file operation event is not an illegal process, the file operation event is allowed to be responded to. Detailed descriptions refer to the corresponding descriptions of the above embodiments, which will not be repeated here.

[0100] The container operation control method provided in this embodiment is to synchronize the container asset information of the container running on the current host in full, so as to facilitate the subsequent determination of the target container to be protected and avoid missing the target container that needs security protection. The container hook mechanism dynamically monitors the startup event and / or deregistration event of the container on the current host, realizes the dynamic update of the container asset information, ensures that the container running on the host can achieve full synchronization, and further ensures the comprehensiveness of container protection. The corresponding prevention and control policy is matched from the prevention and control policy set by the container name of the target container, so as to facilitate the accurate identification of the target container that needs to be protected, further reduce the scope of container asset protection, and reduce performance consumption. The file system namespace descriptor of the target container is determined by the main process number of the target container, and then the file system namespace descriptor is switched to the file system namespace that needs to be protected, and then the corresponding monitoring point is set under the specified file directory of the target container, thereby realizing the protection of the specified file directory in the target container, and can perform pre-defense on the protected data file to avoid malicious tampering of the protected data file, and maximize the protection of the normal operation of the system where the container is located.

[0101] In this embodiment, a container operation control method is provided, which can be used for electronic devices having the above system architecture, such as a host, etc. This embodiment takes the host as an example. Figure 5 is a flow chart of a container operation control method according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps:

[0102] S31, collecting container asset information of the container running on the host. For detailed description, please refer to the relevant description of the above embodiment, which will not be repeated here.

[0103] S32, determining the target container to be monitored and the prevention and control policy corresponding to the target container according to the container asset information through the policy controller, and setting a monitoring point in the file system namespace of the target container for the designated file directory of the target container.

[0104] The monitoring point is used to monitor events related to a specified file directory of the target container.

[0105] For detailed description, please refer to the relevant description corresponding to the above embodiments, which will not be repeated here.

[0106] S33, monitoring events related to the specified file directory of the target container through the monitoring point. When a file operation event is monitored, the prevention and control policy corresponding to the target container is called to determine whether the process triggering the file operation event is an illegal process.

[0107] Specifically, the container asset information includes the container main process ID, and the above step S33 may include:

[0108] S331, reporting the monitored file operation event to the blocking interceptor, parsing the file operation event through the blocking interceptor, and obtaining the file process number corresponding to the file operation event.

[0109] As mentioned above, the blocking interceptor can make a legal judgment on the process that executes the file operation event based on the prevention and control strategy. Once the blocking interceptor determines that it is an illegal process, it will directly block the current process from operating the specified file directory, thereby achieving the purpose of defense.

[0110] Real-time monitoring is performed on the operation process of the specified file directory with a monitoring point. When a file operation event for the specified file directory is monitored, the file operation event is reported to the blocking interceptor, which parses the file operation event to obtain the file process number PID, file path, file name, and current file operation type that triggered the file operation event.

[0111] S332, comparing the file process ID with the main process ID of the target container to determine whether the process that triggers the file operation event is an illegal process.

[0112] Since the specified file directory is in the target container, if the main process of the target container operates the specified file directory, the file process ID of the process that triggers the file operation event is consistent with the main process ID of the target container.

[0113] The parsed file process ID is compared with the main process ID of the target container to determine whether the two are consistent, that is, to determine whether the process that triggers the file operation event is an illegal process.

[0114] Specifically, when the file process ID is inconsistent with the main process ID of the target container, it means that the process triggering the file operation event is not the main process of the target container. At this time, it can be directly determined that the process triggering the file operation event is an illegal process.

[0115] Specifically, when the file process number is consistent with the main process number of the target container, it means that the process that triggers the file operation event is the main process of the target container. At this time, it can be determined that the file operation event generated for the specified file directory in the current container environment belongs to a normal business scenario, that is, it is determined that the process that triggers the file operation event is not an illegal process.

[0116] Optionally, the above file operation events include file read operations and / or file write operations, wherein the file read operation is an operation of reading files corresponding to the specified file directory; the file write operation is an operation of modifying, deleting, etc., files corresponding to the specified file directory.

[0117] Specifically, Figure 1 Taking the system architecture shown in the figure as an example, the blocking interceptor is mainly responsible for monitoring the file operation events generated by the specified file directory in the target container reported by Fanotify, and judging whether the process that triggers the file operation event is illegal or legal according to the set prevention and control strategy. If it is an illegal process, Fanotify is notified to intercept the file operation event, otherwise, the file operation event is released.

[0118] like Figure 8 As shown, the specific implementation process is as follows:

[0119] 1) Parse the file operation event for the specified file directory reported by Fanotify, and obtain the corresponding information of the file operation event, which may include: file process number Pid, ​​file path, file name and file operation type, etc., where the file operation type includes file read operation and file write operation.

[0120] 2) Determine whether the process number Pid corresponding to the process that triggers the file operation event is consistent with the main process number Pid corresponding to the main process of the target container. If the two are consistent, it means that the main process of the target container is operating the specified file directory, which is a normal business scenario. At this time, set Fanotify's Response to FAN_ALLOW, that is, directly release the process. If the two are inconsistent, it means that an illegal process (such as a ransomware process) is performing read and write operations on the specified file directory of the target container. At this time, set Fanotify's Response to FAN_DENY, that is, block and intercept the file operation event.

[0121] S34, when it is determined that the process of the file operation event is an illegal process, then the file operation event is refused to be responded to. Detailed descriptions refer to the corresponding descriptions of the above embodiments, which will not be repeated here.

[0122] S35, when it is determined that the process of the file operation event is not an illegal process, the file operation event is allowed to be responded to. For detailed description, please refer to the relevant description of the above embodiment, which will not be repeated here.

[0123] The container operation control method provided in this embodiment effectively determines the legitimacy of the process started in the target container by comparing whether the file process number is consistent with the main process number of the target container. The file operation events of the legitimate process are directly ignored, and the file operation time of the illegal process is directly blocked, thereby effectively reducing the risk of misjudgment of file operation events.

[0124] In this embodiment, a container operation control device is also provided, which is used to implement the above embodiments and preferred implementation modes, and will not be repeated here. The term "module" used below can implement a combination of software and / or hardware for a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0125] This embodiment provides a container operation control device, such as Fig. 9 As shown, including:

[0126] The collection module 51 is used to collect the container asset information of the container running on the host. For detailed description, please refer to the relevant description corresponding to the above method embodiment, which will not be repeated here.

[0127] The monitoring module 52 is used to determine the target container to be monitored and the prevention and control policy corresponding to the target container according to the container asset information through the policy controller, and set a monitoring point in the file system namespace of the target container for the specified file directory of the target container. The monitoring point is used to monitor events related to the specified file directory of the target container. For detailed description, please refer to the relevant description corresponding to the above method embodiment, which will not be repeated here.

[0128] The judgment module 53 is used to monitor events related to the specified file directory of the target container through the monitoring point. When a file operation event is monitored, the prevention and control strategy corresponding to the target container is called to determine whether the process that triggers the file operation event is an illegal process. For detailed description, please refer to the relevant description corresponding to the above method embodiment, which will not be repeated here.

[0129] The first response module 54 is used to refuse to respond to the file operation event when it is determined that the process of the file operation event is an illegal process. For detailed description, please refer to the relevant description corresponding to the above method embodiment, which will not be repeated here.

[0130] The second response module 55 is used to allow responding to the file operation event when it is determined that the process of the file operation event is not an illegal process. Detailed descriptions refer to the corresponding descriptions of the above method embodiments, which will not be repeated here.

[0131] The container operation control device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC circuit, a processor and a memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0132] The container operation control device provided in this embodiment sets a monitoring point for the file system namespace of the target container through a pre-configured prevention and control strategy that matches the target container, so as to monitor the specified file directory of the target container running on the current host. When a file operation event that attempts to operate the specified file directory is detected, it is detected to determine whether the file operation event is an illegal process such as ransomware, thereby achieving pre-emptive defense and directly blocking attacks on the specified file directory by illegal processes, ensuring that data files under the specified file directory of the target container are not maliciously encrypted and tampered with, and effectively ensuring the security of data files in the container environment.

[0133] Optionally, the acquisition module 51 may include:

[0134] The link submodule is used to establish a link with a container platform through an inter-process communication method, and the container platform includes at least one container.

[0135] The synchronization submodule is used to synchronize the container asset information of the container running on the host in full through the container interface service. The container asset information includes at least the container main process number and the container name.

[0136] Optionally, the acquisition module 51 may include:

[0137] The monitoring submodule is used to dynamically monitor the startup event or deregistration event of the container on the container platform through the container's hook mechanism, and dynamically update the corresponding container asset information based on the startup event or deregistration event of the container.

[0138] Optionally, the monitoring module 52 may include:

[0139] The calling submodule is used to call the policy controller to traverse the container asset information.

[0140] The query submodule is used to query the control policy set according to the container name of each container and match whether there is a corresponding control policy for the container.

[0141] The acquisition submodule is used to obtain the main process number of the target container to be monitored when there is a corresponding prevention and control strategy, and obtain the file system namespace descriptor of the target container according to the main process number of the target container.

[0142] The switching submodule is used to switch from the host file namespace to the file system namespace of the target container according to the file system namespace descriptor of the target container, and call the tracking function to set the tracking point of the specified file directory of the target container.

[0143] Optionally, the judgment module 53 may include:

[0144] The parsing submodule is used to report the monitored file operation events to the blocking interceptor, parse the file operation events through the blocking interceptor, and obtain the file process number corresponding to the file operation event.

[0145] The comparison submodule is used to compare the file process ID with the main process ID of the target container to determine whether the process that triggers the file operation event is an illegal process.

[0146] Optionally, the comparison submodule may include:

[0147] The first determination submodule is used to determine that the process triggering the file operation event is an illegal process when the file process ID is inconsistent with the main process ID of the target container.

[0148] The second determination submodule is used to determine that the process triggering the file operation event is not an illegal process when the file process ID is consistent with the main process ID of the target container.

[0149] Optionally, the above file operation events include file read operations and / or file write operations.

[0150] The further functional description of each of the above modules is the same as that of the above corresponding embodiments and will not be repeated here.

[0151] An embodiment of the present invention further provides an electronic device having Fig. 9 The container operation control device shown.

[0152] See also Fig.10 , Fig.10 is a schematic diagram of a structure of a device provided by an optional embodiment of the present invention, such as Fig.10 As shown, the device may include: at least one processor 601, such as a central processing unit (CPU), at least one communication interface 603, a memory 604, and at least one communication bus 602. The communication bus 602 is used to realize the connection and communication between these components. The communication interface 603 may include a display screen (Display), a keyboard (Keyboard), and the optional communication interface 603 may also include a standard wired interface and a wireless interface. The memory 604 may be a high-speed volatile random access memory (Random Access Memory, RAM), or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 604 may optionally be at least one storage device located away from the aforementioned processor 601. The processor 601 may be combined with Fig.10 In the described device, the memory 604 stores an application program, and the processor 601 calls the program code stored in the memory 604 to execute any of the above method steps.

[0153] The communication bus 602 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The communication bus 602 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0154] Among them, the memory 604 may include a volatile memory (English: volatile memory), such as a random-access memory (RAM); the memory may also include a non-volatile memory (non-volatile memory), such as a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory 604 may also include a combination of the above types of memory.

[0155] The processor 601 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP.

[0156] The processor 601 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0157] Optionally, the memory 604 is also used to store program instructions. The processor 601 can call the program instructions to implement the present application Figures 3 to 5 The container operation control method shown in the embodiment.

[0158] The embodiment of the present invention also provides a non-transitory computer storage medium, which stores computer executable instructions, and the computer executable instructions can execute the processing method of the container operation control method in any of the above method embodiments. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memory.

[0159] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.< / pid>

Claims

1. A container operation control method, characterized in that: include: Collect container asset information of containers running on the host; Determine, by means of a policy controller, a target container to be monitored and a prevention and control policy corresponding to the target container according to the container asset information, and set a monitoring point in a file system namespace of the target container for a designated file directory of the target container, the monitoring point being used to monitor events related to the designated file directory of the target container; wherein the target container is a specific container that contains the designated file directory and needs to be protected, and the prevention and control policy is pre-set according to whether the target container has the designated file directory that needs to be protected; Monitor events related to the specified file directory of the target container through the monitoring point, and when a file operation event is monitored, call the prevention and control policy corresponding to the target container to determine whether the process triggering the file operation event is an illegal process; When it is determined that the process of the file operation event is an illegal process, refusing to respond to the file operation event; When it is determined that the process of the file operation event is not an illegal process, responding to the file operation event is allowed.

2. The method according to claim 1, characterized in that The collecting of container asset information of the container running on the host includes: Establishing a link with a container platform by means of inter-process communication, wherein the container platform includes at least one container; The container asset information of the container running on the host is fully synchronized through the container interface service, where the container asset information includes at least the container main process number and the container name.

3. The method according to claim 2, characterized in that The method further comprises: Through the container hook mechanism, the startup event or deregistration event of the container on the container platform is dynamically monitored, and the corresponding container asset information is dynamically updated based on the startup event or deregistration event of the container.

4. The method according to claim 2, characterized in that: The policy controller determines the target container to be monitored and the prevention and control policy corresponding to the target container according to the container asset information, and sets a monitoring point in the namespace of the target container for a designated file directory of the target container, including: Calling the policy controller to traverse the container asset information; Query the prevention and control policy set based on the container name of each container to match whether there is a corresponding prevention and control policy for the container; When a corresponding prevention and control strategy exists, the main process ID of the target container to be monitored is obtained, and the file system namespace descriptor of the target container is obtained according to the main process ID of the target container; According to the file system namespace descriptor of the target container, the host file namespace is switched to the file system namespace of the target container, and the tracking function is called to perform tracking setting of the monitoring point on the designated file directory of the target container.

5. The method according to claim 2, characterized in that: The monitoring point monitors events related to the specified file directory of the target container, and when a file operation event is monitored, calls a prevention and control policy corresponding to the target container to determine whether the process triggering the file operation event is an illegal process, including: Reporting the monitored file operation event to the blocking interceptor, parsing the file operation event through the blocking interceptor, and obtaining the file process number corresponding to the file operation event; The file process ID is compared with the main process ID of the target container to determine whether the process triggering the file operation event is an illegal process.

6. The method according to claim 5, characterized in that The comparing the file process ID with the main process ID of the target container to determine whether the process triggering the file operation event is an illegal process includes: When the file process ID is inconsistent with the main process ID of the target container, determining that the process triggering the file operation event is an illegal process; When the file process ID is consistent with the main process ID of the target container, it is determined that the process triggering the file operation event is not an illegal process.

7. The method according to claim 1, characterized in that Also includes: When the container asset information changes, determining the container to be monitored currently running on the host based on the changed container asset information; The protection policy is dynamically issued to the container to be monitored through the policy controller.

8. A container operation control device, characterized in that: include: A collection module, used to collect container asset information of containers running on the host; A monitoring module, used to determine a target container to be monitored and a prevention and control policy corresponding to the target container according to the container asset information through a policy controller, and set a monitoring point in the file system namespace of the target container for a designated file directory of the target container, wherein the monitoring point is used to monitor events related to the designated file directory of the target container; wherein the target container is a specific container that contains the designated file directory and needs to be protected, and the prevention and control policy is pre-set according to whether the target container has the designated file directory that needs to be protected; a judgment module, configured to monitor events related to a specified file directory of the target container through the monitoring point, and when a file operation event is monitored, call a prevention and control policy corresponding to the target container to determine whether the process triggering the file operation event is an illegal process; A first response module, configured to refuse to respond to the file operation event when it is determined that the process of the file operation event is an illegal process; The second response module is used to allow responding to the file operation event when it is determined that the process of the file operation event is not an illegal process.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the container operation control method according to any one of claims 1 to 7 by executing the computer instructions.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the container operation control method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • System and method for preventing file from being tampered

    CN102902909A

  • Method and system for detecting Android malicious application based on file access dynamic monitoring

    CN105956468A

  • File processing method and device

    CN108959955A

  • Resource association relationship discovery method and apparatus, and electronic device

    CN111221699A

  • System and method for container file integrity monitoring

    CN111324891A