Black box API (Application Program Interface) detection method and device of container, electronic equipment and storage medium
By obtaining container feature information and historical detection results, using preset models to generate detection strategies, and multiplex multiple container copy detection results of the same image, solving the problem of inefficient detection of traditional container black box APIs, and achieving efficient and accurate security monitor.
Patent Information
- Application Number
- CN202411220986.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-08-30
AI Technical Summary
Traditional container black box API detection methods are inefficient and difficult to meet the security monitoring needs of modern cloud computing and microservice architectures, especially in terms of the complexity of container technology and multi-replica features.
By obtaining the characteristic information of the container, using preset models to generate detection strategies, combining historical detection results and static vulnerability analysis, targeted black box API detection is carried out, multiplexed detection results of multiple container copies of the same image, and improving detection speed and accuracy.
It improves the efficiency and accuracy of container black box API detection, reduces duplicate detection work, reduces resource consumption, adapts to the multi-copy and mirror immutable characteristics of container technology, and improves security monitoring capabilities.
Smart Images

Figure CN119004484A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a black box API detection method, device, electronic device, and storage medium for a container. Background Art
[0002] With the popularity of cloud computing and microservice architecture, container technology has become the main technology for modern application deployment. The lightweight and dynamic characteristics of containers improve deployment flexibility, but also bring challenges to security monitoring. Traditional container black box API (Application Interface) detection uses traversal and response-based detection methods, which are inefficient and unsatisfactory. Summary of the invention
[0003] The present disclosure provides a black box API detection method, device, electronic device and storage medium for a container.
[0004] The present disclosure adopts the following technical solutions.
[0005] In some embodiments, the present disclosure provides a black box API detection method for a container, comprising:
[0006] Acquiring characteristic information of a first container, where the first container is a container to be detected;
[0007] Inputting the characteristic information of the first container into a preset model to generate a detection strategy for the first container, wherein the preset model is generated based on reference information, the reference information including: characteristic information of a second container, and historical detection results of the second container corresponding to the characteristic information of the second container; the number of the second containers is one or more, and the detection strategy for the first container includes: reusable historical detection results of the first container;
[0008] Perform black box API detection on the first container according to the detection strategy.
[0009] In some embodiments, the present disclosure provides a black box API detection device for a container, comprising:
[0010] An acquiring unit, which acquires characteristic information of a first container, where the first container is a container to be detected;
[0011] a control unit, configured to input the feature information of the first container into a preset model to generate a detection strategy for the first container, wherein the preset model is generated based on reference information, the reference information comprising: feature information of a second container, and historical detection results of the second container corresponding to the feature information of the second container; the number of the second containers is one or more, and the detection strategy for the first container comprises: reusable historical detection results of the first container;
[0012] The control unit is further configured to perform black box API detection on the first container according to the detection strategy.
[0013] In some embodiments, the present disclosure provides an electronic device, comprising: at least one memory and at least one processor;
[0014] The memory is used to store program codes, and the processor is used to call the program codes stored in the memory to execute the above method.
[0015] In some embodiments, the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program code, and when the program code is executed by a processor, the processor is prompted to perform the above method.
[0016] The black box API detection method for containers provided by the embodiments of the present disclosure can reduce the content that needs to be detected in the first container by reusing the existing historical detection results, because the image has a static feature, the detection results of the same image can be reused, and the container has a multi-copy feature, so multiple container copies of the same image can be reused. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that components and elements are not necessarily drawn to scale.
[0018] Figure 1 4 is a flowchart of a black box API detection method for a container according to an embodiment of the present disclosure.
[0019] Figure 2 Schematic diagram of a black box API detection method for a container according to an embodiment of the present disclosure.
[0020] Figure 3 It is a schematic diagram of generating feature information according to an embodiment of the present disclosure.
[0021] Figure 4 It is a schematic diagram of generating a vulnerability report according to an embodiment of the present disclosure.
[0022] Figure 5 Schematic diagram of performing black box API detection of a container according to an embodiment of the present disclosure.
[0023] Figure 6 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0025] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0026] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0027] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0028] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0029] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0030] It should be understood that the various steps described in the method embodiments of the present disclosure can be performed in sequence and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0031] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0032] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0033] It should be noted that the modification of “one” mentioned in the present disclosure is illustrative rather than restrictive, and those skilled in the art should understand that it should be understood as “one or more” unless otherwise clearly indicated in the context.
[0034] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0035] The solution provided by the embodiment of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0036] Glossary:
[0037] Image: An image is a special file system that contains all the code, runtime libraries, environment variables, and configuration information required to run a container. An image does not contain any dynamic data, and its content will not be changed after it is built. It is a static file.
[0038] Image layer: An image layer is an incremental file system change that makes up an image. Each layer represents a state or operation in the image building process, and a complete image is formed by superposition.
[0039] Container: A container is a running instance created based on an image using operating system layer virtualization technology. It has an independent file system, network, and process space, allowing applications to run in an isolated environment. One image can start multiple containers, and each container can be started, stopped, paused, resumed, and deleted.
[0040] Container load: When running, containers also rely on the processor, memory, disk, network and other environments. These environments and containers as a whole are called container load.
[0041] Black-box API detection for containers is a professional security detection method that simulates the behavior of real users or clients to conduct security assessments on APIs without having to understand the internal logic and source code details. This process constructs and sends designed HTTP requests to interact with web applications, covering normal, abnormal, and even potentially malicious inputs to comprehensively detect the responses and behaviors of APIs. The detection tool accurately captures and analyzes the API's response to the request, interpreting key information such as the HTTP status code, response header, and response body. Through in-depth analysis of these response data, the tool can accurately identify possible security vulnerabilities in the API, including but not limited to possible risks such as information leakage, unauthorized access, and insufficient input validation. Tools usually use traversal and detection methods, such as detecting the entire IP address range, port range, or using known API paths and parameter patterns to identify potential API interfaces.
[0042] Traditional black box API detection of containers uses traversal and response-based detection methods, which ignore the characteristics of container technology and face problems such as resource intensiveness, low efficiency, long time consumption, and low detection accuracy. In some embodiments of the present disclosure, by integrating reference information such as the characteristic information of the container, the static vulnerability analysis results, and the black box API detection rule library, the multi-copy characteristics of the container and the immutable characteristics of the image are utilized to collect the second container and the second image in advance for vulnerability detection, and a rule model is constructed based on these data to identify security risks and improve detection speed during actual black box detection.
[0043] In some embodiments of the present disclosure, a black box API detection method for a container load environment is proposed. It can utilize the multi-copy mechanism of the container and the immutable characteristics of the image, obtain the metadata of the second container and the second image through feature collection and analysis to construct feature information; then use the immutable characteristics of the image to perform efficient static detection; then combine the feature information, vulnerability detection, etc. with the rule base of the black box API detection to obtain a preset model; based on the preset model, a specific API detection strategy (target strategy) is customized for the first container to initiate targeted detection. The method in some embodiments of the present disclosure utilizes the multi-copy mechanism of the container and the immutable characteristics of the image to accelerate the detection process and enhance the detection accuracy. The scheme concentrated in the embodiments of the present disclosure is not effective under the host load, because the host is a variable asset, which is easy to change during operation, and the detection results cannot be reused. However, this problem does not exist in the container scenario. The image has an immutable characteristic, and the detection results of the container copy of the same image can be reused, which is an advantage in the container scenario.
[0044] like Figure 1 As shown, Figure 1 and Figure 2 Detailed description of the invention The black box detection method of the present invention includes the following steps.
[0045] S11. Obtain characteristic information of the first container.
[0046] In some embodiments, the first container is a container to be detected, which is an example generated based on the first image. An application can be run on the first container. The feature information generally includes multiple features. Specifically, the feature information of the first container includes, for example: various elements (Repo, Tag, ImageID, etc.), runtime environment (container ID, image hash, etc.), network configuration (IP address, open port, service protocol, etc.).
[0047] S12: Input the feature information of the first container into a preset model to generate a detection strategy for the first container.
[0048] In some embodiments, the preset model is generated based on reference information, and the reference information includes: feature information of the second container, and historical detection results of the second container corresponding to the feature information of the second container. The number of the second containers is one or more, and the detection strategy of the first container includes: reusable historical detection results of the first container. The historical detection results may include, for example, the detection results of the historical black box API of the second container and the detection results of the vulnerability detection of the second image. The historical black box API detection results are the detection results obtained by performing black box API detection on the second container before. Vulnerability detection may be a vulnerability or risk that may exist in the static software information or configuration information obtained by analyzing one or both of them. In some embodiments, the second container is a container, and the number of the second container may be one or more, and the second container is usually multiple. The second image is an image, and the number of the second image may be one or more, and each second image may be different, or the same second image may exist. Any second container may be an instance generated based on a second image. The detection results of the vulnerability detection of the second container describe the risks that it may have, such as the number of the vulnerability that it may have, the configuration information risk of the configuration information, and the degree of the configuration information risk. The black box API detection rule base includes one or more black box API detection rule bases, which describe the rules used when performing black box API detection. The historical black box API detection result is the detection result obtained by performing black box API detection on the second container before.
[0049] In some embodiments, the preset model is used to determine the possible risks based on the feature information and generate the corresponding detection strategy. After obtaining the reference information, a mapping relationship between the feature information and the detection results of the vulnerability detection, the black box API detection rule base and the historical black box API detection results can be established, so as to obtain the association between the feature information of the container and the possible risks. Based on the possible risks, the detection strategy (API detection strategy) can be customized to obtain the relationship between the feature information and the detection strategy, so that after inputting a feature information into the preset model, the detection strategy corresponding to the risk fingerprint can be obtained. The possible risks include, for example, one or more of the vulnerabilities and configuration information risks. Because of the correspondence between the feature information of the second container obtained in advance and its historical detection results, after obtaining the feature information of the first container, the preset model can first determine whether there are historical detection results that the first container can reuse. If so, when performing black box API detection on the first container, the historical detection results can be reused, so that the content in the first container corresponding to the historical detection results is not detected, thereby reducing the detection time and improving the detection speed.
[0050] S13. Perform black box API detection on the first container according to the detection strategy.
[0051] In some embodiments, the first container may be a container instance generated based on the same or partially identical image as the second container. For example, a second container and the first container may be instances of a container of the same image, or a first image based on the first container and a second image based on the second container have a build dependency relationship, and both have partially identical image layers. The first container may have exactly the same feature information as a second container, so that the historical black box API detection results of the second container can be directly reused, without having to perform detection on the first container. The first container may also have some of the same characteristic information as a second container, and the historical detection results of the second container corresponding to the same characteristic information part may also be reused, so that the content corresponding to the same characteristic information part in the first container does not need to be detected. For example, the first image has image layer 1, image layer 2 and image layer 3, and the second image is built based on the first image. The second image has image layer 1, image layer 2, image layer 3, image layer 4 and image layer 5. At this time, the parts of the historical detection results of the second container about image layer 1, image layer 2 and image layer 3 can be reused. For example, if the historical detection results include the detection results of vulnerability detection, then the detection results of vulnerability detection of image layer 1, image layer 2 and image layer 3 can be directly reused without the need to perform vulnerability detection on the repeated image layers in the first image. Similarly, the historical detection results include the historical black box API detection results, and the parts corresponding to image layer 1, image layer 2 and image layer 3 in the historical black box API detection can also be reused. The characteristic information may be a collection of characteristics of the container. The detection strategy is a detection method formulated for a container. In this embodiment, the historical detection results of the second container are reused in the preset model to avoid duplication of work when performing black box API detection on the first container, thereby speeding up the detection as a whole.
[0052] In some embodiments of the present disclosure, because the image has a static feature, the detection results of the same image can be reused, and the container has a multi-copy feature, and multiple container copies of the same image can be reused, so before the first container is detected, the reusable historical detection results are first determined, and the corresponding part of the reusable historical detection results in the first container does not need to be repeatedly detected, which can improve the detection speed. In the traditional host load scenario, since the host is variable, the detection results cannot be reused.
[0053] In some embodiments of the present disclosure, the historical detection results of the second container include: historical black box API detection results of the second container. In some embodiments of the present disclosure, the second container is built from a second image, the second container is an instance of the second image, and the historical detection results of the second container include: detection results of vulnerability detection of the second image.
[0054] In some embodiments, before performing black-box API detection on a container (e.g., a first container or a second container), a static vulnerability detection may be performed on the container first, so that the risks that may exist in the application information and configuration information can be analyzed, so that when performing black-box API detection on the container, attack samples can be prepared for these possible risks in a targeted manner. If the historical detection results include the detection results of the vulnerability detection of the second image, then when performing vulnerability detection on the first container, it can be determined whether there are reusable vulnerability detection results, and if there are reusable ones, they can be reused, thereby reducing the portion of the first container that needs to be vulnerable. Similarly, if the historical detection results include the historical black-box API detection results of the second container, the reusable ones can be reused, thereby reducing the portion of the first container that needs to be black-box API detected.
[0055] In some embodiments of the present disclosure, the feature information of the first container is input into a preset model to generate a detection strategy for the first container, including performing the following operations in the preset model: in response to the feature information of the second container and the feature information of the first container showing that the second container and the first container are instances built from the same image, determining that the reusable historical detection results include: the historical detection results of the second container.
[0056] In some embodiments, in order to improve the detection speed, it is proposed to reuse historical detection results. When two containers are built from the same image, the historical detection results of the second container (such as historical black box API detection results) can be directly reused, because the image is immutable and the container has a multi-copy mechanism. The image that the two rely on must be exactly the same, and the two are just two instances. At this time, when performing black box API detection on the first container, the historical detection results of the second container can be fully reused, so there is no need to detect the first container.
[0057] In some embodiments of the present disclosure, the feature information of the first container is input into a preset model to generate a detection strategy for the first container, including performing the following operations in the preset model: in response to the feature information of the second container and the feature information of the first container showing that the first container is built from a first image, the second container is built from a second image, and the first image and the second image have a construction dependency, determining that the reusable historical detection results of the first container include: the portion of the image layer in the second image that is the same as the first image corresponding to the portion in the historical detection results.
[0058] In some embodiments, the first image and the second image have a build dependency, that is, the first image can be built based on the second image, or the second image can be built based on the first image. In this case, the two have some of the same image layers. For example, the first image includes image layers 1 to 5, and the second image includes image layers 1 to 3. In this case, the historical detection results of image layers 1 to 3 (such as the detection results of vulnerability detection) can be directly reused, thereby avoiding repeated execution of the same detection on image layers 1 to 3 in the first image.
[0059] In some embodiments of the present disclosure, the feature information of the first container is input into a preset model to generate a detection strategy for the first container, including performing the following operations in the preset model: after determining the reusable historical detection results of the first container, determining the detection results of the vulnerability detection of the first image; based on the detection results of the vulnerability detection of the first image, determining the detection strategy for the first container.
[0060] In some embodiments, in a preset model, the detection result of the vulnerability detection of the first image is obtained. When obtaining the detection result of the vulnerability detection of the first image, the detection result of the reusable historical vulnerability detection can be first obtained from the reusable historical detection results, and vulnerability detection is performed only on the part of the first image that does not have the detection result of the reusable historical vulnerability detection. For example, the first image includes static layers 1 to 5. If static layers 1 to 3 already have reusable historical vulnerability detection results, it is only necessary to perform vulnerability detection on static layers 4 and 5 to obtain the detection result of the vulnerability detection of the first image. By performing vulnerability detection, attack samples can be prepared for possible risks to avoid blindly using attack samples. The detection speed can be further improved by reducing attack samples.
[0061] In some embodiments of the present disclosure, the reference information further includes: a black box API detection rule base; the black box API detection rule base includes: black box API detection rules; the detection strategy further includes: black box API detection rules used when performing black box API detection on the first container.
[0062] In some embodiments, the black box API detection rule may describe the method used when performing black box API detection on a container. For example, the Log4j vulnerability that broke out in 2021, also known as Log4Shell, is a remote code execution vulnerability that exists in Apache Log4j 2. Attackers can trigger Log4j to load classes from an external LDAP server by constructing specific input data (usually a string in a network log message) to execute malicious code. The black box API detection rule may include: when a Log4j software package is found, try to detect whether it has the above-mentioned Log4j vulnerability. Because the characteristic information of the first container is obtained, it is possible to determine whether it meets the conditions for using the black box API detection rule based on the characteristic information of the first container. When the conditions are met, the black box API detection rule corresponding to the met conditions can be adopted. The black box API detection rules that meet the conditions will be recorded in the detection strategy, so that these black box API detection rules that meet the conditions will be adopted when performing black box API detection on the first container.
[0063] In some embodiments of the present disclosure, the characteristic information of the first container or the second container is obtained in the following manner: obtaining metadata of a target container and metadata of a target image, wherein the target container is the first container or the second container, and the target container is constructed from the target image, that is, the target image is the first image or the second image; constructing a characteristic association relationship according to the metadata of the target container and the metadata of the target image; and generating characteristic information of the target container according to the characteristic association relationship.
[0064] In some embodiments, Figure 3As shown, in the process of generating feature information, Kubernetes API (for example, using Go client library k8s.io / client-go) and Docker SDK (for example, PHP's docker library) can be used to collect metadata of target containers and target images. Metadata includes but is not limited to warehouse address (repo), label, image ID, software list, active process, open port and running application, etc. Metadata reflects the characteristics. Take obtaining software packages and obtaining running applications as examples. When obtaining software packages, it is necessary to determine the method of collecting software packages in combination with the characteristics of the target image. Specifically, for images based on operating systems such as Debian or Ubentu, the software package list file in the / var / lib / apt / lists / directory can be checked; for images based on RPM, the database file in the / var / lib / rpm / directory can be checked. For the collection of language packages in software packages, the method needs to be determined in combination with the characteristics of the language. For example, the Java language can identify language packages by file extensions (for example, jar, war), and use the Manifest file or jar command to obtain version information. For Go packages, they can be identified by searching for executable files or static link libraries, but since the Go compiled binary files do not contain version information, it may be necessary to combine other content (such as Doceker tags or build history, etc.) for version identification. When obtaining running applications, one or more of process detection, port monitoring, and file inspection can be used to obtain them. When performing process detection, the running application is identified by checking the process list inside the target container. For common applications, they can be identified based on the process name or command line parameters. When performing port monitoring, the running application can be identified by detecting the port monitored by the target container and comparing it with the default port of the known application. When performing file inspection, specific files or directories inside the target container (such as application configuration files, log files, etc.) can be checked to determine the existence of the application and identify the application. In order to improve the accuracy of application identification, the results of the above-mentioned process detection, port monitoring, and file inspection can be combined to comprehensively judge the application in the target container. After obtaining the metadata of the target container and the target image, the metadata can be cleaned and converted into the same data model using a standardized field format, thereby generating features such as the target container, target image, process, software package, and application. In some embodiments, these features are calculated and associated to construct a multi-level feature association graph with the target container as a node and one or more of the target image, software package, application, and configuration information as attributes as a feature association relationship. The attributes associated with the target container can be known through the feature association relationship.In some embodiments, the feature association relationship includes one or more of the following: an instantiation relationship between a target image and a target container, a copy relationship between different target containers, a build relationship between different target images, a mapping relationship between an application and a port, and a mapping relationship between a target container and an application. The instantiation relationship between a target container and a target image can be a mapping constructed by analyzing the ID of an image and a container instance. If one container is an instance of another image, the two have an instantiation relationship. If multiple containers are instances of the same image, there is a copy relationship between the multiple containers. If multiple images are images built based on the same base image, there is a build relationship between the multiple images, and images built based on the same base image can be identified by comparing the image hierarchy. The mapping relationship between an application and a port can characterize the ports used or possessed by an application. The mapping relationship between a target container and an application can characterize the application running in the target container, and the mapping relationship between the target container and the application can be established based on the process, port, and application identifier. After the creation of the feature association relationship is completed, the feature information of the target container is completed according to the feature association relationship, and the feature information may include but is not limited to one or more of the image hash and configuration information. Based on the characteristic information of the target container, preparation is made for the subsequent generation of the preset model, because the characteristic information is created based on the characteristic association relationship, and the attributes related to the characteristic information can be obtained through the characteristic information, such as the related image, software package, application, and configuration information. These attributes can help determine the possible risks of the container with the characteristic information, such as the software package is outdated and the open port is unauthorized. The characteristic information of the target container integrates one or more of the target container metadata, the target image metadata (image ID, etc.), the runtime environment (container ID, image hash value), the application fingerprint (based on the metadata and configuration information of the application) and the network configuration (IP address, open port, service protocol). Multi-dimensional information integration is achieved. And the characteristic information of the target container is updated regularly or in real time, for example, a periodicity is designed to check the changes in metadata regularly, and if there is a change, the characteristic information of the target container is recalculated to ensure that the characteristic information changes over time and the latest state is guaranteed. In some embodiments, an industry standard algorithm (such as SHA-256) can be used to encrypt the characteristic association relationship to generate irreversible characteristic information to ensure data security and privacy protection.
[0065] In some embodiments of the present disclosure, the detection result of the vulnerability detection of the second image is obtained by at least one of the following methods: Method 1: adopting a layered image vulnerability static detection method, performing vulnerability detection on each layer of the second image, and generating the detection result of the vulnerability detection of the second image according to the detection result of the vulnerability detection. Method 2: adopting a layered image vulnerability static detection method, performing configuration information risk detection on each layer of the second image, and generating the detection result of the vulnerability detection of the second image according to the detection result of the configuration information risk detection.
[0066] In some embodiments, reference Figure 4 When performing vulnerability detection on the second image, the detection strategy used for vulnerability detection can be determined first. In this embodiment, taking into account the immutable characteristics of the image, a layered image vulnerability static detection strategy is adopted to perform layer-by-layer vulnerability and configuration information risk detection on each layer (each image layer) of the second image. Vulnerability detection of the second image can be performed periodically at regular intervals. If the second image has been subjected to vulnerability detection, then the next time the vulnerability detection is performed, the newly added or changed image layer of the second image can be marked. In this way, vulnerability detection is only performed on the newly added or changed image layer, which can greatly reduce the workload. After vulnerability detection and configuration risk detection are performed on the second image, the vulnerabilities in the second image and the risks in the configuration information can be obtained. Combining the two, the detection results of vulnerability detection can be obtained.
[0067] In some embodiments of the present disclosure, the detection result of the vulnerability detection of the second image is obtained by at least one of the following methods. Method 1: Obtain the metadata of the second image, and obtain the software information from the metadata of the second image; load the configuration baseline rule base, the vulnerability rule base includes: known vulnerabilities and corresponding software information; perform vulnerability detection according to the software information of the second image and the vulnerability rule base; generate the detection result of the vulnerability detection of the second image according to the detection result of the vulnerability detection. Method 2: Obtain the metadata of the second image, and obtain the configuration information from the metadata of the second image; load the configuration baseline rule base, the configuration baseline rule base includes: expected configuration information; perform configuration information risk detection according to the configuration information of the second image and the configuration baseline rule base; generate the detection result of the vulnerability detection of the second image according to the detection result of the configuration information risk detection.
[0068] In some embodiments, when performing vulnerability detection on the second image, the metadata of the second image is first obtained, for example, including: the second container name or the second image name, version number, operating system type, etc., and software information and configuration information are extracted therefrom. The software information may include system software information and application information. The configuration information may include various configuration items and the values of the configuration items. The vulnerability rule base may include known vulnerabilities of various system software and known vulnerabilities of various applications. In this way, by comparing the software information of the second image with the vulnerability rule base, the possible vulnerabilities of the second image can be obtained as the detection result of the vulnerability detection. The configuration baseline rule base may include expected configuration information, which may include the expected value of the configuration item. The expected configuration information is compared with the actual configuration information of the second image. According to whether they are the same, it can be determined that there may be problems in the configuration information (for example, different parts can be regarded as having risks), and the severity of the problem can be evaluated as the risk detection result of the configuration information. After obtaining the detection results of vulnerability detection and configuration information risk detection, the detection results of vulnerability detection of the second image can be generated, which may include, for example, the vulnerability number, the number of risky configuration information, the severity of the vulnerability, the severity of risky configuration information, etc. The detection results of vulnerability detection can be used to determine the detection strategy for black box API detection of the first container. The preset model can identify the characteristic information of the first container to determine the corresponding vulnerability detection results, find out the vulnerabilities and configuration risks in the first container according to the detection results, and attack the vulnerabilities and configuration risks of the first container, thereby reducing attack samples.
[0069] In some embodiments of the present disclosure, in the process of performing vulnerability detection on the same second image again, when loading the vulnerability rule base, only the part of the vulnerability rule base that has changed compared to the last time the vulnerability detection was performed on the second image is loaded. In some embodiments, in the process of performing vulnerability detection on the same second image again, when loading the configuration baseline rule base, only the part of the configuration baseline rule base that has changed compared to the last time the vulnerability detection was performed on the second image is loaded. For some embodiments, for the second image, it may be subjected to multiple vulnerability detections, for example, a detection cycle may be set to periodically perform vulnerability detection on the second container and the second image. In the process of performing vulnerability detection on the second image other than the first time, when loading the vulnerability rule base, only the part of the vulnerability rule base that has changed compared to the last time the vulnerability detection was performed on the second image can be loaded, so that the last detection result can be reused for the part that has not changed. This can reduce the content that needs to be repeatedly executed for vulnerability detection. Similarly, for the configuration baseline rule base, in the process of performing vulnerability detection on the second image other than the first time, only the part that has changed compared to the last time the vulnerability detection was performed on the second image is loaded.
[0070] In some embodiments of the present disclosure, in the process of generating a preset model based on reference information, an association logic is established to perform a security assessment on the API of the first container, thereby optimizing the detection strategy to improve the speed and accuracy of black box API detection, reduce repeated detection of known safe APIs, and save computing resources. Specifically, the preset model includes at least one item: an association relationship between feature information and a black box API detection rule base, which is used to determine the black box API detection rule in the black box API detection rule base to which the feature information is applicable; a dependency relationship between the black box API detection rules in the black box API detection rule base, which is used to determine the execution order of the black box API detection rules; an API list corresponding to the detection results of vulnerability detection, which is used to indicate the priority detection API associated with the detection results of vulnerability detection; an optimization rule of the black box API detection rule base, which is used to adjust the black box API detection rules in the black box API detection rule base according to configuration information; an API risk grading rule, which is used to perform risk rating on the API according to the historical black box API detection results in the historical detection results; a historical black box API detection result reuse rule, which is used to reuse the historical black box API detection results of the API when an API that has not changed is identified; an association relationship between a vulnerability and a black box API detection rule base, which is used to determine the black box API detection rule corresponding to the vulnerability.
[0071] In some embodiments, there is an association relationship between feature information and a black box API detection rule base in the preset model. After obtaining a certain feature information, the preset model can search for its associated attributes (such as associated images, software packages, applications, configuration information) according to the feature information, and then determine the black box API detection rule base from the black box API detection rule base according to the associated attributes. The determined black box API detection rule base can be used as a detection strategy recommended for the container corresponding to the feature information. For example, if the attribute display associated with the container runs the Tomcat application and identifies its version, configuration file, dependency library and other information, the preset model will automatically match the Tomcat-related black box API detection rule base, such as specific Http response checks, default management interface access attempts, etc., to ensure targeted detection.
[0072] In some embodiments, some or all black box API detection rules have dependencies, for example, rule 2 can be executed only after rule 1 is executed, and the execution result of rule 2 determines whether to execute rule 3 or rule 4. The execution order of black box API detection rules can be determined by the dependencies.
[0073] In some embodiments, in the API list corresponding to the detection result of the vulnerability detection, there are priority detection APIs corresponding to the vulnerability or configuration information risk, which indicates the APIs that need to be detected first when there are these vulnerabilities or configuration information risks. For example, if a container is found to have a vulnerability in the vulnerability detection result, the preset model will mark the APIs affected by the vulnerability so that these APIs will be detected first when performing black box API detection. If the feature information of the first container is the same as the feature information of a second container, and the API list corresponding to the vulnerability detection result of the second container can be obtained, it is indicated in the detection strategy that the API list corresponding to the vulnerability detection result of the second container is detected first. In some embodiments, the optimization rules of the black box API detection rule base can be defined how to adjust the black box API detection rule base according to the configuration information. For example, if the listening port is defined in the configuration information, the black box API detection rule base will be adjusted to send requests only to the listening port. When the container black box API is detected, unnecessary detection can be reduced by considering its configuration information. The API risk grading rules may be used to perform risk rating on the API based on historical black box API detection results. For example, if a certain API is shown in the historical black box API detection results to have an attack frequency higher than a first preset frequency, its risk rating may be increased. If a certain API is shown in the historical black box API detection results to have an attack frequency lower than a second preset frequency, its risk rating may be reduced. In this way, when performing black box API detection on the container's API, the detection depth may be determined based on the API's risk rating. For example, deep detection may be used for APIs with high risk ratings, and lightweight detection or delayed detection may be used for APIs with low risk ratings. In some embodiments, the historical black box API detection results use rules to describe the reuse criteria for the black box API detection results. For example, for APIs and configuration information that have not changed, the preset model may use the historical black box API detection results of the API from the last time to avoid unnecessary repeated detection. For example, if a certain API has not changed since the first black box API, the API may be skipped during the second black box API detection to save resources. In some embodiments, the association between the vulnerability and the black box API detection rule library can be used to determine the black box API detection rule library corresponding to the vulnerability. When a vulnerability is found in the container, the preset model searches for the black box API detection rule library associated with the vulnerability to ensure that potential dangers are covered.
[0074] In some embodiments of the present disclosure, the detection strategy includes: a risk rating of the API of the first container. Performing black box API detection on the first container according to the detection strategy includes: determining the detection priority and / or detection depth of the API of the first container according to the risk rating of the API of the first container; in some embodiments, such as Figure 5In the rule screening part, when performing black box API detection on the first container, deep detection is performed on APIs with high risk ratings, and lightweight detection or delayed detection can be used for low risk APIs, so as to focus on APIs with high risk ratings. High risk rating and low risk rating are relative, and a standard risk rating can be set. Risk ratings higher than the standard risk rating are high risk ratings, and risk ratings lower than the standard risk rating are low risk ratings.
[0075] In some embodiments of the present disclosure, the detection strategy includes: changes in the API of the first container; performing black box API detection on the first container according to the detection strategy, including: for an API that has not changed, reusing the historical black box API detection results corresponding to the API. By reusing the historical black box API detection results of the API that has not changed, invalid detection can be avoided and the detection speed can be improved.
[0076] In some embodiments of the present disclosure, the detection strategy includes: if the feature information of the first container is the same as the feature information of any second container, reuse the historical black box API detection result of the second container. In some embodiments, the feature information of the first container is the same as the feature information of the second container, indicating that the first container is the second container or has the same configuration. If there is a historical black box API detection result of the second container, it can be directly reused.
[0077] In some embodiments of the present disclosure, performing black box API detection on the first container according to the detection strategy includes: caching the detection results of the black box API detection of APIs whose access frequency is greater than a preset frequency and whose security status reaches a preset stability standard. Figure 5 As shown in the caching and result utilization, the detection results of API interfaces that are frequently accessed and have a stable security status can be cached, thereby reducing the time overhead of repeated detection.
[0078] In some embodiments of the present disclosure, black box API detection is performed on the first container according to the detection strategy, including: pre-storing the attack method of the vulnerability, attacking the first container according to the attack method of the vulnerability of the first container, and / or, pre-storing the attack method of the configuration information risk, and attacking the first container according to the attack method of the configuration information risk of the first container. In some embodiments, a database containing the attack method of the vulnerability and the attack method of the configuration information risk can be constructed, so that when a vulnerability or configuration information risk is detected, the corresponding attack method can be quickly obtained from the database, and the black box API detection is performed using the attack method.
[0079] In some embodiments of the present disclosure, Figure 5As shown in the distributed parallel detection in , the black box API detection can be accelerated by the detection accelerator. Specifically, when performing black box API detection, the distributed parallel detection method can be used to decompose the black box API detection task into multiple units, each unit is responsible for a part of the API detection work. A dynamic load balancing algorithm can be used to automatically allocate detection tasks according to the real-time load and performance of each detection node to ensure efficient operation of the nodes. Multithreading or clustering technology can be used to execute multiple detection tasks at the same time to reduce the total time consumption.
[0080] In some embodiments of the present disclosure, the preset model is optimized according to the detection result of the black box API detection of the first container. Figure 5 As shown in the adaptive optimization in , for each black box API detection result, the preset model can be input to optimize the preset model. For example, the black box API detection result of the first container can be added to the historical black box API detection result to regenerate the preset model.
[0081] In some embodiments of the present disclosure, Figure 2 The method in the embodiment of the present disclosure is described. First, a feature collection mechanism is introduced, and metadata of the second container and the second image are collected by a feature collector, and feature association relationships are constructed through these metadata, and feature information of the second container is constructed according to the feature association relationship. Then, by utilizing the immutable characteristics of the image, a vulnerability detection engine is used to implement layered image vulnerability static detection. Vulnerability and configuration information risk detection is performed on each layer of the second image and the second container to obtain the corresponding vulnerability detection results. After obtaining the feature information of the second container and the detection results of the vulnerability detection, the association between the feature information and the possible risks is obtained in combination with the black box API detection rule library, and a preset model is generated based on the association model generator. For the first container, a detection strategy (black box API detection strategy) for the first container is generated based on the preset model, the detection path is optimized, and the detection accelerator performs black box API detection on the first container according to the detection strategy, wherein the detection results can be reused between multiple copies of the container of the same image to avoid duplication of work. Overall, the acceleration of the black box API detection of the first container is achieved. After obtaining the detection results of the black box API detection of the first container, it can be input to the model generator for optimizing the preset model. When the black box API detection is performed again on the first container later, the API and configuration information that have not been changed are checked.
[0082] In some embodiments proposed in the embodiments of the present disclosure, by means of dynamic identification of characteristic information of containers, multiple copies of containers and immutability of images are utilized to dynamically collect and integrate metadata such as container basic information, operating system software packages, language packages, middleware software, applications, configuration information, etc. of images and image layers, to form comprehensive and real-time updated characteristic information. A preset model is generated by matching characteristic information with vulnerabilities. The model is based on container application software, vulnerabilities, and configuration information. Before scanning the black box API, the API of the first container is screened and prioritized according to the preset model, invalid black box API detection rule libraries are filtered out, and a specific black box API detection rule library set matching the first container is generated to ensure that the detection activities are highly targeted, reduce unnecessary traversal, and improve detection efficiency. While improving security, the present disclosure can also effectively reduce detection resources and efficiency, and improve detection accuracy and efficiency.
[0083] The present disclosure also provides a black box detection device, comprising:
[0084] An acquiring unit, which acquires characteristic information of a first container, where the first container is a container to be detected;
[0085] a control unit, configured to input the feature information of the first container into a preset model to generate a detection strategy for the first container, wherein the preset model is generated based on reference information, the reference information comprising: feature information of a second container, and historical detection results of the second container corresponding to the feature information of the second container; the number of the second containers is one or more, and the detection strategy for the first container comprises: reusable historical detection results of the first container;
[0086] The control unit is further configured to perform black box API detection on the first container according to the detection strategy.
[0087] In some embodiments, inputting the characteristic information of the first container into a preset model to generate a detection strategy for the first container includes performing one or more of the following operations in the preset model:
[0088] In response to the feature information of the second container and the feature information of the first container indicating that the second container and the first container are instances built from the same image, determining the reusable historical detection results includes: the historical detection results of the second container;
[0089] In response to the feature information of the second container and the feature information of the first container showing that the first container is built from a first image, the second container is built from a second image, and the first image and the second image have a build dependency relationship, determining that the historical detection result that the first container is reusable includes: a portion of the image layer in the second image that is the same as the first image corresponding to the portion in the historical detection result;
[0090] After determining the reusable historical detection result of the first container, determine the detection result of the vulnerability detection of the first image; and determine the detection strategy of the first container based on the detection result of the vulnerability detection of the first image.
[0091] In some embodiments, the historical detection results of the second container include: historical black box API detection results of the second container, and / or, the second container is built from a second image, and the historical detection results of the second container include: detection results of vulnerability detection of the second image.
[0092] In some embodiments, the reference information further includes: a black box API detection rule base; the black box API detection rule base includes: black box API detection rules;
[0093] The detection strategy also includes: a black box API detection rule used when performing black box API detection on the first container.
[0094] In some embodiments, the characteristic information of the first container or the second container is obtained by:
[0095] Obtain metadata of a target container and metadata of a target image, wherein the target container is a first container or a second container, and the target container is constructed from the target image;
[0096] Building a feature association relationship according to the metadata of the target container and the metadata of the target image;
[0097] The characteristic information of the target container is generated according to the characteristic association relationship.
[0098] In some embodiments, one or more of the following are satisfied:
[0099] The feature association relationship is a feature association graph, wherein the feature association graph takes the target container as a node and takes one or more of the target image, software package, application, and configuration information as association attributes;
[0100] The feature association relationship includes one or more of the following: an instantiation relationship between the target container and the target image, a copy relationship between different containers, a build relationship between different images, a mapping relationship between an application and a port, and a mapping relationship between a target container and an application;
[0101] The characteristic information of the target container includes: one or more of metadata of the target container, metadata of the target image, runtime environment, application program, and network configuration;
[0102] The characteristic information of the first container is updated in real time or periodically.
[0103] In some embodiments, the detection result of the vulnerability detection of the second image is obtained by at least one of the following methods:
[0104] Adopting a layered image vulnerability static detection method, performing vulnerability detection on each layer of the second image, and generating a vulnerability detection result of the second image according to the detection result of the vulnerability detection;
[0105] A layered image vulnerability static detection method is adopted to perform configuration information risk detection on each layer of the second image, and a detection result of the vulnerability detection of the second image is generated according to the detection result of the configuration information risk detection.
[0106] In some embodiments, the detection result of the vulnerability detection of the second image is obtained by at least one of the following methods:
[0107] Obtaining metadata of the second image, and obtaining software information from the metadata of the second image; loading a configuration baseline rule base, wherein the vulnerability rule base includes: known vulnerabilities and corresponding software information; performing vulnerability detection according to the software information of the second image and the vulnerability rule base; and generating a detection result of vulnerability detection of the second image according to the detection result of the vulnerability detection;
[0108] Obtain metadata of the second image, and obtain configuration information from the metadata of the second image; load a configuration baseline rule library, wherein the configuration baseline rule library includes: expected configuration information; perform configuration information risk detection based on the configuration information of the second image and the configuration baseline rule library; and generate a detection result of vulnerability detection of the second image based on the detection result of the configuration information risk detection.
[0109] In some embodiments, at least one of the following is satisfied:
[0110] In the process of performing vulnerability detection again on the same second image, when loading the vulnerability rule library, only the part of the vulnerability rule library that has changed compared to the last time the vulnerability detection was performed on the second image is loaded:
[0111] In the process of performing vulnerability detection on the same second image again, when loading the configuration baseline rule base, only the changed part of the configuration baseline rule base compared with the last vulnerability detection on the second image is loaded.
[0112] In some embodiments, the preset model includes at least one item:
[0113] The association relationship between the feature information and the black box API detection rule base is used to determine the black box API detection rule in the black box API detection rule base to which the feature information is applicable;
[0114] The dependencies of the black-box API detection rules in the black-box API detection rule base are used to determine the execution order of the black-box API detection rules;
[0115] The API list corresponding to the vulnerability detection results is used to indicate the priority detection API associated with the vulnerability detection results;
[0116] An optimization rule of a black box API detection rule base, which is used to adjust the black box API detection rules in the black box API detection rule base according to configuration information;
[0117] API risk grading rules, which are used to rate the risk of APIs based on historical black box API test results in historical test results;
[0118] The historical black box API detection result reuse rule is used to reuse the historical black box API detection results of an API when an API that has not changed is identified;
[0119] The association between the vulnerability and the black-box API detection rule base is used to determine the black-box API detection rule corresponding to the vulnerability.
[0120] In some embodiments, at least one of the following is included:
[0121] The detection strategy includes: a risk rating of the API of the first container; performing black box API detection on the first container according to the detection strategy includes: determining at least one of a detection priority and a detection depth of the API of the first container according to the risk rating of the API of the first container;
[0122] The detection strategy includes: changes in the API of the first container; performing black box API detection on the first container according to the detection strategy, including: for an API that has not changed, reusing a historical black box API detection result corresponding to the API.
[0123] In some embodiments, performing black box API detection on the first container according to the detection strategy includes at least one of the following:
[0124] Cache the detection results of black box API detection for APIs whose access frequency is greater than the preset frequency and whose security status reaches the preset stability standard;
[0125] Pre-store the attack method of the vulnerability, and attack the first container according to the attack method of the vulnerability of the first container;
[0126] An attack method of configuration information risk is pre-stored, and the first container is attacked according to the attack method of the configuration information risk of the first container.
[0127] In some embodiments, the control unit is further configured to optimize the preset model according to a detection result of the black box API detection of the first container.
[0128] For the embodiments of the device, since they basically correspond to the method embodiments, the relevant parts refer to the partial description of the method embodiments. The device embodiments described above are merely illustrative, wherein the modules described as separation modules may or may not be separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of the present embodiment. Those of ordinary skill in the art can understand and implement without paying creative work.
[0129] The method and device of the present disclosure are described above based on the embodiments and application examples. In addition, the present disclosure also provides an electronic device and a computer-readable storage medium, which are described below.
[0130] Reference below Figure 6 , which shows a schematic diagram of the structure of an electronic device (such as a terminal device or a server) 800 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. The electronic device shown in the figure is only an example and should not bring any limitation to the functions and scope of use of the embodiment of the present disclosure.
[0131] The electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0132] Typically, the following devices may be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 808 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or by wire to exchange data. Although the electronic device 800 with various devices is shown in the figure, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have alternatively.
[0133] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0134] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0135] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0136] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0137] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method of the present disclosure.
[0138] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0139] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0140] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0141] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0142] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0143] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, including:
[0144] Acquiring characteristic information of a first container, where the first container is a container to be detected;
[0145] Inputting the characteristic information of the first container into a preset model to generate a detection strategy for the first container, wherein the preset model is generated based on reference information, the reference information including: characteristic information of a second container, and historical detection results of the second container corresponding to the characteristic information of the second container; the number of the second containers is one or more, and the detection strategy for the first container includes: reusable historical detection results of the first container;
[0146] Perform black box API detection on the first container according to the detection strategy.
[0147] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, wherein feature information of the first container is input into a preset model to generate a detection strategy for the first container, including performing one or more of the following operations in the preset model:
[0148] In response to the feature information of the second container and the feature information of the first container indicating that the second container and the first container are instances built from the same image, determining the reusable historical detection results includes: the historical detection results of the second container;
[0149] In response to the feature information of the second container and the feature information of the first container showing that the first container is built from a first image, the second container is built from a second image, and the first image and the second image have a build dependency relationship, determining that the historical detection result that the first container is reusable includes: a portion of the image layer in the second image that is the same as the first image corresponding to the portion in the historical detection result;
[0150] After determining the reusable historical detection result of the first container, determine the detection result of the vulnerability detection of the first image; and determine the detection strategy of the first container based on the detection result of the vulnerability detection of the first image.
[0151] According to one or more embodiments of the present disclosure, a method for detecting a black box API of a container is provided, wherein the historical detection result of the second container includes: the historical black box API detection result of the second container, and / or,
[0152] The second container is constructed from the second image, and the historical detection result of the second container includes: a detection result of a vulnerability detection of the second image.
[0153] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, wherein the reference information further includes: a black box API detection rule base; the black box API detection rule base includes: black box API detection rules;
[0154] The detection strategy also includes: a black box API detection rule used when performing black box API detection on the first container.
[0155] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, wherein the feature information of the first container or the second container is obtained in the following manner:
[0156] Obtain metadata of a target container and metadata of a target image, wherein the target container is a first container or a second container, and the target container is constructed from the target image;
[0157] Building a feature association relationship according to the metadata of the target container and the metadata of the target image;
[0158] The characteristic information of the target container is generated according to the characteristic association relationship.
[0159] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, characterized in that one or more of the following conditions are met:
[0160] The feature association relationship is a feature association graph, wherein the feature association graph takes the target container as a node and takes one or more of the target image, software package, application, and configuration information as association attributes;
[0161] The feature association relationship includes one or more of the following: an instantiation relationship between the target container and the target image, a copy relationship between different containers, a build relationship between different images, a mapping relationship between an application and a port, and a mapping relationship between a target container and an application;
[0162] The characteristic information of the target container includes: one or more of metadata of the target container, metadata of the target image, runtime environment, application program, and network configuration;
[0163] The characteristic information of the first container is updated in real time or periodically.
[0164] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, and the detection result of the vulnerability detection of the second image is obtained by at least one of the following methods:
[0165] Adopting a layered image vulnerability static detection method, performing vulnerability detection on each layer of the second image, and generating a vulnerability detection result of the second image according to the detection result of the vulnerability detection;
[0166] A layered image vulnerability static detection method is adopted to perform configuration information risk detection on each layer of the second image, and a detection result of the vulnerability detection of the second image is generated according to the detection result of the configuration information risk detection.
[0167] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, and a detection result of vulnerability detection of the second image is obtained by at least one of the following methods:
[0168] Obtaining metadata of the second image, and obtaining software information from the metadata of the second image; loading a configuration baseline rule base, wherein the vulnerability rule base includes: known vulnerabilities and corresponding software information; performing vulnerability detection according to the software information of the second image and the vulnerability rule base; and generating a detection result of vulnerability detection of the second image according to the detection result of the vulnerability detection;
[0169] Obtain metadata of the second image, and obtain configuration information from the metadata of the second image; load a configuration baseline rule library, wherein the configuration baseline rule library includes: expected configuration information; perform configuration information risk detection based on the configuration information of the second image and the configuration baseline rule library; and generate a detection result of vulnerability detection of the second image based on the detection result of the configuration information risk detection.
[0170] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, the method comprising at least one of the following:
[0171] In the process of performing vulnerability detection again on the same second image, when loading the vulnerability rule library, only the part of the vulnerability rule library that has changed compared to the last time the vulnerability detection was performed on the second image is loaded:
[0172] In the process of performing vulnerability detection on the same second image again, when loading the configuration baseline rule base, only the changed part of the configuration baseline rule base compared with the last vulnerability detection on the second image is loaded.
[0173] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, wherein the preset model includes at least one of the following:
[0174] The association relationship between the feature information and the black box API detection rule base is used to determine the black box API detection rule in the black box API detection rule base to which the feature information is applicable;
[0175] The dependencies of the black-box API detection rules in the black-box API detection rule base are used to determine the execution order of the black-box API detection rules;
[0176] The API list corresponding to the vulnerability detection results is used to indicate the priority detection API associated with the vulnerability detection results;
[0177] An optimization rule of a black box API detection rule base, which is used to adjust the black box API detection rules in the black box API detection rule base according to configuration information;
[0178] API risk grading rules, which are used to rate the risk of APIs based on historical black box API test results in historical test results;
[0179] The historical black box API detection result reuse rule is used to reuse the historical black box API detection results of an API when an API that has not changed is identified;
[0180] The association between the vulnerability and the black-box API detection rule base is used to determine the black-box API detection rule corresponding to the vulnerability.
[0181] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, the method comprising at least one of the following:
[0182] The detection strategy includes: a risk rating of the API of the first container; performing black box API detection on the first container according to the detection strategy includes: determining at least one of a detection priority and a detection depth of the API of the first container according to the risk rating of the API of the first container;
[0183] The detection strategy includes: changes in the API of the first container; performing black box API detection on the first container according to the detection strategy, including: for an API that has not changed, reusing a historical black box API detection result corresponding to the API.
[0184] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, and black box API detection is performed on the first container according to the detection strategy, including at least one of the following:
[0185] Cache the detection results of black box API detection for APIs whose access frequency is greater than the preset frequency and whose security status reaches the preset stability standard;
[0186] Pre-store the attack method of the vulnerability, and attack the first container according to the attack method of the vulnerability of the first container;
[0187] An attack method of configuration information risk is pre-stored, and the first container is attacked according to the attack method of the configuration information risk of the first container.
[0188] According to one or more embodiments of the present disclosure, a black box API detection method for a container is provided, further comprising:
[0189] The preset model is optimized according to the detection result of the black box API detection of the first container.
[0190] According to one or more embodiments of the present disclosure, a black box API detection device for a container is provided, comprising:
[0191] An acquiring unit, which acquires characteristic information of a first container, where the first container is a container to be detected;
[0192] a control unit, configured to input the feature information of the first container into a preset model to generate a detection strategy for the first container, wherein the preset model is generated based on reference information, the reference information comprising: feature information of a second container, and historical detection results of the second container corresponding to the feature information of the second container; the number of the second containers is one or more, and the detection strategy for the first container comprises: reusable historical detection results of the first container;
[0193] The control unit is further configured to perform black box API detection on the first container according to the detection strategy.
[0194] According to one or more embodiments of the present disclosure, there is provided an electronic device, including: at least one memory and at least one processor;
[0195] The at least one memory is used to store program codes, and the at least one processor is used to call the program codes stored in the at least one memory to execute any one of the above methods.
[0196] According to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium is used to store program code, and when the program code is executed by a processor, the processor is prompted to execute the above method.
[0197] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0198] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0199] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A black box API detection method for a container, characterized in that: include: Acquiring characteristic information of a first container, where the first container is a container to be detected; Inputting the characteristic information of the first container into a preset model to generate a detection strategy for the first container, wherein the preset model is generated based on reference information, the reference information including: characteristic information of a second container, and historical detection results of the second container corresponding to the characteristic information of the second container; the number of the second containers is one or more, and the detection strategy for the first container includes: reusable historical detection results of the first container; Perform black box API detection on the first container according to the detection strategy.
2. The method according to claim 1, characterized in that Inputting the characteristic information of the first container into a preset model to generate a detection strategy for the first container includes performing one or more of the following operations in the preset model: In response to the feature information of the second container and the feature information of the first container indicating that the second container and the first container are instances built from the same image, determining the reusable historical detection results includes: the historical detection results of the second container; In response to the feature information of the second container and the feature information of the first container showing that the first container is built from the first image, the second container is built from the second image, and the first image and the second image have a build dependency relationship, determining that the historical detection result that the first container is reusable includes: a portion of the image layer in the second image that is the same as the first image corresponding to the portion in the historical detection result; After determining the reusable historical detection result of the first container, determining the detection result of the vulnerability detection of the first image; and determining the detection strategy of the first container based on the detection result of the vulnerability detection of the first image.
3. The method according to claim 1, characterized in that The historical detection result of the second container includes: the historical black box API detection result of the second container, and / or, The second container is constructed from the second image, and the historical detection result of the second container includes: a detection result of a vulnerability detection of the second image.
4. The method according to claim 1, characterized in that: The reference information also includes: a black box API detection rule base; the black box API detection rule base includes: black box API detection rules; The detection strategy also includes: a black box API detection rule used when performing black box API detection on the first container.
5. The method according to claim 1, characterized in that The characteristic information of the first container or the second container is obtained in the following manner: Obtain metadata of a target container and metadata of a target image, wherein the target container is a first container or a second container, and the target container is constructed from the target image; Building a feature association relationship according to the metadata of the target container and the metadata of the target image; The characteristic information of the target container is generated according to the characteristic association relationship.
6. The method according to claim 5, characterized in that Meet one or more of the following: The feature association relationship is a feature association graph, in which the target container is a node and one or more of the target image, software package, application and configuration information are association attributes; The feature association relationship includes one or more of the following: an instantiation relationship between the target container and the target image, a copy relationship between different containers, a build relationship between different images, a mapping relationship between an application and a port, and a mapping relationship between a target container and an application; The characteristic information of the target container includes: one or more of metadata of the target container, metadata of the target image, a runtime environment, an application program, and a network configuration; The characteristic information of the first container is updated in real time or periodically.
7. The method according to claim 3, characterized in that The detection result of the vulnerability detection of the second image is obtained by at least one of the following methods: Adopting a layered image vulnerability static detection method, performing vulnerability detection on each layer of the second image, and generating a vulnerability detection result of the second image according to the detection result of the vulnerability detection; A layered image vulnerability static detection method is adopted to perform configuration information risk detection on each layer of the second image, and a detection result of the vulnerability detection of the second image is generated according to the detection result of the configuration information risk detection.
8. The method according to claim 3, characterized in that The detection result of the vulnerability detection of the second image is obtained by at least one of the following methods: Obtaining metadata of the second image, and obtaining software information from the metadata of the second image; Loading a configuration baseline rule base, the vulnerability rule base including: known vulnerabilities and corresponding software information; performing vulnerability detection according to the software information of the second image and the vulnerability rule base; generating a vulnerability detection result of the second image according to the detection result of the vulnerability detection; Obtain metadata of the second image, and obtain configuration information from the metadata of the second image; load a configuration baseline rule library, wherein the configuration baseline rule library includes: expected configuration information; perform configuration information risk detection based on the configuration information of the second image and the configuration baseline rule library; and generate a detection result of vulnerability detection of the second image based on the detection result of the configuration information risk detection.
9. The method according to claim 8, characterized in that The method includes at least one of the following: In the process of performing vulnerability detection again on the same second image, when loading the vulnerability rule library, only the part of the vulnerability rule library that has changed compared to the last time the vulnerability detection was performed on the second image is loaded: In the process of performing vulnerability detection on the same second image again, when loading the configuration baseline rule base, only the changed part of the configuration baseline rule base compared with the last vulnerability detection on the second image is loaded.
10. The method according to claim 1, characterized in that The preset model includes at least one item: The association relationship between the feature information and the black box API detection rule base is used to determine the black box API detection rule in the black box API detection rule base to which the feature information is applicable; The dependencies of the black box API detection rules in the black box API detection rule base, which are used to determine the execution order of the black box API detection rules; The API list corresponding to the vulnerability detection results is used to indicate the priority detection API associated with the vulnerability detection results; An optimization rule of a black box API detection rule base, which is used to adjust the black box API detection rules in the black box API detection rule base according to configuration information; API risk grading rules, which are used to rate the risk of APIs based on historical black box API test results in historical test results; The historical black box API detection result reuse rule is used to reuse the historical black box API detection results of an API when an API that has not changed is identified; The association between the vulnerability and the black-box API detection rule base is used to determine the black-box API detection rule corresponding to the vulnerability.
11. The method according to claim 1, characterized in that: The method includes at least one of the following: The detection strategy includes: a risk rating of the API of the first container; performing black box API detection on the first container according to the detection strategy includes: determining at least one of a detection priority and a detection depth of the API of the first container according to the risk rating of the API of the first container; The detection strategy includes: changes in the API of the first container; performing black box API detection on the first container according to the detection strategy, including: for an API that has not changed, reusing a historical black box API detection result corresponding to the API.
12. The method according to claim 1, characterized in that Performing a black box API test on the first container according to the test strategy includes at least one of the following: Cache the detection results of black box API detection for APIs whose access frequency is greater than the preset frequency and whose security status reaches the preset stability standard; Pre-store the attack method of the vulnerability, and attack the first container according to the attack method of the vulnerability of the first container; An attack method of configuration information risk is pre-stored, and the first container is attacked according to the attack method of the configuration information risk of the first container.
13. The method according to claim 1, characterized in that Also includes: The preset model is optimized according to the detection result of the black box API detection of the first container.
14. A black box API detection device for a container, characterized in that: include: An acquiring unit, which acquires characteristic information of a first container, where the first container is a container to be detected; a control unit, configured to input the feature information of the first container into a preset model to generate a detection strategy for the first container, wherein the preset model is generated based on reference information, the reference information comprising: feature information of a second container, and historical detection results of the second container corresponding to the feature information of the second container; the number of the second containers is one or more, and the detection strategy for the first container comprises: reusable historical detection results of the first container; The control unit is further configured to perform black box API detection on the first container according to the detection strategy.
15. An electronic device, comprising: at least one memory and at least one processor; The at least one memory is used to store program code, and the at least one processor is used to call the program code stored in the at least one memory to execute the method according to any one of claims 1 to 13. 16 . A computer-readable storage medium, the computer-readable storage medium being used to store program code, wherein when the program code is executed by a processor, the processor is prompted to execute the method according to claim 1 .
Citation Information
Patent Citations
A system and a method for statically detecting malicious software in a container
CN110008703A
Object vulnerability detection method and device, medium and electronic equipment
CN111435393A
Container mirror image detection method and device, electronic equipment and storage medium
CN112613041A
Abnormal behavior detection method and device during container running and a model training method and device
CN112860484A
Container security scanning method, device and equipment and storage medium
CN113946824A
