Abnormality detection method and device based on traceability subgraph, and electronic equipment

Through the anomaly detection method based on the traceability subgraph, using the depth-first search algorithm and embedding vector calculation, the problems of poor interpretability and high human resource consumption of network anomaly detection in the existing technology are solved, and high-accuracy network anomaly detection is achieved. , enhanced network security.

CN118568628AActive Publication Date: 2024-08-30TSINGHUA UNIVERSITY

Patent Information

Application Number
CN202410624914.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2024-08-30
Estimated Expiration
2044-05-20

AI Technical Summary

Technical Problem

Existing network anomaly detection methods have problems with poor interpretability and inaccurate annotation when faced with large-scale data, making it difficult to accurately detect anomalies, and subsequent traceability analysis requires a lot of human resources.

Method used

The anomaly detection method based on the traceability subgraph is used to generate the traceability graph by extracting key fields from the application log, and uses the depth-first search algorithm to traverse the traceability graph, calculate the embedding vector of the behavior subgraph, and generate an isolated tree through multiple sampling. Detect whether the traceability graph contains abnormal behavioral subgraphs.

Benefits of technology

On the basis of saving human resources, it improves the accuracy of network anomaly detection, realizes the correlation between the system's underlying behavior and high-level semantics, and enhances network security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568628A
    Figure CN118568628A
Patent Text Reader

Abstract

The embodiment of the invention discloses an anomaly detection method and device based on a traceability subgraph and electronic equipment, and the method comprises the steps: extracting a plurality of application sessions containing key fields from an application log, and generating a traceability graph based on an audit log; for each application session, traversing the traceability graph according to the direction of the information flow from an application process provided by the application session by utilizing a depth-first search algorithm, and taking a traceability sub-graph obtained by traversing as a behavior sub-graph corresponding to the application session; a plurality of rooted sub-graphs of each behavior sub-graph are obtained, according to the rooted sub-graphs, embedded vectors of the behavior sub-graphs are calculated, and orders corresponding to the rooted sub-graphs in the behavior sub-graphs are different; the method comprises the following steps: sampling a plurality of embedded vectors of a traceability graph for multiple times to generate a plurality of isolated trees of the traceability graph; and according to the expectation of the height of each behavior sub-graph in all isolated trees and the search length of the balanced binary tree under the worst condition, detecting whether an abnormal behavior sub-graph is contained in the traceability graph or not.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network security technology, and in particular to an anomaly detection method, device and electronic equipment based on a tracing subgraph. Background Art

[0002] With the rapid development of network technology and the increasingly tense international situation, information security has become increasingly important. Faced with the digital transformation of various industries in my country, cyber attacks have become more rampant, and attack techniques have become more complex and covert. The key data assets and infrastructure of the country and major enterprises require more effective cybersecurity defense measures to deal with unknown cyber threats.

[0003] In the face of complex and hidden network attacks, anomaly detection methods based on audit logs have become an important research topic in the field of network security. By analyzing the content of system audit logs and building a traceability graph that reflects the underlying execution logic of the system, we can fully explore abnormal system call links and help conduct security analysis and attack investigations.

[0004] However, although audit logs record event information at the bottom layer of the system, when faced with large-scale data, anomaly detection methods often have difficulty accurately detecting anomalies due to problems such as poor interpretability and inaccurate labeling, and subsequent tracing analysis often requires a lot of human resources. Summary of the invention

[0005] The present invention provides a method, device and electronic equipment for anomaly detection based on a traceability subgraph, which can improve the accuracy of network anomaly detection while saving human resources.

[0006] The specific technical solutions are as follows:

[0007] In a first aspect, an embodiment of the present invention provides an anomaly detection method based on a provenance subgraph, the method comprising:

[0008] Extract multiple application sessions containing key fields from application logs, and generate a traceability graph based on audit logs;

[0009] For each of the application sessions, using a depth-first search algorithm, starting from the application process provided by the application session, traversing the traceability graph in the direction of information flow, and using the traceability subgraph obtained by the traversal as the behavior subgraph corresponding to the application session;

[0010] Acquire multiple rooted subgraphs of each of the behavior subgraphs, and calculate an embedding vector of the behavior subgraph according to the multiple rooted subgraphs, wherein the order corresponding to each rooted subgraph in the multiple rooted subgraphs of the behavior subgraph is different;

[0011] Generate multiple isolated trees of the traceability graph by sampling multiple embedding vectors of the traceability graph multiple times;

[0012] According to the expected height of each behavior subgraph in all isolated trees and the worst-case search length of a balanced binary tree, it is detected whether the traceability graph contains abnormal behavior subgraphs.

[0013] In a possible implementation, the key fields include the unique identifier of the application session, the process controller PID of the application process, the user's request IP address, the start time of the user's request, the end time of the user's request, an identifier for indicating whether the current behavior sequence has ended, an identifier for indicating whether the current behavior sequence is abnormal, and the source log of the application.

[0014] In a possible implementation, generating a traceability graph based on the audit log includes:

[0015] In the process of constructing the traceability graph, the application process of the application log is obtained, and in the process of sequentially parsing the audit log, the category of each node is determined according to the degree of relevance of each node to the corresponding application process, wherein the categories of the nodes include backbone nodes, edge nodes and irrelevant nodes, the backbone nodes are entities that directly or indirectly include the application process, the edge nodes are non-backbone nodes with information flowing into the backbone nodes, and the irrelevant nodes are entities that are irrelevant to the application process;

[0016] When both the starting node and the ending node are not trunk nodes, filtering the starting node and the ending node;

[0017] When the starting node is a backbone node and the ending node is not a backbone node, adjusting the ending node to a backbone node;

[0018] When the starting node is not a backbone node and the ending node is a backbone node, the starting node is used as an edge node;

[0019] Filter nodes that are classified as irrelevant nodes.

[0020] In a possible implementation, generating a traceability graph based on the audit log further includes:

[0021] When the node to be processed has no new incoming edge and the node to be processed has multiple outgoing edges, the multiple outgoing edges of the node to be processed are merged into one edge, wherein the node to be processed is the node to be determined whether the edges need to be merged;

[0022] When the node to be processed has a new incoming edge and the node to be processed has multiple outgoing edges, the edges whose timestamps are after the target timestamp of the multiple outgoing edges of the node to be processed are merged into one edge, and the target timestamp is the timestamp of the new incoming edge of the node to be processed.

[0023] In a possible implementation, in the process of traversing the traceability graph according to the direction of information flow using a depth-first search algorithm for each application session, starting from the application process provided by the application session, the method further includes:

[0024] Perform a reverse search on the currently traversed process node;

[0025] When the previous node corresponding to the incoming edge of the currently traversed process node includes a process node and a file node, if the behavior of reading the file is later than the behavior of inter-process communication, the file node corresponding to the incoming edge of the currently traversed process node is retained.

[0026] In a possible implementation, in the process of traversing the traceability graph according to the direction of information flow using a depth-first search algorithm for each application session, starting from the application process provided by the application session, the method further includes:

[0027] Determine a time window according to the start time and end time of the user request recorded in the application session, wherein the start time of the time window is less than the start time, and the end time of the time window is greater than the end time;

[0028] Determine whether the currently traversed node is a critical point to be split according to the time window;

[0029] When the currently traversed node is a critical point to be split, the split is performed at the currently traversed node.

[0030] In a possible implementation, obtaining a plurality of rooted subgraphs of each of the behavior subgraphs includes:

[0031] In the behavior subgraph, the process name is used as the node label of the process node, the combination of the remote IP and the remote port is used as the node label of the network node, and the complete file path is used as the node label of the file node;

[0032] In the process of generating a 0-order rooted subgraph to generating a d-order rooted subgraph, for any k-order, searching for the node label of the k-order node of each node in the behavior subgraph, and updating the node label of each node to a combination of the node label of the node and the node label of the k-order node;

[0033] According to the preset compression algorithm, the updated node labels are compressed to obtain a rooted subgraph of order k.

[0034] In a possible implementation, detecting whether the traceability graph contains an abnormal behavior subgraph according to the expected height of each behavior subgraph in all isolated trees and the search length in the worst case of a balanced binary tree includes:

[0035] According to a preset formula, the anomaly score of each behavior subgraph is calculated, and when it is determined that the traceability graph has an anomaly according to the anomaly score of the behavior subgraph, the behavior subgraph with the highest anomaly score is determined as the abnormal behavior subgraph;

[0036] Wherein, the preset formula includes:

[0037]

[0038] The S(i,n) represents the anomaly score of the behavior subgraph i when the number of behavior subgraphs is n, the h(i) represents the height of the behavior subgraph i in each isolated tree, the E(h(i)) represents the expected height of the behavior subgraph i in all isolated trees, and the c(n) represents the search length in the worst case of a balanced binary tree.

[0039] In a second aspect, an embodiment of the present invention provides an anomaly detection device based on a provenance subgraph, the device comprising:

[0040] An extraction unit, used for extracting a plurality of application sessions containing key fields from the application log;

[0041] A traceability graph generation unit, used to generate a traceability graph based on the audit log;

[0042] A behavior subgraph generating unit is used to use a depth-first search algorithm for each application session, starting from the application process provided by the application session, traverse the traceability graph in the direction of information flow, and use the traceability subgraph obtained by the traversal as the behavior subgraph corresponding to the application session;

[0043] An acquisition unit, used for acquiring a plurality of rooted subgraphs of each of the behavior subgraphs;

[0044] A calculation unit, configured to calculate an embedding vector of the behavior subgraph according to the multiple rooted subgraphs, wherein the order of each rooted subgraph in the multiple rooted subgraphs of the behavior subgraph is different;

[0045] An isolated tree generating unit, configured to generate multiple isolated trees of the traceability graph by sampling multiple embedding vectors of the traceability graph multiple times;

[0046] The anomaly detection unit is used to detect whether the traceability graph contains an abnormal behavior subgraph based on the expected height of each behavior subgraph in all isolated trees and the search length in the worst case of a balanced binary tree.

[0047] In a possible implementation, the key fields include the unique identifier of the application session, the process controller PID of the application process, the user's request IP address, the start time of the user's request, the end time of the user's request, an identifier for indicating whether the current behavior sequence has ended, an identifier for indicating whether the current behavior sequence is abnormal, and the source log of the application.

[0048] In a possible implementation, the provenance graph generating unit includes:

[0049] A determination module, in the process of constructing the traceability graph, obtains the application process of the application log, and in the process of sequentially parsing the audit log, determines the category of each node according to the degree of relevance of each node to the corresponding application process, wherein the categories of the nodes include backbone nodes, edge nodes and irrelevant nodes, the backbone nodes are entities that directly or indirectly include the application process, the edge nodes are non-backbone nodes with information flowing into the backbone nodes, and the irrelevant nodes are entities that are irrelevant to the application process;

[0050] A filtering module, when the starting node and the ending node are not trunk nodes, filtering the starting node and the ending node;

[0051] An adjustment module, configured to adjust the terminating node to a trunk node when the starting node is a trunk node and the terminating node is not a trunk node; and to use the starting node as an edge node when the starting node is not a trunk node and the terminating node is a trunk node;

[0052] The filtering module is also used to filter nodes that are classified as irrelevant nodes.

[0053] In a possible implementation, the provenance graph generating unit further includes:

[0054] A merging module is used to merge the multiple outgoing edges of the node to be processed into one edge when there is no new incoming edge of the node to be processed and the node to be processed has multiple outgoing edges, wherein the node to be processed is a node to be determined whether edges need to be merged; when the node to be processed has a new incoming edge and the node to be processed has multiple outgoing edges, merge the edges whose timestamps are after the target timestamp among the multiple outgoing edges of the node to be processed into one edge, wherein the target timestamp is the timestamp of the new incoming edge of the node to be processed.

[0055] In a possible implementation, the behavior subgraph generation unit is also used to perform a reverse search on the currently traversed process node in the process of traversing the traceability graph in the direction of information flow, starting from the application process provided by the application session, using a depth-first search algorithm for each of the application sessions; when the previous node corresponding to the incoming edge of the currently traversed process node includes a process node and a file node, if the behavior of reading the file is later than the behavior of communicating between processes, the file node corresponding to the incoming edge of the currently traversed process node is retained.

[0056] In a possible implementation, the behavior subgraph generation unit is further used to determine a time window according to the start time and end time of the user request recorded in the application session during the process of traversing the traceability graph in the direction of information flow using a depth-first search algorithm for each application session, wherein the start time of the time window is less than the start time and the end time of the time window is greater than the end time; determine whether the currently traversed node is a critical point to be split according to the time window; and when the currently traversed node is a critical point to be split, split at the currently traversed node.

[0057] In a possible implementation, the acquisition unit includes:

[0058] A setting module is used to use, in the behavior subgraph, a process name as a node label of a process node, a combination of a remote IP and a remote port as a node label of a network node, and a complete file path as a node label of a file node;

[0059] An updating module, used for searching the node label of the k-order node of each node in the behavior subgraph for any k-order in the process from generating the 0-order rooted subgraph to generating the d-order rooted subgraph, and updating the node label of each node to a combination of the node label of the node and the node label of the k-order node;

[0060] The compression module is used to compress the updated node labels according to a preset compression algorithm to obtain a rooted subgraph of order k.

[0061] In a possible implementation, the anomaly detection unit is used to calculate the anomaly score of each of the behavior subgraphs according to a preset formula, and when determining that the traceability graph has an anomaly according to the anomaly score of the behavior subgraph, determine the behavior subgraph with the highest anomaly score as the abnormal behavior subgraph;

[0062] Wherein, the preset formula includes:

[0063]

[0064] The S(i,n) represents the anomaly score of the behavior subgraph i when the number of behavior subgraphs is n, the h(i) represents the height of the behavior subgraph i in each isolated tree, the E(h(i)) represents the expected height of the behavior subgraph i in all isolated trees, and the c(n) represents the search length in the worst case of a balanced binary tree.

[0065] In a third aspect, an embodiment of the present invention provides a storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method described in the first aspect.

[0066] In a fourth aspect, an embodiment of the present invention provides an electronic device, including:

[0067] one or more processors;

[0068] a storage device for storing one or more programs,

[0069] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in the first aspect.

[0070] In a fifth aspect, an embodiment of the present invention provides a computer program product, which includes instructions. When the instructions are executed on a computer or a processor, the one or more processors implement the method described in the first aspect.

[0071] From the above content, it can be seen that the anomaly detection method, device and electronic device based on the traceability subgraph provided by the embodiment of the present invention can first extract multiple application sessions containing key fields from the application log, and generate a traceability graph based on the audit log, and then for each application session, using the depth-first search algorithm, starting from the application process provided by the application session, traverse the traceability graph in the direction of the information flow, and use the traversed traceability subgraph as the behavior subgraph corresponding to the application session, and calculate the embedding vector of the behavior subgraph according to the multiple rooted subgraphs of each behavior subgraph, and generate multiple isolated trees of the traceability graph by sampling the multiple embedding vectors of the traceability graph multiple times, and finally detect whether the traceability graph contains abnormal behavior subgraphs according to the expected height of each behavior subgraph in all isolated trees and the search length of the worst case of the balanced binary tree. It can be seen that the embodiment of the present invention can realize the association between the underlying behavior of the system and the high-level semantics by associating the application log with the underlying audit log, and realize the automatic detection of the user's high-level behavior, thereby saving human resources and improving the accuracy of network anomaly detection, thereby improving network security. Of course, it is not necessary to achieve all the advantages described above at the same time for any product or method implementing the present invention.

[0072] The innovative features of the embodiments of the present invention include:

[0073] 1. By associating application logs with underlying audit logs, the underlying behavior of the system can be associated with high-level semantics, and automatic detection of user high-level behavior can be achieved, thereby saving human resources and improving the accuracy of network anomaly detection, thereby improving network security.

[0074] 2. During the construction of the traceability graph, each node is divided into backbone nodes, edge nodes and irrelevant nodes according to the degree of relevance between each node and the corresponding application process in the application log, and irrelevant nodes that are completely irrelevant to the application process are filtered out. This can not only improve the efficiency of subsequent generation of behavioral subgraphs, but also avoid the impact of irrelevant nodes on subsequent anomaly detection.

[0075] 3. By merging the edges with the same events, the construction of the traceability graph can be optimized and its practicality can be improved. By filtering out the events of the background process from the traceability graph, the number of invalid events can be significantly reduced, thereby avoiding interference with the analysis caused by irrelevant events.

[0076] 4. In the process of depth-first search, by performing a layer of reverse search on the process nodes and retaining important nodes, information loss can be avoided.

[0077] 5. By segmenting the traceability graph based on the time window determined by the start and end time in the application session, the dependency explosion phenomenon can be avoided. Dependency explosion means that if nodes or events unrelated to the current user behavior are incorrectly divided into the current behavior subgraph, a large number of unrelated events will appear in the behavior subgraph.

[0078] 6. By using the process name as the node label of the process node, the combination of the remote IP and remote port as the node label of the network node, and the full file path as the node label of the file node, a rooted subgraph can be generated to obtain richer node semantics and topology information.

[0079] 7. By sampling multiple embedding vectors of the traceability graph multiple times to obtain an isolation forest, and performing anomaly detection on the behavior subgraph based on the isolation forest, the randomness of feature selection and feature partitioning values ​​of a single isolated tree can be avoided, thereby improving the accuracy of anomaly detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative work.

[0081] Figure 1 A schematic diagram of a flow chart of an anomaly detection method based on a tracing subgraph provided in an embodiment of the present invention;

[0082] Figure 2 An example diagram of a snowflake growth algorithm provided by an embodiment of the present invention;

[0083] Figure 3 An example graph for removing duplicate edges of a provenance graph provided by an embodiment of the present invention;

[0084] Figure 4 A behavior-level subgraph partitioning algorithm framework diagram provided by an embodiment of the present invention;

[0085] Figure 5 An example of behavior subgraph segmentation for a PostgreSQL application scenario provided by an embodiment of the present invention;

[0086] Figure 6 An example diagram of information loss provided by an embodiment of the present invention;

[0087] Figure 7 An example diagram of an Apache source traceability diagram provided by an embodiment of the present invention;

[0088] Figure 8 An example diagram of a first-order rooted subgraph provided by an embodiment of the present invention;

[0089] Fig. 9 An exemplary diagram of the working principle of a Weisfeiler-Leman algorithm provided in an embodiment of the present invention;

[0090] Fig.10 A framework diagram of an anomaly detection algorithm based on graph embedding provided by an embodiment of the present invention;

[0091] Fig.11 A t-SNE visualization example diagram of a data set CVE-2021-41773 provided in an embodiment of the present invention;

[0092] Fig.12 A block diagram of a composition of an anomaly detection device based on a tracing subgraph provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0093] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0094] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present invention and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.

[0095] Audit logs record the underlying activities of the system, allowing us to monitor system activities in detail. Through these logs, we can observe various behaviors performed by the underlying entities of the system, such as file reading and writing, process creation, etc., thereby obtaining rich underlying system information and execution history records.

[0096] Application logs reflect high-level system behavior. Each application log records the user requests completed by the application, so application logs are strongly related to user behavior. By analyzing application logs, you can clearly understand which users the application serves and what operations it performs. In addition, many vulnerabilities are also directly related to applications, so user attack behaviors are often recorded in application logs.

[0097] However, although audit logs can reflect the interaction between underlying entities in the system, they cannot be directly associated with high-level application behaviors; similarly, although application logs can reflect the request relationship between users and applications, it is difficult to understand the underlying system behaviors caused by user requests through application log analysis alone. Therefore, it is difficult to obtain sufficient behavioral semantics by using any type of log data alone.

[0098] The embodiment of the present invention provides an anomaly detection method based on a traceability subgraph. By associating application logs with underlying audit logs, the method can realize the association between the underlying behavior of the system and high-level semantics, and realize the detection of high-level behavior of users, thereby further improving network security. The method can be applied to any electronic device with computing power, which can be a terminal or a server. In one implementation, the functional software implementing the method can exist in the form of a separate client software, or in the form of a plug-in for currently related client software. The embodiments of the present invention are described in detail below.

[0099] Figure 1 A flowchart of an anomaly detection method based on a tracing subgraph is provided in an embodiment of the present invention. The method may include the following steps:

[0100] S110: extracting multiple application sessions containing key fields from the application log, and generating a traceability graph based on the audit log.

[0101] (I) Generate application sessions based on application logs

[0102] An application session represents a series of actions performed by the same user on a specific application over a period of time. Application logs record user requests processed by the application and detail the actions taken by the user after the connection with the application is established. The goal of this step includes dividing different application sessions based on application logs. Since applications usually serve multiple users at the same time, it is not possible to directly divide application sessions only by time windows.

[0103] Given that different applications have their own unique execution modes, the rules for extracting application behaviors also need to be adjusted accordingly. The following is an analysis of several typical application execution modes:

[0104] PostgreSQL: This application uses a multi-process execution model. After receiving a user connection request, the main process named postgres clones a child process to serve the connection. It can be considered that the application requests completed by the same process within a period of time belong to the operation sequence of a specific user, so the process PID (Process Identifier) ​​can be used as a key mark to distinguish application sessions.

[0105] Vsftpd: This application also uses a multi-process model. After receiving a user request, the Vsftpd daemon clones a main process to handle the user's request. Unlike PostgreSQL, the main process does not directly participate in the user's related operations, but clones a subprocess to execute. In this case, multiple processes may serve the same user, so PID cannot be directly used as a criterion for session division, and a specific log format is required to distinguish them. For example, in an application log, processes with process PIDs 4746, 4747, and 4748 all serve the same connection, and process 4746 is the main process for this connection. By locating the log of successful login, the main process of each application session can be determined.

[0106] Apache: Considering that Apache has different working modes, only the prefork working mode, which is more commonly used in Apache, is discussed here. In this mode, Apache will pre-clone several child processes to handle user requests when the service is started, and dynamically adjust the number of child processes according to the number of requests. In this case, a process only serves one user at a time. A single user operation usually sends multiple requests, and each request generates a connection. In order to more accurately reflect the user's behavior sequence, it is recommended to use network IP (Internet Protocol) and process PID as identifiers to divide application logs.

[0107] The extraction of user behavior can be understood as the process of extracting different identifiers (such as process PID, network IP, etc.) from application logs and clustering them. In order to more effectively segment different application logs, by analyzing the relevant logs of the above applications, some key fields can be mentioned from the application logs to constitute the application session. The key fields include the unique identifier of the application session, the PID of the application process, the user's request IP address, the start time of the user's request, the end time of the user's request, the identifier used to indicate whether the current behavior sequence has ended, the identifier used to indicate whether the current behavior sequence is abnormal, and the source log of the application. For details, please refer to Table 1.

[0108] Table 1 Application Session

[0109]

[0110]

[0111] In addition, considering the multi-process execution mode of PostgreSQL and the process pool mode of Apache, long-running programs may cause the same PID or IP to appear repeatedly, making the extracted behavior semantics confusing. Therefore, in order to avoid the application session time span being too long, when no new requests join the session for a period of time, the session will be automatically closed. Conversely, when a new request joins the current session, the session life cycle will be reset.

[0112] (II) Generate a traceability graph based on the audit log

[0113] A1. Audit log collection

[0114] Current network attack methods, especially APT (Advanced Persistent Threat) attacks, cannot be effectively detected only through network traffic logs or blacklists. Audit logs record the overall process of system calls. By building a traceability graph, the underlying execution call logic of the system can be revealed, the different states of the system can be distinguished, and the attacker's attack trajectory can be unearthed. Therefore, it is particularly important to detect anomalies through audit logs.

[0115] There are many audit log collection tools, such as Auditd, ETW and Sysdig. Compared with other audit log collection tools, Sysdig not only has rich operation and use documents, but also maintains the trend of updating and iteration. Sysdig can monitor the system calls of its deployed containers in the host environment. Therefore, the embodiment of the present application can use the Sysdig tool to collect audit logs.

[0116] Selection of system calls The number of Linux system calls increases with the update of the kernel version, and currently exceeds 300. Each system call involves different underlying logic, so the construction principle of the traceability graph varies from system call to system call, which makes it impossible to uniformly parse all system calls. In order to accurately restore the execution call link of the system, the embodiment of the present invention performs a detailed traceability analysis on the underlying audit log of the system to identify three types of commonly used and critical system calls: calls between processes, calls between processes and networks, and calls between processes and files. The detailed information of these key system calls is listed in Table 2.

[0117] Table 2 System calls parsed

[0118]

[0119] The system calls listed in Table 2 can cover most system behaviors. System calls between processes mainly deal with operations such as process forking; system calls between processes and networks mainly involve operations related to establishing connections and information exchange between servers and clients; system calls between processes and files mainly resolve file read, write, and edit operations. The concept of "file" here is relatively broad, including system memory, pipes, or disk files. Inter-process communication is usually implemented using files as intermediaries, so the specific meaning of files depends on specific system operations.

[0120] A2. Log analysis

[0121] The provenance graph is essentially a set of four-tuple events and nodes extracted from system events. The provenance graph construction process provided in the embodiment of the present application refers to the traditional provenance graph model, extracts system entities and relationships from the audit log, and constructs a four-tuple structure containing source nodes, target nodes, relationships and timestamps. System entities are mainly divided into three types of nodes: process, file or network. The relationship represents the system response corresponding to the event, such as file creation, writing, reading, etc., and the timestamp records the specific time when the system call occurs.

[0122] G(p,q)=<V,E> ;

[0123] Among them, p is the audit log sequence, q is the application log sequence, V is the node set, and E is the edge set.

[0124] e=(src,dst,rel,timeatamp);

[0125] Among them, e represents the four-tuple of the traceability graph, src is the source node, dst is the destination node, rel is the system call type (that is, the relationship between the two nodes), and timestamp is the timestamp of the system call.

[0126] In the process of building a traceability graph, each node needs to be given a unique identifier for node identification and matching. For network nodes, the remote IP address and port number are used to build a unique identifier. File nodes directly use the global path of the file as the unique identifier. For process nodes, the PID, process name and version number of the process are combined as its unique identifier. Since the process PID may be repeated, the version number mechanism is introduced to distinguish processes with the same PID and process name but in different life cycles.

[0127] Considering the existence of the execve system call, the process name may change. Usually, after a process clones a child process through the clone or fork operation, in order to let the child process perform specific operations, it will execute the execve system call to update the child process's memory space to run the new program. Since the execve system call does not record the detailed information of the original process, in order to restore the execution link, it is necessary to record the original process node when the cloning operation is completed, and after the execve operation is completed, point the original process node to the new process. Although the PIDs of the two process nodes are the same, their process names and other attributes are different.

[0128] In addition, the direction of the four-tuple extracted from the audit log should be configured completely according to the direction of information flow. For example, for the openat system call, since the system uses special flags to specify the file opening method when opening a file, these methods may affect the information flow of the event. The embodiment of the present invention determines the event direction by parsing the startup instruction of the system response, and regards the system response containing the 3 parameters in the table as a write file operation, and the others as a read file operation.

[0129] Table 3 Write-related file opening parameters

[0130] Startup parameters meaning O_WRONLY Open the file for writing only O_RDWR Open the file for reading and writing O_APPEND Append data to the end of the file on each write operation O_TRUNC If the file already exists, it is truncated to empty space when opened.

[0131] A3. Origin Optimization

[0132] Given that the size of audit logs will grow rapidly over time, more than 1GB and tens of millions of audit logs may be collected within an hour. In order to parse these logs and complete the construction of the full traceability graph, a relational database or a graph database is usually required. Although databases such as MySQL and Neo4j are widely used, they do not support custom retrieval and traceability algorithms, and therefore cannot meet the requirements of the embodiment of the present invention for constructing a traceability graph. For this reason, the embodiment of the present invention chooses a memory-based method to save the complete traceability graph, and independently designs and implements a method for constructing a traceability graph.

[0133] The memory-based provenance graph construction method poses a huge challenge to computer performance. In the face of long-running attack scenarios, machines with large audit logs, weak performance, or small memory capacity may need to enable the swap mechanism to build a full provenance graph, which will consume a lot of time. However, not all system entities and events are required by the embodiments of the present invention. In the process of building the provenance graph, only nodes and edges related to the application need to be retained, and irrelevant system events need to be filtered out.

[0134] Drawing on the process of snowflakes in nature growing gradually in a cold environment by relying on condensation nuclei, an embodiment of the present invention proposes a "snowflake growth algorithm". Based on the application sessions obtained through the previous analysis, key system processes are extracted as "condensation nuclei" for constructing the provenance graph, and gradually grow in the system audit environment to construct a provenance graph closely related to the application. "Growth" here refers to the process of information flowing from one master node to another, such as cloning of processes, modification of files, etc. This algorithm effectively concentrates resources and attention on key system behaviors, thereby improving the efficiency and relevance of constructing the provenance graph.

[0135] Therefore, the traceability graph optimization method proposed in the embodiment of the present invention includes: in the process of constructing the traceability graph, obtaining the application process of the application log, and in the process of sequentially parsing the audit log, determining the category of each node according to the degree of relevance of each node to the corresponding application process, wherein the node categories include trunk nodes, edge nodes and irrelevant nodes; when the starting node and the ending node are not trunk nodes, filtering the starting node and the ending node; when the starting node is a trunk node and the ending node is not a trunk node, adjusting the ending node to a trunk node; when the starting node is not a trunk node and the ending node is a trunk node, using the starting node as an edge node; filtering nodes whose category is irrelevant nodes.

[0136] The backbone nodes include the application process of interest and the related nodes that grow from the process. These nodes are entities that directly or indirectly contain the application process and are system entities that are strongly related to the application process. Edge nodes are non-backbone nodes with information flowing into the backbone nodes, and they do not directly or indirectly receive information from the backbone nodes. Edge nodes cannot grow like backbone nodes, and they constitute the boundaries of the traceability graph. Irrelevant nodes are entities that are irrelevant to the application process. These nodes do not directly or indirectly exchange information with the application process, so they are filtered as background information. Figure 2 As shown, the black circle represents the initial application process node, the gray circle represents the backbone node, the white circle represents the edge node, and the other nodes are filtered out because they are not related to the application process node.

[0137] There are usually a large number of repeated and irrelevant events in the audit log, which will generate a lot of noise, resulting in a large scale of the traceability graph and too many invalid events, affecting subsequent anomaly detection and attack investigation. In order to optimize the construction of the traceability graph and improve its practicality, the embodiments of the present application adopt some strategies to deal with these repeated and irrelevant events.

[0138] The deduplication method includes: when a node to be processed has no new incoming edge and has multiple outgoing edges, merging the multiple outgoing edges of the node to be processed into one edge, wherein the node to be processed is a node for which it is to be determined whether edges need to be merged; when a node to be processed has a new incoming edge and has multiple outgoing edges, merging the edges whose timestamps are after a target timestamp among the multiple outgoing edges of the node to be processed into one edge, wherein the target timestamp is the timestamp of the new incoming edge of the node to be processed.

[0139] Figure 3 The basic principle of deduplication is shown, assuming that all edge types are the same and the numbers on the edges are the times when the events occur. Since node a has no new incoming edges, the information contained in its outgoing edges is the same, so the events occurring at time 1 and time 6 can be merged; while for node c, since it has a new incoming edge at time 2, the information has changed, so only the events occurring at time 3 and time 4 can be merged.

[0140] In addition to aggregating repeated events, the embodiments of the present invention also pay special attention to background processes that generate a large number of irrelevant noise events during the construction of the traceability graph, such as 'systemd-oomd', 'systemd', 'crontab', 'xargs', and 'systemd-resolve'. These background processes are often not directly involved in the main system operations, but they generate a large number of log entries. By filtering the events of these processes out of the traceability graph, the number of invalid events can be significantly reduced, thereby avoiding interference with the analysis caused by irrelevant events. Of course, these background processes can also be called irrelevant nodes and are directly filtered in the aforementioned optimization process.

[0141] S120: For each application session, using a depth-first search algorithm, starting from the application process provided by the application session, traverse the traceability graph in the direction of information flow, and use the traceability subgraph obtained by the traversal as the behavior subgraph corresponding to the application session.

[0142] A behavior subgraph is a traceability subgraph with high-level system behavior semantics. Figure 4As shown in the figure, by parsing the audit logs and application logs, the user behavior and the corresponding system information flow process are mapped to the traceability graph, thus forming a behavior subgraph. Compared with the complete traceability graph, the behavior subgraph incorporates high-level behavior semantics, which can more effectively assist security analysts in anomaly detection and attack investigation.

[0143] Figure 5 This paper shows an example of behavior subgraph segmentation for PostgreSQL application scenarios. The entire subgraph presents the user's high-level behavior, in which the attacker uses the arbitrary instruction execution vulnerability to perform the whoami operation after imitating a normal user to perform a series of database access operations. This traceability subgraph fully reflects the current user's behavioral intention. The embodiment of the present invention can automatically segment such behavior subgraphs, greatly improving the efficiency of security analysis and anomaly detection.

[0144] In order to extract the behavior subgraph from the provenance graph, the embodiment of the present invention starts from the application process provided by the application session, and traverses the provenance graph by depth-first search (DFS). The events and nodes obtained by the traversal constitute the behavior subgraph. This not only assigns the user's behavioral semantics to the subgraph, but also reveals the underlying execution logic of the behavior. The advantage of using the application process as the starting point for the search is that it can more directly associate and reflect the user behavior and system response related to a specific application, and provide clearer high-level behavioral semantics. Depth-first search is an algorithm for traversing or searching a tree or graph data structure.

[0145] In the process of graph traversal, in order to ensure that the construction of subgraphs is strictly carried out along the direction of information flow, the implementation of depth-first search must take into account the directionality of edges and the consistency of time series. This approach can prevent information from flowing from future events to past events, thereby avoiding the introduction of irrelevant dependencies and ensuring that the causal relationship of subgraphs is clear.

[0146] The depth-first search of the embodiment of the present invention will adopt a recursive form to realize the construction of the behavior subgraph by recording the events in the search process. Specifically, the events that have been visited will be recorded during the search process to prevent repeated traversal or entering an infinite loop, and these events will be used to construct the behavior subgraph to present the system information flow process of user behavior.

[0147] Although constructing behavior subgraphs according to the direction of information flow can fully grasp the direction of information flow of the trunk nodes and dig out the execution control logic of the program to a certain extent, just like hundreds of rivers flowing into the sea, the trunk information flow will also accept data from different sources as input, and the system information it contains will not only come from the "trunk river", and if only the direction of information flow is followed, some "tributary" information will inevitably be lost.

[0148] In one possible implementation, in order to prevent information loss, for each application session, a depth-first search algorithm is used to traverse the traceability graph starting from the application process provided by the application session in the direction of the information flow, and a reverse search can be performed on the currently traversed process node; when the previous node corresponding to the incoming edge of the currently traversed process node includes a process node and a file node, if the behavior of reading the file is later than the behavior of communicating between processes, the file node corresponding to the incoming edge of the currently traversed process node is retained.

[0149] like Figure 5 As shown in the figure, if the direction of information flow is strictly followed, the event of whoami process reading / etc / passwd will be lost. Analyzing the reasons, this kind of information loss can be divided into Figure 6 The corresponding solutions for the two situations shown are as follows:

[0150] Read behavior 3 occurs after behavior 2, and this behavior must be retained because it is taken after receiving the backbone node information, such as the whoami instruction, which reads / etc / passwd after fork.

[0151] Reading behavior 1 occurs after behavior 2. Since behavior 1 does not occur under the influence of behavior 2, its information is not strongly related to the backbone node. However, it can also reflect some key information. For example, when the process is created, backtracking can be used to find out which malicious files are loaded by process 3.

[0152] By analyzing the traceability graph obtained from the experimental scenario, the following conclusion is drawn: In the process of depth-first search, a layer of reverse search is required for the process entity to avoid the two types of information missing problems mentioned above.

[0153] In a possible implementation, when using depth-first search to extract a behavior subgraph related to the current application session, if nodes or events that are not related to the current user behavior are incorrectly classified into the current behavior subgraph, a large number of irrelevant events will appear in the behavior subgraph. This phenomenon is called dependency explosion in the embodiment of the present invention.

[0154] When generating the behavior subgraph of the Apache application, a serious dependency explosion problem occurred, resulting in a large number of system events that were unrelated to the current behavior appearing in the traceability subgraph. Figure 7 The example of Apache's traceability graph is shown. The embodiment of the present invention analyzes the causal dependency relationship of the traceability graph in depth and summarizes two types of causes that lead to dependency explosion:

[0155] Profork execution mode: This mode clones some child processes before the application is started. These child processes are used to handle user service requests. Although the same process only serves one network request at a time, it actually serves multiple network requests over a period of time. In addition, during the experiment, a machine will simulate multiple network requests, and a network node will be associated with multiple application processes. As a result, when performing a depth-first search starting from the application process node, other requests of the network node will be searched out, resulting in a dependency explosion.

[0156] CGI (Common Gateway Interface) standard: This standard specifies how Apache calls external programs and how it communicates with external programs. Figure 7 As shown in the left module of , Apache maintains an httpd process. When the main process writes an external instruction to be executed into the allocated memory, the process reads the request and clones a new process to execute the external instruction. Therefore, starting from the process, a depth-first search will search out multiple system instructions executed by it.

[0157] In order to avoid the dependency explosion problem in the depth-first search process, through tracing the execution logic of Apache, it was found that Apache's service process and CGI module only serve one user request at the same time.

[0158] Based on this, the present invention implements the use of the start and end time of the application session record to segment the traceability graph using a time window segmentation method. Specifically, for each application session, using a depth-first search algorithm, starting from the application process provided by the application session, in the process of traversing the traceability graph in the direction of the information flow, the time window can be determined according to the start time and end time of the user request recorded in the application session, wherein the start time of the time window is less than the start time, and the end time of the time window is greater than the end time; according to the time window, it is determined whether the currently traversed node is a critical point to be segmented; when the currently traversed node is a critical point to be segmented, segmentation is performed at the currently traversed node. This method can reduce irrelevant events in the behavior subgraph, thereby alleviating dependency explosion.

[0159] From the application session, we can only get the start and end time of each session in seconds. Since the accuracy of system events is microseconds, and considering that the time of application log records has certain fluctuations, we make corrections based on the original start and end time. For this reason, this article defines the time window as follows:

[0160] window=(start_time-σ,end_time+β);

[0161] To avoid missing information, the time window strategy only targets specific processes. When encountering a special process node during depth-first search, the event will be guaranteed to be within the time window while ensuring that the search follows the information flow and time order.

[0162] In addition, for network nodes, since the information flow representing key behaviors is caused by the application process, terminating the depth-first search at the network node will not lead to information loss and can effectively avoid the occurrence of dependency explosion.

[0163] S130: Acquire multiple rooted subgraphs of each behavior subgraph, and calculate an embedding vector of the behavior subgraph according to the multiple rooted subgraphs.

[0164] The behavior subgraph is a traceability graph divided according to the application session, which reflects the underlying execution logic of the application. Considering the differences in each application session request and the differences in the system state, the topological dependencies and scales of the behavior subgraph are usually different. For a behavior subgraph with a dynamically changing scale, it is difficult to directly perform related operations such as anomaly detection. As a special data structure, the traceability graph essentially has the properties of a graph, so the embedded expression of the traceability graph can be obtained through graph encoding. By converting the traceability graph into a fixed-length vector, the anomaly detection task can be converted into a classification operation on the vector.

[0165] The embodiment of the present invention can use the Graph2vec algorithm to obtain multiple rooted subgraphs of each behavior subgraph, and calculate the embedding vector of the behavior subgraph based on the multiple rooted subgraphs. Graph2vec extracts the rooted subgraph (RSG) and its feature information through the Weisfeiler-Leman graph kernel method, and then regards each rooted subgraph as a word, and uses the Skip-Gram technology in the Doc2vec model to maximize the probability of the rooted subgraph appearing by constructing a vector representation of each graph, thereby realizing the coding generation of the traceability graph. In order to realize the construction of the traceability graph coding, two core steps are required, namely, the feature construction of the rooted subgraph and the training of the Doc2vec model.

[0166] The order corresponding to each rooted subgraph in the multiple rooted subgraphs of the behavior subgraph obtained in this step is different. Traditional graph embedding methods, such as the research of Bordes et al., Lin et al., Grover et al., etc., embed structured nodes or events into vector space, which loses a lot of topological information. In order to learn the topological features of the graph, the embodiment of the present invention adopts the graph kernel method, which decomposes the original graph structure into smaller substructures, namely rooted subgraphs, and calculates the high-order features of each rooted subgraph using the Weisfeiler-Leman method.

[0167] A rooted subgraph has a specific order. For a k-order rooted subgraph of node n, it refers to a traceability graph with node n as the root and all nodes and edges that can be reached within k hops from the root node. This rooted subgraph describes the characteristics of node n and its neighborhood, and can express the attributes and topological information of the node. Figure 8 As shown, the first-order rooted subgraph of black nodes is the subgraph inside the circle.

[0168] In order to construct the features of the rooted subgraph, it is first necessary to construct the features of each node, and extract key fields as node features from the attribute information of each node in the behavior subgraph. Thereafter, rooted subgraphs of different orders are obtained, and the features of each rooted subgraph are calculated using the Weisfeiler-Leman algorithm. In order to explain the algorithm flow here more clearly, the embodiment of the present invention will first describe the overall process of rooted subgraph feature extraction, and then describe the construction of node features.

[0169] Rooted subgraph feature extraction is based on node features and uses the Weisfeiler-Leman algorithm to construct feature information of the graph. The Weisfeiler-Leman algorithm is based on the topological structure of the graph and takes any node in the graph as the root to collect and integrate information. The embodiment of the present invention aims to extract rooted subgraph features of all nodes in the behavior subgraph.

[0170] Fig. 9 The working principle of the Weisfeiler-Leman algorithm is shown. The node labels of the original image in Figure (a) are 1 to 6. First, each node collects the information of its neighbors, together with its own features, to form the current information set of the node. For example, the information set of the upper left node in Figure (b) is {1, 2, 3}. After the label compression process shown in Figure (c), the original lengthy label information is compressed to obtain new label information. The new label information is re-labeled to the corresponding node as a new node feature, and the rooted subgraph shown in Figure (d) is obtained. Since this information already contains the information of the surrounding neighbors, it is considered to be high-order information.

[0171] The rooted subgraph can effectively obtain the high-order structural information of the traceability graph by iterating the Weisfeiler-Leman method multiple times. However, if the initial feature selection of the node is inappropriate, this method may not be able to effectively learn the topological information of the graph. Too specific node labels may cause the learned information to lack generalization ability. For example, if the process PID is used as node information, since the PID of each process is usually unique, this will cause the information learned even in the same scenario to be different. On the contrary, if the set label information is too simple, it may cause the traceability graphs in different scenarios to have similar labels, thus lacking in distinguishability.

[0172] For large-scale provenance graphs, complex label semantics will make the corpus of node labels extremely large, making it difficult for Graph2vec to learn a representative embedding representation of the provenance graph. Therefore, Prographer only uses the type of node as a node label. However, in an embodiment of the present invention, the behavior subgraph obtained by subgraph partitioning does not include noise nodes and related events such as the background process of the system, and the scale of the provenance graph is kept within a small range, which avoids the problem of the corpus becoming too large, so more complex node labels can be used. In order to obtain richer node semantics and topological information, the following labeling strategies are adopted for different types of nodes:

[0173] Process node: The process node contains three types of information: node type, process name, and process PID. Since the process PID itself does not have the ability to distinguish scenarios, and the process node type can be distinguished only by the process name, the process name is selected as the node label.

[0174] Network node: The information of a network node includes node type, remote IP, remote port, local IP and local port. Considering that applications usually use fixed ports and the local IP is usually not distinguishable, we choose to keep the remote IP and remote port as node labels.

[0175] File node: For applications, the files they access and read are usually specific files or files in a specific directory, so the full file path is selected as the node label.

[0176] In summary, the method for obtaining multiple rooted subgraphs of a behavior subgraph according to an embodiment of the present invention includes: in the behavior subgraph, the process name is used as the node label of the process node, the combination of the remote IP and the remote port is used as the node label of the network node, and the complete file path is used as the node label of the file node; in the process from generating a 0-order rooted subgraph to generating a d-order rooted subgraph, for any k-order, the node label of the k-order node of each node in the behavior subgraph is searched, and the node label of each node is updated to the combination of the node label of the node and the node label of the k-order node; according to a preset compression algorithm, the updated node label is compressed to obtain a rooted subgraph of k-order. The preset compression algorithm includes an MD5 (Message Digest Algorithm 5) algorithm, a hash algorithm, and the like.

[0177] In order to obtain the vector embedding of the complete traceability graph, the embodiment of the present invention uses the Skip-Gram method of Doc2vec after extracting the feature information of each rooted subgraph. The main task of this method is to learn the embedding representation of the document and optimize its ability to predict the probability of the occurrence of context words of words in the document.

[0178] The method of the embodiment of the present invention regards the graph as a document and each rooted subgraph as a word in the document. In this way, the graph embedding problem is cleverly transformed into a task similar to document embedding. The multi-order features of the rooted subgraph obtained by the Weisfeiler-Leman method actually constitute the context subunit of each behavioral subgraph. Therefore, the encoding generation task of the embodiment of the present invention is mainly transformed into learning the embedding representation of the graph, aiming to maximize the probability of each rooted subgraph appearing, so as to effectively capture and express the structure and semantic information of the traceability graph.

[0179] The features of the root nodes at different levels obtained by Weisfeiler-Leman can fully reflect the topological information of the single-hop and multi-hop traceability graph. Therefore, when constructing the feature encoding of the behavior subgraph, all the root subgraph features of order 0-d are used as the "words" of the behavior subgraph. i For , its related rooted subgraph feature set is defined as follows:

[0180] V i =R1∪R2…∪R j ={r1,r2,…,r m};

[0181] Among them, V i refers to the behavior subgraph G i The rooted subgraph feature set, R j It refers to the multi-order features of the behavior subgraph node j, which is defined as follows:

[0182]

[0183] in, Represents the d-order feature of the root node j, that is, R j is the feature set of different orders of node j.

[0184] In essence, Graph2vec uses the Skip-Gram method of Doc2vec and the idea of ​​maximum likelihood to maximize the probability of each rooted subgraph in the graph by constructing an embedded representation of the graph. i , first generate a random vector representation After that, a neural network model is trained to predict the behavior subgraph G i Thereafter, each behavior subgraph {G1, G2, …, G k The optimization goal adopted in the embodiment of the present invention is:

[0185]

[0186] Among them, J(E) represents the target optimization function, V i Behavior subgraph G i The characteristic set of the rooted subgraph of Refers to the behavior subgraph G i There is a rooted subtree r j The embedding representation of It refers to the behavior subgraph G i The embedding representation of , Pr refers to the probability.

[0187]

[0188] In the above formula, V represents the rooted subgraph feature set generated by all behavior subgraphs. For training efficiency, in the actual training process, when considering the behavior subgraph G i The relevant rooted subgraph features V i After that, for the full set of behavior subgraphs V, the feature set V′ is obtained by negative sampling, and satisfies Thus, the above The formula changes to:

[0189]

[0190] During the training process, the core optimization goal is to maximize the behavior subgraph G i Each rooted subgraph feature V i The possibility of minimizing the absence of G i The possibility of the feature set V′ in , so the final model loss is defined as:

[0191]

[0192] S140: Generate multiple isolated trees of the traceability graph by sampling multiple embedding vectors of the traceability graph multiple times.

[0193] In the field of network security, anomaly detection is an important means to determine whether there is a potential attack in the system state. To this end, it is common practice to distinguish abnormal data from normal data. However, in practical applications, attack or abnormal behavior subgraph data usually show serious imbalance, which is a challenge for classification models. Although ATLAS uses oversampling and undersampling techniques to balance the data set to a certain extent, this method is prone to overfitting of the model. In addition, when new attack methods appear, classification-based methods often fail and cannot effectively identify unknown attacks.

[0194] The same application vulnerability can be exploited in many ways. For example, through arbitrary instruction execution vulnerabilities, attackers may exploit it in many ways, such as implanting malicious scripts or launching rebound shells. Fig.10As shown, in view of the diversity of attack methods and the data imbalance problem in application scenarios, after obtaining the embedding vector (i.e., graph embedding) of each behavior subgraph, the embodiment of the present invention adopts an unsupervised learning method such as Isolation Forest for anomaly detection.

[0195] The basic principle of Isolation Forest is to isolate each element in the data set through a binary tree, so that each element is in an independent space, and each element that is segmented constitutes a node on the binary tree. The denser the data nodes, the more segmentations are required to isolate the nodes into independent spaces. For sparsely distributed abnormal nodes, they can usually be isolated quickly, so the fewer segmentations required to isolate a node, the greater the possibility that it is an abnormality.

[0196] Through the previous behavior subgraph construction process, the original dynamic-scale behavior subgraph has been converted into fixed-length vector data. The t-SNE method is used to reduce the dimension of the data and visualize it. Fig.11 , where black represents normal data and gray represents abnormal data. In the dataset CVE-2021-41773, normal data is basically clustered together and distributed densely, while abnormal data is distributed in a banded manner and is sparsely distributed. Therefore, the number of splits required to isolate abnormal nodes will be less than that of normal nodes.

[0197] This algorithm will be divided into two main modules: isolation tree generation and isolation forest construction. Isolation trees for each data node are quickly constructed through binary decomposition. Isolation forests are similar to random forests. They generate multiple simple isolation trees and combine the results of these trees to obtain the final anomaly detection output.

[0198] Isolation Tree is a special binary tree where all data is split into leaf nodes. For each node, if it is not a leaf node, it must have two child nodes. From the embedding vector obtained from the behavior subgraph, select k random features, select a random value within the range of these features to split the data, and repeat this process until there is only one element in each space.

[0199] Since a single isolated tree has a large randomness in feature selection and feature partition value determination, relying on only one isolated tree often cannot guarantee the effect of anomaly detection. In order to improve the accuracy of anomaly detection on behavior subgraphs, the embodiment of the present invention draws on the concept of random forests, samples the original data set multiple times, and constructs multiple isolated trees, so as to judge whether there is an anomaly in the behavior subgraph by summarizing the detection results of these isolated trees.

[0200] In addition, in order to improve the efficiency of training and control the complexity of the model, the maximum growth height of each isolated tree is set to ceiling(log2Ψ), where Ψ is the number of samples. Although this setting limits the height of the tree, since we mainly focus on abnormal data and abnormal data usually appear at the lower level of the isolated tree due to its sparsity, this height limit does not affect the prediction performance of the model.

[0201] S150: Detect whether the traceability graph contains abnormal behavior subgraphs based on the expected height of each behavior subgraph in all isolated trees and the worst-case search length of a balanced binary tree.

[0202] Regarding the data distribution of behavior subgraphs, abnormal behavior subgraphs are sparser than normal subgraphs, so they are more easily divided into separate areas, which is manifested as abnormal subgraphs being distributed at lower heights in isolated trees. Therefore, for each behavior subgraph, the possibility of its behavior being abnormal is calculated by the distance between its node and the root node, that is, the height. Specifically, the anomaly score of each behavior subgraph can be calculated according to a preset formula, and when the traceability graph is determined to be abnormal based on the anomaly score of the behavior subgraph, the behavior subgraph with the highest anomaly score is determined as the abnormal behavior subgraph;

[0203] The preset formulas include:

[0204]

[0205] S(i,n) represents the anomaly score of behavior subgraph i when the number of behavior subgraphs is n, h(i) represents the height of behavior subgraph i in each isolated tree, E(h(i)) represents the expected height of behavior subgraph i in all isolated trees, and c(n) represents the worst-case search length of a balanced binary tree.

[0206] c(n)=2H(n-1)-(2(n-1) / n

[0207] H(k)=ln(k)+ε,ε=0.5772156649

[0208] When the average height of the behavior subgraph in the isolated forest is different, three different situations can be obtained according to Formula 4.8:

[0209] When E(h(i)) approaches C(n), S(i,n) will continue to approach 0.5;

[0210] When E(h(i)) approaches 0, S(i,n) will continue to approach 1;

[0211] When E(h(i)) approaches n-1, S(i,n) will continue to approach 0.

[0212] When there is an anomaly score greater than or equal to a preset score threshold, it can be determined that there is an anomaly in the isolation forest, and the behavior subgraph with the highest anomaly score is determined as the abnormal behavior subgraph, and the user of the malicious attack can be determined based on the audit log corresponding to the abnormal behavior subgraph.

[0213] The anomaly detection method based on the traceability subgraph provided by the embodiment of the present invention can first extract multiple application sessions containing key fields from the application log, and generate a traceability graph based on the audit log, and then for each of the application sessions, using the depth-first search algorithm, starting from the application process provided by the application session, traverse the traceability graph in the direction of the information flow, and use the traceability subgraph obtained by the traversal as the behavior subgraph corresponding to the application session, and calculate the embedding vector of the behavior subgraph according to the multiple rooted subgraphs of each behavior subgraph, and generate multiple isolated trees of the traceability graph by sampling the multiple embedding vectors of the traceability graph multiple times, and finally detect whether the traceability graph contains abnormal behavior subgraphs according to the expected height of each behavior subgraph in all isolated trees and the search length of the worst case of the balanced binary tree. It can be seen that the embodiment of the present invention can realize the association between the underlying behavior of the system and the high-level semantics by associating the application log with the underlying audit log, and realize the automatic detection of the user's high-level behavior, thereby improving the accuracy of network anomaly detection on the basis of saving human resources, and thus improving network security.

[0214] Corresponding to the above method embodiment, the embodiment of the present invention provides an anomaly detection device based on a tracing subgraph, such as Fig.12 As shown, the device comprises:

[0215] An extraction unit 210 is used to extract multiple application sessions containing key fields from the application log;

[0216] A traceability graph generating unit 220, configured to generate a traceability graph based on the audit log;

[0217] The behavior subgraph generating unit 230 is used to use a depth-first search algorithm for each application session, starting from the application process provided by the application session, traverse the traceability graph in the direction of information flow, and use the traceability subgraph obtained by the traversal as the behavior subgraph corresponding to the application session;

[0218] An acquisition unit 240, configured to acquire a plurality of rooted subgraphs of each of the behavior subgraphs;

[0219] A calculation unit 250 is used to calculate an embedding vector of the behavior subgraph according to the multiple rooted subgraphs, wherein the order of each rooted subgraph in the multiple rooted subgraphs of the behavior subgraph is different;

[0220] An isolated tree generating unit 260, configured to generate multiple isolated trees of the traceability graph by sampling multiple embedding vectors of the traceability graph multiple times;

[0221] The abnormality detection unit 270 is used to detect whether the traceability graph contains abnormal behavior subgraphs according to the expected height of each behavior subgraph in all isolated trees and the search length in the worst case of a balanced binary tree.

[0222] In a possible implementation, the key fields include the unique identifier of the application session, the process controller PID of the application process, the user's request IP address, the start time of the user's request, the end time of the user's request, an identifier for indicating whether the current behavior sequence has ended, an identifier for indicating whether the current behavior sequence is abnormal, and the source log of the application.

[0223] In a possible implementation, the provenance graph generating unit 220 includes:

[0224] A determination module, in the process of constructing the traceability graph, obtains the application process of the application log, and in the process of sequentially parsing the audit log, determines the category of each node according to the degree of relevance of each node to the corresponding application process, wherein the categories of the nodes include backbone nodes, edge nodes and irrelevant nodes, the backbone nodes are entities that directly or indirectly include the application process, the edge nodes are non-backbone nodes with information flowing into the backbone nodes, and the irrelevant nodes are entities that are irrelevant to the application process;

[0225] A filtering module, when the starting node and the ending node are not trunk nodes, filtering the starting node and the ending node;

[0226] An adjustment module, configured to adjust the terminating node to a trunk node when the starting node is a trunk node and the terminating node is not a trunk node; and to use the starting node as an edge node when the starting node is not a trunk node and the terminating node is a trunk node;

[0227] The filtering module is also used to filter nodes that are classified as irrelevant nodes.

[0228] In a possible implementation, the provenance graph generating unit 220 further includes:

[0229] A merging module is used to merge the multiple outgoing edges of the node to be processed into one edge when there is no new incoming edge of the node to be processed and the node to be processed has multiple outgoing edges, wherein the node to be processed is a node to be determined whether edges need to be merged; when the node to be processed has a new incoming edge and the node to be processed has multiple outgoing edges, merge the edges whose timestamps are after the target timestamp among the multiple outgoing edges of the node to be processed into one edge, wherein the target timestamp is the timestamp of the new incoming edge of the node to be processed.

[0230] In a possible implementation, the behavior subgraph generation unit 230 is also used to perform a reverse search on the currently traversed process node during the process of traversing the traceability graph in the direction of information flow, starting from the application process provided by the application session, using a depth-first search algorithm for each of the application sessions; when the previous node corresponding to the incoming edge of the currently traversed process node includes a process node and a file node, if the behavior of reading the file is later than the behavior of communicating between processes, the file node corresponding to the incoming edge of the currently traversed process node is retained.

[0231] In a possible implementation, the behavior subgraph generation unit 230 is further used to determine a time window according to the start time and end time of the user request recorded in the application session during the process of traversing the traceability graph in the direction of information flow using a depth-first search algorithm for each application session, wherein the start time of the time window is less than the start time and the end time of the time window is greater than the end time; determine whether the currently traversed node is a critical point to be split according to the time window; and when the currently traversed node is a critical point to be split, split at the currently traversed node.

[0232] In a possible implementation, the acquisition unit 240 includes:

[0233] A setting module is used to use, in the behavior subgraph, a process name as a node label of a process node, a combination of a remote IP and a remote port as a node label of a network node, and a complete file path as a node label of a file node;

[0234] An updating module, used for searching the node label of the k-order node of each node in the behavior subgraph for any k-order in the process from generating the 0-order rooted subgraph to generating the d-order rooted subgraph, and updating the node label of each node to a combination of the node label of the node and the node label of the k-order node;

[0235] The compression module is used to compress the updated node labels according to a preset compression algorithm to obtain a rooted subgraph of order k.

[0236] In a possible implementation, the anomaly detection unit 270 is configured to calculate an anomaly score of each of the behavior subgraphs according to a preset formula, and when determining that an anomaly exists in the traceability graph according to the anomaly score of the behavior subgraph, determine the behavior subgraph with the highest anomaly score as the abnormal behavior subgraph;

[0237] Wherein, the preset formula includes:

[0238]

[0239] The S(i,n) represents the anomaly score of the behavior subgraph i when the number of behavior subgraphs is n, the h(i) represents the height of the behavior subgraph i in each isolated tree, the E(h(i)) represents the expected height of the behavior subgraph i in all isolated trees, and the c(n) represents the search length in the worst case of a balanced binary tree.

[0240] The anomaly detection device based on the traceability subgraph provided by the embodiment of the present invention can first extract multiple application sessions containing key fields from the application log, and generate a traceability graph based on the audit log, and then for each of the application sessions, using the depth-first search algorithm, starting from the application process provided by the application session, traverse the traceability graph in the direction of the information flow, and use the traceability subgraph obtained by the traversal as the behavior subgraph corresponding to the application session, and calculate the embedding vector of the behavior subgraph according to the multiple rooted subgraphs of each behavior subgraph, and generate multiple isolated trees of the traceability graph by sampling the multiple embedding vectors of the traceability graph multiple times, and finally detect whether the traceability graph contains abnormal behavior subgraphs according to the expected height of each behavior subgraph in all isolated trees and the search length of the worst case of the balanced binary tree. It can be seen that the embodiment of the present invention can realize the association between the underlying behavior of the system and the high-level semantics by associating the application log with the underlying audit log, and realize the automatic detection of the user's high-level behavior, thereby improving the accuracy of network anomaly detection on the basis of saving human resources, and thus improving network security.

[0241] Based on the above embodiment, another embodiment of the present invention further provides a storage medium on which executable instructions are stored. When the instructions are executed by a processor, the processor implements the above method.

[0242] Based on the above embodiment, another embodiment of the present invention further provides an electronic device, including:

[0243] one or more processors;

[0244] a storage device for storing one or more programs,

[0245] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.

[0246] Based on the above embodiment, another embodiment of the present invention further provides a computer program product, wherein the computer program product includes instructions, and when the instructions are executed on a computer or a processor, the one or more processors implement the above method.

[0247] The above device embodiment corresponds to the method embodiment and has the same technical effect as the method embodiment. For specific description, please refer to the method embodiment. The device embodiment is obtained based on the method embodiment. For specific description, please refer to the method embodiment part, which will not be repeated here. It can be understood by those skilled in the art that the accompanying drawings are only schematic diagrams of one embodiment, and the modules or processes in the accompanying drawings are not necessarily required to implement the present invention.

[0248] Those skilled in the art can understand that the modules in the device in the embodiment can be distributed in the device in the embodiment according to the description of the embodiment, or can be changed accordingly and located in one or more devices different from the embodiment. The modules in the above embodiment can be combined into one module, or can be further divided into multiple sub-modules.

[0249] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for anomaly detection based on tracing subgraph, characterized in that: The method comprises: Extract multiple application sessions containing key fields from application logs, and generate a traceability graph based on audit logs; For each of the application sessions, using a depth-first search algorithm, starting from the application process provided by the application session, traversing the traceability graph in the direction of information flow, and using the traceability subgraph obtained by the traversal as the behavior subgraph corresponding to the application session; Acquire multiple rooted subgraphs of each of the behavior subgraphs, and calculate an embedding vector of the behavior subgraph according to the multiple rooted subgraphs, wherein the order corresponding to each rooted subgraph in the multiple rooted subgraphs of the behavior subgraph is different; Generate multiple isolated trees of the traceability graph by sampling multiple embedding vectors of the traceability graph multiple times; According to the expected height of each behavior subgraph in all isolated trees and the worst-case search length of a balanced binary tree, it is detected whether the traceability graph contains abnormal behavior subgraphs.

2. The method according to claim 1, characterized in that The key fields include the unique identifier of the application session, the process controller PID of the application process, the user's request IP address, the start time of the user's request, the end time of the user's request, an identifier for indicating whether the current behavior sequence has ended, an identifier for indicating whether the current behavior sequence is abnormal, and the source log of the application.

3. The method according to claim 1, characterized in that Generate a traceability diagram based on the audit log, including: In the process of constructing the traceability graph, the application process of the application log is obtained, and in the process of sequentially parsing the audit log, the category of each node is determined according to the degree of relevance of each node to the corresponding application process, wherein the categories of the nodes include backbone nodes, edge nodes and irrelevant nodes, the backbone nodes are entities that directly or indirectly include the application process, the edge nodes are non-backbone nodes with information flowing into the backbone nodes, and the irrelevant nodes are entities that are irrelevant to the application process; When both the starting node and the ending node are not trunk nodes, filtering the starting node and the ending node; When the starting node is a backbone node and the ending node is not a backbone node, adjusting the ending node to a backbone node; When the starting node is not a backbone node and the ending node is a backbone node, the starting node is used as an edge node; Filter nodes that are classified as irrelevant nodes.

4. The method according to claim 3, characterized in that Generate a traceability graph based on the audit log, including: When the node to be processed has no new incoming edge and the node to be processed has multiple outgoing edges, the multiple outgoing edges of the node to be processed are merged into one edge, wherein the node to be processed is the node to be determined whether the edges need to be merged; When the node to be processed has a new incoming edge and the node to be processed has multiple outgoing edges, the edges whose timestamps are after the target timestamp of the multiple outgoing edges of the node to be processed are merged into one edge, and the target timestamp is the timestamp of the new incoming edge of the node to be processed.

5. The method according to claim 1, characterized in that In the process of traversing the traceability graph according to the direction of information flow, using a depth-first search algorithm for each application session, starting from the application process provided by the application session, the method further includes: Perform a reverse search on the currently traversed process node; When the previous node corresponding to the incoming edge of the currently traversed process node includes a process node and a file node, if the behavior of reading the file is later than the behavior of inter-process communication, the file node corresponding to the incoming edge of the currently traversed process node is retained.

6. The method according to claim 1 or 5, characterized in that: In the process of traversing the traceability graph according to the direction of information flow, using a depth-first search algorithm for each application session, starting from the application process provided by the application session, the method further includes: Determine a time window according to the start time and end time of the user request recorded in the application session, wherein the start time of the time window is less than the start time, and the end time of the time window is greater than the end time; Determine whether the currently traversed node is a critical point to be split according to the time window; When the currently traversed node is a critical point to be split, the split is performed at the currently traversed node.

7. The method according to claim 1, characterized in that Get multiple rooted subgraphs for each of the behavior subgraphs, including: In the behavior subgraph, the process name is used as the node label of the process node, the combination of the remote IP and the remote port is used as the node label of the network node, and the complete file path is used as the node label of the file node; In the process of generating a 0-order rooted subgraph to generating a d-order rooted subgraph, for any k-order, searching for the node label of the k-order node of each node in the behavior subgraph, and updating the node label of each node to a combination of the node label of the node and the node label of the k-order node; According to the preset compression algorithm, the updated node labels are compressed to obtain a rooted subgraph of order k.

8. The method according to any one of claims 1 to 5 and 7, characterized in that: According to the expected height of each behavior subgraph in all isolated trees and the worst-case search length of a balanced binary tree, detecting whether the traceability graph contains an abnormal behavior subgraph includes: According to a preset formula, the anomaly score of each behavior subgraph is calculated, and when it is determined that the traceability graph has an anomaly according to the anomaly score of the behavior subgraph, the behavior subgraph with the highest anomaly score is determined as the abnormal behavior subgraph; Wherein, the preset formula includes: The S(i,n) represents the anomaly score of the behavior subgraph i when the number of behavior subgraphs is n, the h(i) represents the height of the behavior subgraph i in each isolated tree, the E(h(i)) represents the expected height of the behavior subgraph i in all isolated trees, and the c(n) represents the search length in the worst case of a balanced binary tree.

9. An anomaly detection device based on tracing subgraph, characterized in that: The device comprises: An extraction unit, used for extracting a plurality of application sessions containing key fields from the application log; A traceability graph generation unit, used to generate a traceability graph based on the audit log; A behavior subgraph generating unit is used to use a depth-first search algorithm for each application session, starting from the application process provided by the application session, traverse the traceability graph in the direction of information flow, and use the traceability subgraph obtained by the traversal as the behavior subgraph corresponding to the application session; An acquisition unit, used for acquiring a plurality of rooted subgraphs of each of the behavior subgraphs; A calculation unit, configured to calculate an embedding vector of the behavior subgraph according to the multiple rooted subgraphs, wherein the order of each rooted subgraph in the multiple rooted subgraphs of the behavior subgraph is different; An isolated tree generating unit, configured to generate multiple isolated trees of the traceability graph by sampling multiple embedding vectors of the traceability graph multiple times; The anomaly detection unit is used to detect whether the traceability graph contains an abnormal behavior subgraph based on the expected height of each behavior subgraph in all isolated trees and the search length in the worst case of a balanced binary tree.

10. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Attack tracing method and device, equipment and storage medium

    CN115622802A

  • System audit log-based traceability graph construction method and device

    CN116992089A

  • Detecting security vulnerabilities in queries via an information flow graph

    US20230169180A1

Cited By

  • APT attack detection method and device based on graph attention learning and electronic equipment

    CN121283670A