A security detection method and device, electronic equipment and storage medium
By monitoring and generating dependency graphs, and combining whitelists and hash value comparisons, the problem of not being able to detect dynamic behavior of code at runtime in existing technologies is solved, enabling security detection during system cold starts and improving system security.
Patent Information
- Application Number
- CN202510669105.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies primarily analyze static code and cannot detect dynamic behavior of code at runtime, resulting in relatively low security.
By monitoring the library loading behavior of processes, a dependency graph is generated, and security checks are performed during system cold starts, including whitelist verification and hash value comparison, to identify illegal dependency libraries. When risks are detected, an isolation environment is created to restrict permissions, and process snapshots are captured to generate alarm logs.
It enables timely detection and handling of security threats during code runtime, reducing potential security risks and improving system security.
Smart Images

Figure CN123158633A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of security detection technology, and in particular to a security detection method, apparatus, electronic device and storage medium. Background Technology
[0002] Ensuring code security and the reliability of dependent libraries is crucial during software development and deployment. Traditional security testing methods primarily rely on Static Application Security Testing (SAST). Static code testing is a technique that performs security analysis on source code during the code writing phase or before deployment. SAST tools analyze source code, bytecode, or binary code to identify potential security vulnerabilities, coding errors, and code patterns that do not conform to security standards.
[0003] However, this method mainly analyzes static code and cannot detect dynamic behavior of code at runtime, such as dynamically loaded dependency libraries or security threats in the runtime environment, resulting in relatively low security. Summary of the Invention
[0004] This application provides a security detection method, apparatus, electronic device, and storage medium to solve the problem that existing technologies mainly analyze static code and cannot detect the dynamic behavior of code during runtime, resulting in relatively low security.
[0005] Firstly, this application provides a security detection method, including:
[0006] For any process in the system, monitor the library loading behavior of that process during system operation, wherein each process runs one function instance;
[0007] Obtain the dependency library information corresponding to the library loading behavior, wherein the dependency library information includes the executable file path and the dependency library path;
[0008] Generate a dependency graph corresponding to the process based on the executable file path and the dependent library path;
[0009] During a system cold start, security checks are performed on the function instances running by the process based on the dependency graph.
[0010] In one possible implementation, the security detection of function instances running by the process based on the dependency graph includes:
[0011] Obtain the loading path of the dependent library from the dependency graph;
[0012] For each dependent library, determine whether the loading path of the dependent library is located in the system standard library directory;
[0013] If the loading path is not located in the system standard library directory, check whether the dependent library is in the preset whitelist;
[0014] If the loading path is not located in the system standard library directory and is not in the whitelist, query whether the dependent library is marked as an official dependent library;
[0015] If the dependent library is not marked as an official dependent library, it is determined that the function instance being run by the process poses a security risk.
[0016] In one possible implementation, querying whether the dependency library is marked as an official dependency library includes:
[0017] Extract the name and version number of the dependency library from the dependency graph;
[0018] The blockchain lightweight node calls a smart contract to query the hash value of the official dependency library corresponding to the name and version number;
[0019] Compare the hash value of the local dependency library with the hash value of the official dependency library;
[0020] If the hash value of the local dependency library is inconsistent with the hash value of the official dependency library, it is determined that the dependency library has not been marked as an official dependency library;
[0021] If the hash value of the local dependency library matches the hash value of the official dependency library, the dependency library is identified as an official dependency library.
[0022] In one possible implementation, querying whether the dependency library is marked as an official dependency library includes:
[0023] Extract the name and version number of the dependency library from the dependency graph;
[0024] Initiate a query to the centralized database to obtain the official dependency library hash value corresponding to the name and version number;
[0025] Compare the hash value of the local dependency library with the hash value of the official dependency library;
[0026] If the hash value of the local dependency library is inconsistent with the hash value of the official dependency library, it is determined that the dependency library has not been marked as an official dependency library;
[0027] If the hash value of the local dependency library matches the hash value of the official dependency library, the dependency library is identified as an official dependency library.
[0028] In one possible implementation, generating the dependency graph corresponding to the process based on the executable file path and the dependent library path includes:
[0029] Parse the executable file path and the dependent library path to obtain the name, version number, and loading path of each dependent library;
[0030] Generate a dependency graph based on the name, version number, and loading path of each dependent library;
[0031] The dependency graph is associated with and stored as a unique identifier for the function instance.
[0032] In one possible implementation, the method further includes:
[0033] If a security risk is identified in the function instance, an isolated environment is created;
[0034] Switch the runtime environment of the function instance to the isolated environment;
[0035] The function instance continues to execute in the isolated environment, but its access to external resources is restricted.
[0036] In one possible implementation, the method further includes:
[0037] After switching to the isolated environment, a process snapshot of the function instance is captured, including memory state, file descriptors, and network connection information;
[0038] An alarm log is generated based on the process snapshot;
[0039] The alarm logs are sent to the security monitoring system.
[0040] Secondly, this application provides a security detection device, comprising:
[0041] The monitoring module is used to monitor the library loading behavior of any process in the system during system operation, wherein each process runs one function instance;
[0042] The acquisition module is used to acquire the dependency library information corresponding to the library loading behavior, wherein the dependency library information includes the executable file path and the dependency library path;
[0043] The generation module is used to generate a dependency graph corresponding to the process based on the executable file path and the dependency library path;
[0044] The detection module is used to perform security checks on the function instances running by the process based on the dependency graph during system cold start.
[0045] In one possible implementation, the detection module is specifically used for:
[0046] Obtain the loading path of the dependent library from the dependency graph;
[0047] For each dependent library, determine whether the loading path of the dependent library is located in the system standard library directory;
[0048] If the loading path is not located in the system standard library directory, check whether the dependent library is in the preset whitelist;
[0049] If the loading path is not located in the system standard library directory and is not in the whitelist, query whether the dependent library is marked as an official dependent library;
[0050] If the dependent library is not marked as an official dependent library, it is determined that the function instance being run by the process poses a security risk.
[0051] In one possible implementation, the detection module is further configured to:
[0052] Extract the name and version number of the dependency library from the dependency graph;
[0053] The blockchain lightweight node calls a smart contract to query the hash value of the official dependency library corresponding to the name and version number;
[0054] Compare the hash value of the local dependency library with the hash value of the official dependency library;
[0055] If the hash value of the local dependency library is inconsistent with the hash value of the official dependency library, it is determined that the dependency library has not been marked as an official dependency library;
[0056] If the hash value of the local dependency library matches the hash value of the official dependency library, the dependency library is identified as an official dependency library.
[0057] In one possible implementation, the detection module is further configured to:
[0058] Extract the name and version number of the dependency library from the dependency graph;
[0059] Initiate a query to the centralized database to obtain the official dependency library hash value corresponding to the name and version number;
[0060] Compare the hash value of the local dependency library with the hash value of the official dependency library;
[0061] If the hash value of the local dependency library is inconsistent with the hash value of the official dependency library, it is determined that the dependency library has not been marked as an official dependency library;
[0062] If the hash value of the local dependency library matches the hash value of the official dependency library, the dependency library is identified as an official dependency library.
[0063] In one possible implementation, the generation module is specifically used for:
[0064] Parse the executable file path and the dependent library path to obtain the name, version number, and loading path of each dependent library;
[0065] Generate a dependency graph based on the name, version number, and loading path of each dependent library;
[0066] The dependency graph is associated with and stored as a unique identifier for the function instance.
[0067] In one possible implementation, the device further includes an isolation module for:
[0068] If a security risk is identified in the function instance, an isolated environment is created;
[0069] Switch the runtime environment of the function instance to the isolated environment;
[0070] The function instance continues to execute in the isolated environment, but its access to external resources is restricted.
[0071] In one possible implementation, the device further includes an alarm module for:
[0072] After switching to the isolated environment, a process snapshot of the function instance is captured, including memory state, file descriptors, and network connection information;
[0073] An alarm log is generated based on the process snapshot;
[0074] The alarm logs are sent to the security monitoring system.
[0075] Thirdly, this application provides an apparatus comprising: a processor and a memory, the processor being configured to execute a security detection program stored in the memory to implement the security detection method described in any one of the first aspects.
[0076] Fourthly, this application provides a storage medium storing one or more programs that can be executed by one or more processors to implement the security detection method described in any one aspect.
[0077] Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application first monitors the library loading behavior of any process in the system during system operation, wherein each process runs one function instance. Then, it obtains the dependency library information corresponding to the library loading behavior, wherein the dependency library information includes the executable file path and the dependency library path. A dependency graph corresponding to the process is generated based on the executable file path and the dependency library path. Finally, during system cold start, security checks are performed on the function instances running by the process based on the dependency graph. This application, by dynamically monitoring the library loading behavior of processes, generating a dependency graph, and performing security checks during system cold start, can promptly detect and handle security threats during code execution, reduce potential security risks, and improve system security. Attached Figure Description
[0078] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0079] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0080] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0081] Figure 1 A flowchart illustrating an embodiment of a security detection method provided in this application;
[0082] Figure 2 A flowchart illustrating an embodiment of another security detection method provided in this application;
[0083] Figure 3 A block diagram illustrating an embodiment of a security detection device provided in this application;
[0084] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0085] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0086] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0087] To address the problem that existing technologies primarily analyze static code and cannot detect dynamic behavior during runtime, resulting in lower security, this application provides a security detection method that can promptly detect and address security threats during code runtime, reduce potential security risks, and improve system security.
[0088] Figure 1 This is a flowchart illustrating an embodiment of a security detection method provided in this application.
[0089] like Figure 1 As shown, the method includes the following steps:
[0090] Step 101: For any process in the system, monitor the library loading behavior of the process during system operation, wherein each process runs one function instance.
[0091] A process is an execution unit in an operating system. Each process runs an independent function instance. This application mainly focuses on "processes in a function computing environment" or "processes in a serverless computing environment".
[0092] Library loading behavior refers to the dynamic loading of dependent libraries by a process during runtime, such as loading a shared library through the dlopen system call.
[0093] In this embodiment of the application, eBPF (Extended Berkeley Packet Filter) technology can be used to hook system calls (such as dlopen, execve) at the kernel level to capture the behavior of processes loading dependent libraries in real time.
[0094] In applications, SystemTap can also be used instead of eBPF to achieve dynamic monitoring, but the performance overhead increases by more than 50ms.
[0095] Step 102: Obtain the dependency library information corresponding to the library loading behavior, wherein the dependency library information includes the executable file path and the dependency library path.
[0096] Dependency information includes the executable file path and the dependency library path. The executable file path refers to the complete path of the process's executable file in the file system (e.g., / usr / bin / python3); the dependency library path refers to the complete path of the dependency library in the file system (e.g., / usr / lib / libc.so.6).
[0097] In this embodiment of the application, the execve system call can be hooked using eBPF technology to capture the executable file path loaded when the process starts, and the dlopen system call can be hooked using eBPF technology to capture the dependency library path dynamically loaded during process runtime.
[0098] Step 103: Generate a dependency graph corresponding to the process based on the executable file path and the dependency library path.
[0099] A dependency graph is a structured data representation of the relationship between processes and their dependent libraries, typically stored in JSON format.
[0100] Specifically, step 103 may include the following steps: parsing the executable file path and the dependent library path to obtain the name, version number, and loading path of each dependent library; generating a dependency graph based on the name, version number, and loading path of each dependent library; and associating and storing the dependency graph with the unique identifier of the function instance.
[0101] The name of the dependent library refers to the unique identifier of the dependent library (such as libc, requests).
[0102] The version number of the dependent library refers to the version information of the dependent library (such as 2.34, 1.0.0).
[0103] The load path refers to the complete path of the dependent library in the file system (such as / usr / lib / libc.so.6).
[0104] This scheme first extracts the names and version numbers of dependent libraries by parsing the executable file path and dependent library paths. Then, it records the loading path of each dependent library, thus obtaining a list of dependent library names, version numbers, and loading paths. Finally, it organizes the names, version numbers, and loading paths of the dependent libraries into a structured JSON format to obtain a dependency graph, and binds the dependency graph to a unique identifier of the function instance for easy subsequent querying and analysis.
[0105] This approach enables the system to quickly generate and store dependency graphs during the cold start phase, providing a data foundation for subsequent security testing.
[0106] Step 104: During system cold start, perform security checks on the function instances running by the process based on the dependency graph.
[0107] In this embodiment of the application, a dependency graph is loaded during cold start, and the legality of each dependency library in the graph is verified (such as whitelist verification and hash comparison), thereby realizing the security detection of function instances running in the process.
[0108] Specifically, performing security checks on function instances running by the process based on the dependency graph may include the following steps:
[0109] Step A1: Obtain the loading path of the dependency library from the dependency graph.
[0110] In this step, the loading path of each dependent library is extracted by parsing the dependency graph.
[0111] Step A2: For each dependent library, determine whether the loading path of the dependent library is located in the system standard library directory.
[0112] The system standard library directory refers to the library directory predefined by the operating system. It is a valid library directory predefined by the operating system and typically contains system kernel libraries (such as libc and libpthread).
[0113] In this step, you can determine whether the load path is located in the system standard library directory by checking if it starts with the system standard library directory.
[0114] For example, / usr / lib / libc.so.6 is located in the system standard library directory, while / tmp / malicious_lib.so is not located in the system standard library directory.
[0115] This step allows for rapid identification of pre-installed system libraries, reducing verification overhead, improving detection efficiency, and avoiding redundant verification of system libraries.
[0116] Step A3: If the loading path is not located in the system standard library directory, check whether the dependent library is in the preset whitelist.
[0117] A whitelist is a user-defined list of legal dependency libraries, specifying the allowed library paths or names. It typically includes legitimate third-party or custom libraries.
[0118] In this step, whitelist verification can further narrow down the legitimate scope of dependent libraries and reduce false positives.
[0119] Step A4: If the loading path is not located in the system standard library directory and is not in the whitelist, query whether the dependency library is marked as an official dependency library.
[0120] Step A5: If the dependent library is not marked as an official dependent library, it is determined that the function instance running by the process has a security risk.
[0121] For ease of understanding, steps A4 and A5 will be explained uniformly below:
[0122] Official dependency libraries refer to dependency libraries released by official repositories (such as PyPI and npm), whose hash values have been pre-stored in the blockchain or centralized database.
[0123] In one implementation, querying whether the dependency library is marked as an official dependency library may include the following steps:
[0124] Extract the name and version number of the dependency library from the dependency graph; query the official dependency library hash value corresponding to the name and version number by calling the smart contract through the blockchain lightweight node; compare the local dependency library hash value of the dependency library with the official dependency library hash value; if the local dependency library hash value is inconsistent with the official dependency library hash value, determine that the dependency library is not marked as an official dependency library; if the local dependency library hash value is consistent with the official dependency library hash value, determine that the dependency library is marked as an official dependency library.
[0125] A lightweight blockchain node is a lightweight blockchain client capable of quickly querying on-chain data. In this solution, the lightweight blockchain node uses a pre-caching strategy to synchronously obtain hash updates for the next 30 minutes during cold start, reducing query latency.
[0126] Smart contracts are programs that run on the blockchain and are used to store and retrieve the hash values of official dependency libraries. Smart contracts store all official libraries in the form of triples: <package name, version, SHA256>, ensuring the immutability of the data.
[0127] Official dependency library hash: The hash value of the dependency library released by the official repository, stored on the blockchain.
[0128] The local dependency library hash value is a local verification value obtained by calculating the SHA256 hash value of the dependency library file.
[0129] In this implementation, firstly, the name and version number of each dependency library are extracted by parsing the dependency graph. For example, libc (version 2.34) and malicious_lib (version 1.0.0) are extracted from the graph. Then, a blockchain lightweight node calls a smart contract, passing in the dependency library's name and version number. The smart contract returns the official dependency library hash value corresponding to the name and version number, as well as a local verification value obtained by calculating the SHA256 hash value of the dependency library file. Finally, the local dependency library hash value is compared with the official dependency library hash value, thereby accurately identifying tampered or forged dependency libraries. That is, if the local dependency library hash value does not match the official dependency library hash value, the dependency library is determined not to be marked as an official dependency library; if the local dependency library hash value matches the official dependency library hash value, the dependency library is determined to be marked as an official dependency library.
[0130] This solution enables the system to quickly and accurately identify illegal dependency libraries during the cold start phase, ensuring the security of serverless function instances.
[0131] In another implementation, querying whether the dependency library is marked as an official dependency library may include the following steps:
[0132] Extract the name and version number of the dependency library from the dependency graph; initiate a query to the centralized database to obtain the official dependency library hash value corresponding to the name and version number; compare the local dependency library hash value of the dependency library with the official dependency library hash value; if the local dependency library hash value is inconsistent with the official dependency library hash value, determine that the dependency library has not been marked as an official dependency library; if the local dependency library hash value is consistent with the official dependency library hash value, determine that the dependency library has been marked as an official dependency library.
[0133] A centralized database is a type of database used to store the hash values of official dependency libraries.
[0134] In this implementation, the hash value of the official dependency library can be quickly queried through a centralized database, reducing query latency and making it suitable for scenarios with low requirements for blockchain performance.
[0135] The technical solution provided in this application first monitors the library loading behavior of any process in the system during system operation. Each process runs one function instance. Then, it obtains the dependency library information corresponding to the library loading behavior, including the executable file path and the dependency library path. A dependency graph corresponding to the process is generated based on the executable file path and the dependency library path. Finally, during system cold start, security checks are performed on the function instances running by the process based on the dependency graph. This application, by dynamically monitoring the library loading behavior of processes, generating a dependency graph, and performing security checks during system cold start, can promptly detect and handle security threats during code execution, reducing potential security risks and improving system security.
[0136] Figure 2 A flowchart illustrating an embodiment of another security detection method provided in this application. Figure 2 The process shown is in Figure 1 Based on the illustrated process, the following steps are included:
[0137] Step 201: If it is determined that the function instance poses a security risk, create an isolated environment.
[0138] An isolated environment is a runtime environment isolated from the main system, such as a lightweight sandbox (gVisor, Firecracker) or a Docker container. Isolated environments physically isolate runtime instances from the underlying storage layer through the copy-on-write feature of OverlayFS.
[0139] Security risks refer to situations where a function instance loads an unregistered or modified version of a dependency library, which may lead to malicious behavior.
[0140] In this embodiment, upon detecting a security risk in a function instance, an isolation environment creation process is triggered. First, a lightweight sandbox technology (such as gVisor or Firecracker) is used to create an isolation environment within 20ms. For example, if it is detected that / tmp / malicious_lib.so is not in the whitelist and its hash value is inconsistent with the on-chain record, an isolation environment is created to prepare for switching the function instance's runtime environment. The isolation environment is physically isolated from the main system, preventing the spread of malicious behavior.
[0141] Step 202: Switch the runtime environment of the function instance to the isolation environment.
[0142] In this embodiment, after the isolation environment is created, the runtime environment of the function instance is switched from the main system to the isolation environment to ensure that the function instance can continue to run normally in the isolation environment. During the switching process, the state of the function instance (such as memory and file descriptors) is completely preserved. For example, the function instance f1234567-89ab-cdef-0123-456789abcdef is switched from the main system to the gVisor sandbox.
[0143] Step 203: Continue executing the function instance in the isolated environment and restrict the function instance's access to external resources.
[0144] External resources include file systems, networks, and inter-process communication.
[0145] Access restrictions: Restrict the ability of function instances to access external resources through sandbox technology.
[0146] In this embodiment of the application, the function instance continues to execute in an isolated environment, and the permissions of the function instance are restricted through sandbox technology, specifically including: file system: only allowing access to specific directories (such as / var / task); network: prohibiting access to external networks, or only allowing access to specific IP addresses; inter-process communication: prohibiting communication with other processes.
[0147] For example, a function instance continues to run in an isolated environment, but cannot access files or the network on the main system.
[0148] pass Figure 2 As shown in the process, the system can quickly isolate function instances and restrict their permissions when a security risk is detected, thus ensuring the security of the main system.
[0149] In another embodiment of this application, the method may further include the following steps: after switching to the isolated environment, capturing a process snapshot of the function instance, the process snapshot including memory state, file descriptors and network connection information; generating an alarm log based on the process snapshot; and sending the alarm log to the security monitoring system.
[0150] A process snapshot is used to capture a process's memory state, file descriptors, and network connection information at a specific point in time. Memory state refers to the process's memory image, including the heap, stack, and code segment; file descriptors refer to the descriptors of resources such as files and sockets opened by the process; and network connection information refers to network connections established by the process (such as TCP / UDP connections).
[0151] A security monitoring system is a system used to receive, store, and analyze security events.
[0152] In this embodiment, after switching to the isolated environment, firstly, a process snapshot of the function instance is captured. Specifically, the memory state is captured: the process_vm_readv system call is used to fully copy the process memory (including heap, stack, and code segment). For processes larger than 128MB, zstd real-time compression (60% compression ratio) is enabled. File descriptors are captured via / proc / <pid>The ` / fd` directory is used to retrieve file descriptors opened by processes. Inode tracing is performed on each file descriptor, recording the file path and content (truncated to the first 4KB). Network connection information is captured from ` / proc / `. <pid>Extract socket inode from / net / tcp → local port mapping. Mirror the last 3 incomplete TCP packets (containing a 512B payload) in the send queue.
[0153] Then, the process snapshot file is parsed to extract key information, specifically including: memory state: contents of the heap, stack, and code segments; file descriptors: paths and contents of open files; and network connection information: active connections and DNS cache. This extracted information is then organized into a structured alert log (e.g., JSON format). In this way, the alert log can record attack context information (i.e., memory state, file descriptors, and network connection information) through structured data (JSON format), facilitating subsequent analysis and tracing.
[0154] Finally, alarm logs are sent to the security monitoring system via an encrypted channel (such as HTTPS) to ensure the security of data transmission. The security monitoring system receives and stores the alarm logs, and analyzes them in real time to trigger alarm notifications, facilitating a rapid response from the security team.
[0155] This solution enables the system to quickly capture process snapshots and generate alarm logs when security risks are detected, ensuring that the security team can respond to and handle security incidents in a timely manner.
[0156] Figure 3 This is a block diagram illustrating an embodiment of a security detection device provided in this application. Figure 3 As shown, the device includes:
[0157] The monitoring module 31 is used to monitor the library loading behavior of any process in the system during system operation, wherein each process runs a function instance.
[0158] The acquisition module 32 is used to acquire the dependency library information corresponding to the library loading behavior, wherein the dependency library information includes the executable file path and the dependency library path;
[0159] Generation module 33 is used to generate a dependency graph corresponding to the process based on the executable file path and the dependency library path;
[0160] The detection module 34 is used to perform security detection on the function instances running by the process based on the dependency graph during system cold start.
[0161] In one possible implementation, the detection module is specifically used for:
[0162] Obtain the loading path of the dependent library from the dependency graph;
[0163] For each dependent library, determine whether the loading path of the dependent library is located in the system standard library directory;
[0164] If the loading path is not located in the system standard library directory, check whether the dependent library is in the preset whitelist;
[0165] If the loading path is not located in the system standard library directory and is not in the whitelist, query whether the dependent library is marked as an official dependent library;
[0166] If the dependent library is not marked as an official dependent library, it is determined that the function instance being run by the process poses a security risk.
[0167] In one possible implementation, the detection module is further configured to:
[0168] Extract the name and version number of the dependency library from the dependency graph;
[0169] The blockchain lightweight node calls a smart contract to query the hash value of the official dependency library corresponding to the name and version number;
[0170] Compare the hash value of the local dependency library with the hash value of the official dependency library;
[0171] If the hash value of the local dependency library is inconsistent with the hash value of the official dependency library, it is determined that the dependency library has not been marked as an official dependency library;
[0172] If the hash value of the local dependency library matches the hash value of the official dependency library, the dependency library is identified as an official dependency library.
[0173] In one possible implementation, the detection module is further configured to:
[0174] Extract the name and version number of the dependency library from the dependency graph;
[0175] Initiate a query to the centralized database to obtain the official dependency library hash value corresponding to the name and version number;
[0176] Compare the hash value of the local dependency library with the hash value of the official dependency library;
[0177] If the hash value of the local dependency library is inconsistent with the hash value of the official dependency library, it is determined that the dependency library has not been marked as an official dependency library;
[0178] If the hash value of the local dependency library matches the hash value of the official dependency library, the dependency library is identified as an official dependency library.
[0179] In one possible implementation, the generation module is specifically used for:
[0180] Parse the executable file path and the dependent library path to obtain the name, version number, and loading path of each dependent library;
[0181] Generate a dependency graph based on the name, version number, and loading path of each dependent library;
[0182] The dependency graph is associated with and stored as a unique identifier for the function instance.
[0183] In one possible implementation, the device further includes an isolation module for:
[0184] If a security risk is identified in the function instance, an isolated environment is created;
[0185] Switch the runtime environment of the function instance to the isolated environment;
[0186] The function instance continues to execute in the isolated environment, but its access to external resources is restricted.
[0187] In one possible implementation, the device further includes an alarm module for:
[0188] After switching to the isolated environment, a process snapshot of the function instance is captured, including memory state, file descriptors, and network connection information;
[0189] An alarm log is generated based on the process snapshot;
[0190] The alarm logs are sent to the security monitoring system.
[0191] The technical solution provided in this application first monitors the library loading behavior of any process in the system during system operation. Each process runs one function instance. Then, it obtains the dependency library information corresponding to the library loading behavior, including the executable file path and the dependency library path. A dependency graph corresponding to the process is generated based on the executable file path and the dependency library path. Finally, during system cold start, security checks are performed on the function instances running by the process based on the dependency graph. This application, by dynamically monitoring the library loading behavior of processes, generating a dependency graph, and performing security checks during system cold start, can promptly detect and handle security threats during code execution, reducing potential security risks and improving system security.
[0192] like Figure 4 As shown in the figure, this application provides a device including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0193] Memory 113 is used to store computer programs;
[0194] In one embodiment of this application, when the processor 111 executes the program stored in the memory 113, it implements the security detection method provided in any of the foregoing method embodiments, including:
[0195] For any process in the system, monitor the library loading behavior of that process during system operation, wherein each process runs one function instance;
[0196] Obtain the dependency library information corresponding to the library loading behavior, wherein the dependency library information includes the executable file path and the dependency library path;
[0197] Generate a dependency graph corresponding to the process based on the executable file path and the dependent library path;
[0198] During a system cold start, security checks are performed on the function instances running by the process based on the dependency graph.
[0199] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the security detection method provided in any of the foregoing method embodiments.
[0200] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0201] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0202] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "a," "an," and "described" as used herein may also mean including the plural forms. The terms "comprising," "including," "containing," and "having" are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a specific order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.
[0203] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.< / pid> < / pid>
Claims
1. A security detection method, characterized in that, The method includes: For any process in the system, monitor the library loading behavior of that process during system operation, wherein each process runs one function instance; Obtain the dependency library information corresponding to the library loading behavior, wherein the dependency library information includes the executable file path and the dependency library path; Generate a dependency graph corresponding to the process based on the executable file path and the dependent library path; During a system cold start, security checks are performed on the function instances running by the process based on the dependency graph.
2. The method according to claim 1, characterized in that, The security detection of function instances running in the process based on the dependency graph includes: Obtain the loading path of the dependent library from the dependency graph; For each dependent library, determine whether the loading path of the dependent library is located in the system standard library directory; If the loading path is not located in the system standard library directory, check whether the dependent library is in the preset whitelist; If the loading path is not located in the system standard library directory and is not in the whitelist, query whether the dependent library is marked as an official dependent library; If the dependent library is not marked as an official dependent library, it is determined that the function instance being run by the process poses a security risk.
3. The method according to claim 2, characterized in that, The query to determine whether the dependency library is marked as an official dependency library includes: Extract the name and version number of the dependency library from the dependency graph; The blockchain lightweight node calls a smart contract to query the hash value of the official dependency library corresponding to the name and version number; Compare the hash value of the local dependency library with the hash value of the official dependency library; If the hash value of the local dependency library is inconsistent with the hash value of the official dependency library, it is determined that the dependency library has not been marked as an official dependency library; If the hash value of the local dependency library matches the hash value of the official dependency library, the dependency library is identified as an official dependency library.
4. The method according to claim 2, characterized in that, The query to determine whether the dependency library is marked as an official dependency library includes: Extract the name and version number of the dependency library from the dependency graph; Initiate a query to the centralized database to obtain the official dependency library hash value corresponding to the name and version number; Compare the hash value of the local dependency library with the hash value of the official dependency library; If the hash value of the local dependency library is inconsistent with the hash value of the official dependency library, it is determined that the dependency library has not been marked as an official dependency library; If the hash value of the local dependency library matches the hash value of the official dependency library, the dependency library is identified as an official dependency library.
5. The method according to claim 1, characterized in that, The step of generating the dependency graph corresponding to the process based on the executable file path and the dependent library path includes: Parse the executable file path and the dependent library path to obtain the name, version number, and loading path of each dependent library; Generate a dependency graph based on the name, version number, and loading path of each dependent library; The dependency graph is associated with and stored as a unique identifier for the function instance.
6. The method according to claim 1, characterized in that, The method further includes: If a security risk is identified in the function instance, an isolated environment is created; Switch the runtime environment of the function instance to the isolated environment; The function instance continues to execute in the isolated environment, but its access to external resources is restricted.
7. The method according to claim 6, characterized in that, The method further includes: After switching to the isolated environment, a process snapshot of the function instance is captured, including memory state, file descriptors, and network connection information; An alarm log is generated based on the process snapshot; The alarm logs are sent to the security monitoring system.
8. A safety detection device, characterized in that, The device includes: The monitoring module is used to monitor the library loading behavior of any process in the system during system operation, wherein each process runs one function instance; The acquisition module is used to acquire the dependency library information corresponding to the library loading behavior, wherein the dependency library information includes the executable file path and the dependency library path; The generation module is used to generate a dependency graph corresponding to the process based on the executable file path and the dependency library path; The detection module is used to perform security checks on the function instances running by the process based on the dependency graph during system cold start.
9. A device, characterized in that, include: A processor and a memory, the processor being configured to execute a security detection program stored in the memory to implement the security detection method according to any one of claims 1-7.
10. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the security detection method according to any one of claims 1-7.
