Anomaly detection method, electronic device, storage medium and product

By extracting and analyzing the characteristic sequence of WebSocket communication, and detecting abnormalities using behavioral analysis algorithm models, the security problems in WebSocket communication are solved, and the identification and early warning of potential attacks are realized, and communication security is improved.

CN118659932BActive Publication Date: 2024-11-15INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411139373.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-15
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

WebSocket communication has security problems, such as cross-site scripting attacks, cross-site request forgery attacks, malware injection and denial of service attacks, and lacks an effective anomaly detection mechanism.

Method used

By extracting the characteristic sequence of the target network socket request, including the timestamp, request type, request size and request frequency, matching verification and behavioral analysis are performed, and abnormal scores are output using the behavioral analysis algorithm model. If the score exceeds the threshold, an alarm will be issued. Identify and alert potential offensive behavior.

Benefits of technology

Effectively prevent cross-site request forgery attacks, connection hijacking, etc., improve the security of WebSocket communication, provide early warning and abnormal detection capabilities, and adapt to the ever-changing threat environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118659932B_ABST
    Figure CN118659932B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides an anomaly detection method, electronic device, storage medium and product, which relate to the field of computer technology. The method includes: when a target network socket request is detected, extracting the source header of the target network socket request, the target protocol format used, the message format, the identity authentication information and several target feature sequences, the target feature sequence includes the target timestamp, the target request type, the target request size and the target request frequency; matching and verifying the source header, the target protocol format, the message format, the identity authentication information and the predefined information, and when the matching verification passes, inputting the target timestamp, the target request type, the target request size and the target request frequency into the behavior analysis algorithm model, and outputting the target anomaly score for each target feature sequence; if the target anomaly score is greater than the target threshold, an alarm is issued. This embodiment improves the security of network socket request communication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an anomaly detection method, electronic equipment, storage medium and product. Background Art

[0002] Initially, duplex communication was implemented through multiple HTTP (HyperText Transfer Protocol) connections. However, creating network applications that implement duplex communication between clients and users will lead to the abuse of HTTP polling (for example, the client continuously sends different HTTP calls to the host to inquire). This will cause a series of problems, including the server needing to use many different underlying TCP (TransmissionControl Protocol) connections for each client, the client script needing to maintain a mapping from outgoing connections to incoming connections to track replies, and some protocols having too high overhead.

[0003] The WebSocket network socket protocol technology is introduced to address the above issues. The communication process of WebSocket technology includes sending an HTTP request from the client. This request will contain some specific header information to inform the server that the client wants to establish a WebSocket connection. After receiving this request, if the server agrees to establish a connection, it will return an HTTP response with a status code of 101, indicating that the protocol switch is successful. After that, a fast channel is formed between the client and the server, and the client and the server can communicate in full-duplex through a TCP connection. This method replaces HTTP polling to achieve two-way communication from a web page to a remote host.

[0004] However, since WebSocket communication is done through TCP connection between the client and the server, there are some potential hazards and shortcomings, the most important of which is security issues, such as: WebSocket may transmit malicious scripts during message transmission. If the server does not properly process and filter user input, attackers may spread malicious scripts to other users through the WebSocket connection, resulting in cross-site scripting attacks; the authentication and authorization mechanisms of the WebSocket connection may be flawed, and attackers may perform unauthorized operations by forging requests or tampering with messages, resulting in cross-site request forgery attacks; attackers may inject malware or malicious code through the WebSocket connection, spread malicious files to the client or server, endanger the security of the user's device or server, and cause malware injection; WebSocket connections may be subject to man-in-the-middle attacks, and attackers can intercept and tamper with the connection, steal user sensitive information or manipulate the content of the communication, resulting in connection hijacking; malicious users may exhaust server resources through a large number of concurrent WebSocket connections or send a large number of messages, resulting in denial of service attacks, etc. Summary of the invention

[0005] The embodiments of the present invention provide an anomaly detection method, an electronic device, a storage medium and a product to solve the problem that there are some potential hazards and shortcomings in the current WebSocket communication. The specific technical solution is as follows:

[0006] A first aspect of an embodiment of the present invention provides an anomaly detection method, the method comprising:

[0007] When a target network socket request is detected, extract the source header of the target network socket request, the target protocol format used, the message format, the authentication information, and a number of target feature sequences, wherein the target feature sequence includes a target timestamp, a target request type, a target request size, and a target request frequency;

[0008] Match and verify the source header, the target protocol format, the message format, and the identity verification information with predefined information;

[0009] If the matching verification is passed, the target timestamp, target request type, target request size and target request frequency are input into the behavior analysis algorithm model according to the division of the target feature sequence, and the target anomaly score of each target feature sequence is output;

[0010] If the absolute value of the target anomaly score is greater than the target threshold, an alarm is issued.

[0011] Optionally, the predefined information includes a trusted source list regarding the network socket request, wherein the trusted source list includes a plurality of trusted first source information;

[0012] The matching and verification of the source header, the target protocol format, the message format, and the identity authentication information with the predefined information includes:

[0013] Determining second source information of the target network socket request through the source header analysis;

[0014] Retrieving the second source information from the trusted source list;

[0015] If the first source information that is consistent with the second source information is retrieved from the trusted source list, it is determined that the matching verification of the source header is passed, and the target protocol format, the message format, and the identity verification information are matched and verified with the predefined information;

[0016] If the first source information consistent with the second source information is not retrieved from the trusted source list, it is determined that the matching verification of the source header has failed, and an alarm is issued.

[0017] Optionally, the predefined information includes a list of valid protocol formats and message formats for network socket requests;

[0018] The matching and verification of the source header, the target protocol format, the message format, and the identity authentication information with the predefined information also includes:

[0019] Retrieving the target protocol format and the message format from a list of valid protocol formats and message formats;

[0020] If a protocol and a message format that are consistent with the target protocol format and the message format are found in the retrieved valid protocol format and message format list, it is determined that the matching verification of the target protocol format and the message format is passed, and the source header and the identity verification information are continued to be matched and verified with the predefined information;

[0021] If no protocol and message format consistent with the target protocol format and the message format is found in the valid protocol format and message format list, it is determined that the matching verification of the target protocol format and the message format has failed, and an alarm is issued.

[0022] Optionally, the step of inputting the target timestamp, target request type, target request size and target request frequency into the behavior analysis algorithm model according to the division of the target feature sequence, and outputting the target anomaly score of each target feature sequence, further includes:

[0023] Collecting a number of normal first network socket requests;

[0024] Performing feature extraction on each of the first network socket requests to obtain a first feature of each of the first network socket requests;

[0025] converting the first feature into a first value;

[0026] Dividing the first value according to a preset time window to generate a plurality of first feature sequences of each first network socket request, wherein one time window corresponds to one time step;

[0027] Input the first feature sequence into a behavior analysis algorithm model, and output a second value for each of the first values ​​in each of the first feature sequences;

[0028] Dividing the second value according to different first features to generate a plurality of first divided regions, wherein the same first feature belongs to the same first divided region, and different first features belong to different first divided regions;

[0029] A first average value of the second value in the first divided area is obtained, where the first average value is used to represent baseline behavior standard values ​​of different features in the network socket request.

[0030] Optionally, the first feature sequence includes a request type feature;

[0031] The step of inputting the first feature sequence into a behavior analysis algorithm model and outputting a second value for each of the first values ​​in each of the first feature sequences further includes:

[0032] Dividing the first feature sequence according to the request type to determine a plurality of second divided areas;

[0033] In each of the second divided areas, the first feature sequence is input into a behavior analysis algorithm model, and a second value for each of the first values ​​in each of the first feature sequences is output.

[0034] Optionally, after dividing the first value according to a preset time window to generate a plurality of first characteristic sequences of each first network socket request, the method further includes:

[0035] Predetermining that the first feature sequence is divided into a training set, a validation set and a test set;

[0036] Setting a target partition ratio for the training set, the validation set, and the test set;

[0037] In each of the second divided areas, the first feature sequence is divided according to the target division ratio.

[0038] Optionally, the behavior analysis algorithm model includes a recurrent neural network layer, and the recurrent neural network layer includes a target input layer, a target output layer and a target hidden layer;

[0039] The step of inputting the first feature sequence into a behavior analysis algorithm model and outputting a second value for each of the first values ​​in each of the first feature sequences further includes:

[0040] Input the first feature sequence into the recurrent neural network layer of the behavior analysis algorithm model, and obtain the target input value of the first feature sequence in the target input layer in the current time step, the first weight from the target input layer to the target hidden layer, the second weight from the target hidden layer to the target hidden layer, the third weight from the target hidden layer to the target output layer, the first bias constant term of the target hidden layer, and the second bias constant term of the target output layer;

[0041] Determine a target hidden state value of the target hidden layer by using a preset hidden state calculation formula, the target input value, the first weight, the second weight and a first bias constant term;

[0042] The target output value of the first feature sequence in the target output layer is determined by a preset target feature capture formula, the target hidden state value, the third weight and the second bias constant term.

[0043] Optionally, the hidden state calculation formula is:

[0044]

[0045] in, is the target hidden state value, is the target constant term, is the first weight from the target input layer to the target hidden layer, is the target input value, is the second weight from the target hidden layer to the target hidden layer, is the hidden state value at the previous time step, is the first bias constant term of the target hidden layer.

[0046] Optionally, the target feature capture formula is:

[0047]

[0048] in, is the target output value, is the third weight from the target hidden layer to the target output layer, is the target hidden state value, is the second bias constant term of the target output layer.

[0049] Optionally, after determining the target output value of the first feature sequence in the target output layer by using a preset target feature capture formula, the target hidden state value, the third weight and the second bias constant term, the method further includes:

[0050] Determine the first weight, the second weight and the third weight as a first target weight;

[0051] Determining the first bias constant term and the second bias constant term as a first target bias constant term;

[0052] The first target weight and the first target bias constant term are updated through an iterative optimization formula to reduce the gradient of the output.

[0053] Optionally, the iterative optimization formula is:

[0054]

[0055] in, is the second target weight or second target bias constant term for the next iteration, is the first target weight or first target bias constant term of the current iteration, is the learning rate, About A loss function is provided, wherein the first target weight is calculated correspondingly to the second target weight, and the first target bias constant term is calculated correspondingly to the second target bias constant term.

[0056] Optionally, when the matching verification is passed, the target timestamp, target request type, target request size and target request frequency are input into the behavior analysis algorithm model according to the division of the target feature sequence, and the target anomaly score of each target feature sequence is output, including:

[0057] When the matching verification is passed, the target timestamp, target request type, target request size and target request frequency are input into the behavior analysis algorithm model according to the division of the target feature sequence, and the third value of each target feature of the target feature sequence is output through the recurrent neural network of the behavior analysis algorithm model;

[0058] Determine a second average value corresponding to each target feature from the first average value;

[0059] Determine a target standard deviation corresponding to each target feature by using the third value of each target feature and the second average value;

[0060] Generate a first anomaly score for each target feature using the standard score calculation formula in the dense layer of the behavior analysis algorithm model, the third value, the second average value, and the target standard deviation;

[0061] The first anomaly score of each target feature of the target feature sequence is output as the target anomaly score of each target feature sequence.

[0062] Optionally, the standard score calculation formula is:

[0063]

[0064] in, is the first anomaly score of each target feature, is the third value of each target feature, is the second mean value corresponding to each target feature, is the target standard deviation corresponding to each target feature.

[0065] A second aspect of an embodiment of the present invention provides an abnormality detection device, the device comprising:

[0066] An extraction module is used to extract the source header, the target protocol format, the message format, the authentication information and several target feature sequences of the target network socket request when a target network socket request is detected, wherein the target feature sequence includes a target timestamp, a target request type, a target request size and a target request frequency;

[0067] A verification module, used for matching and verifying the source header, the target protocol format, the message format, and the identity verification information with predefined information;

[0068] The first input-output module is used to input the target timestamp, target request type, target request size and target request frequency into the behavior analysis algorithm model according to the division of the target feature sequence, and output the target anomaly score of each target feature sequence when the matching verification passes;

[0069] The alarm module is used to issue an alarm if the absolute value of the target anomaly score is greater than a target threshold.

[0070] A third aspect of an embodiment of the present invention provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the anomaly detection method as described in the first aspect of the embodiment of the present invention.

[0071] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the anomaly detection method as described in the first aspect of the embodiment of the present invention are implemented.

[0072] A fifth aspect of an embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the anomaly detection method as described in the first aspect of the embodiment of the present invention.

[0073] An anomaly detection method provided by an embodiment of the present invention, when a target network socket request is detected, extracts the source header of the target network socket request, the target protocol format used, the message format, the identity authentication information and several target feature sequences, wherein the target feature sequence includes a target timestamp, a target request type, a target request size and a target request frequency; matches and verifies the source header, the target protocol format, the message format, the identity authentication information with predefined information to avoid cross-site request forgery attacks, connection hijacking, etc., and when the matching verification passes, inputs the target timestamp, the target request type, the target request size and the target request frequency into a behavior analysis algorithm model according to the division of the target feature sequence, and outputs each target feature The target anomaly score of the sequence; if the target anomaly score is greater than the target threshold, an alarm is issued, and the specific characteristics of the target network socket request are analyzed to avoid cross-site scripting attacks, malware injections, denial of service attacks, etc. This embodiment can detect abnormal behaviors in time and provide early warnings by matching and verifying the source header of the target network socket request, the target protocol format used, the message format, and the identity authentication information. The behavior analysis algorithm model is used to analyze the behavior feature pattern of the target network socket request, identify abnormal or potential attack behaviors and issue an alarm, thereby improving the security of the target network socket request. In addition, the behavior analysis algorithm model can be automatically updated and optimized according to new data to adapt to the ever-changing threat environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0075] Figure 1 is a flowchart of the steps of current network socket communication shown in one embodiment of the present invention;

[0076] Figure 2 is a flowchart of a method for detecting anomalies according to an embodiment of the present invention;

[0077] Figure 3 yes Figure 2The flowchart of step 101 in an abnormality detection method shown in one embodiment of the present invention;

[0078] Figure 4 yes Figure 2 A flowchart of the steps of data preprocessing in an abnormality detection method shown in one embodiment of the present invention;

[0079] Figure 5 yes Figure 2 A neural network diagram of a behavior analysis algorithm model in an abnormality detection method shown in one embodiment of the present invention;

[0080] Figure 6 yes Figure 2 A flowchart of the steps of performing anomaly detection by using a behavior analysis algorithm model in an anomaly detection method shown in one embodiment of the present invention;

[0081] Figure 7 is a structural block diagram of an abnormality detection device provided by an embodiment of the present invention;

[0082] Figure 8 It is a schematic diagram of an electronic device shown in an embodiment of the present invention. DETAILED DESCRIPTION

[0083] To make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the embodiments of the present invention, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can be implemented. The division of the following embodiments is for the convenience of description, and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined and referenced with each other without contradiction.

[0084] Current two-way communication usually uses WebSocket network socket technology, which is widely used in current Internet applications. It is mainly used in scenarios that require real-time communication, data push and real-time monitoring, such as online chat, real-time games, stock quotes, weather forecasts, video surveillance, etc. In these scenarios, WebSocket's real-time performance, two-way communication capabilities and low bandwidth usage make it an ideal choice. WebSocket technology achieves full-duplex communication, allowing the client and server to send and receive data simultaneously, thus meeting the high requirements of these applications for real-time and interactivity. In addition, WebSocket is a component of the HTML5 specification, which defines an API that provides a full-duplex communication channel for clients (such as web browsers) and servers. For example, Figure 1 As shown, in the process of communication of WebSocket network socket technology, the client needs to send a WebSocket connection request, and then the server sends a response. This process is usually called a "handshake". In the WebSocket API, the client and the server only need to do a handshake, and then a fast channel is formed between the client and the server. At this time, the client sends a request, and the server transmits data according to the request. However, in this process, there are some potential hazards and shortcomings. In order to solve these hazards and shortcomings, an embodiment of the present invention provides an anomaly detection method, referring to Figure 2 , shows a flowchart of the steps of an abnormality detection method provided by an embodiment of the present invention, the method may include:

[0085] Step 101, when a target network socket request is detected, extract the source header of the target network socket request, the target protocol format used, the message format, the authentication information and several target feature sequences, wherein the target feature sequence includes a target timestamp, a target request type, a target request size and a target request frequency.

[0086] The embodiment of the present invention analyzes the behavior pattern of the target network socket request by capturing the behavior pattern of the target network socket request, including the frequency, type, size, source, etc. of the request, and pre-establishes a baseline behavior pattern, and identifies any abnormal behavior that deviates from these patterns based on the baseline behavior pattern, so it is necessary to collect characteristics such as the target timestamp, target request type, target request size and target request frequency in the target network socket request.

[0087] In addition to analyzing the behavior pattern, the embodiment of the present invention also provides for detection of the source, the target protocol format used, the message format, and the identity authentication information to identify abnormal attacks.

[0088] Step 102, matching and verifying the source header, target protocol format, message format, and identity authentication information with predefined information.

[0089] In the embodiment of the present invention, since there are many kinds of attacks that the target network socket request may receive, different detection methods are set according to different attack types. For example, for the cross-site WebSocket hijacking (XSSW) attack on the network socket request (the principle is: the attacker induces the victim to visit a malicious web page through some means (such as XSS attack), and the malicious web page contains WebSocket client code, which attempts to establish a WebSocket connection with the target server. If the target server does not correctly verify the origin of the request (Origin) when establishing the WebSocket connection or does not use effective CSRF (cross-site request forgery) protection measures, then the server may accept the WebSocket connection request from the malicious web page. Once the connection is established, the attacker can communicate with the server in a two-way manner through this WebSocket connection, thereby performing unauthorized operations or stealing sensitive information) in the embodiment of the present invention, a trusted source list for network socket requests is predefined to match and verify it. Therefore, the predefined information includes a trusted source list for network socket requests, and the trusted source list includes several trusted first source information.

[0090] The verification step includes: after detecting the target network socket request, first verify whether the source header of the target network socket request exists in the trusted source list, if it exists, it indicates that the verification is passed, if it does not exist, it indicates that the target network socket request is abnormal and an abnormal alarm needs to be issued. Further, step 101, such as Figure 3 As shown:

[0091] Step 1011, determining second source information of the target network socket request through source header analysis.

[0092] Step 1012: Retrieve the second source information from the trusted source list.

[0093] Step 1013, if the first source information that is consistent with the second source information is retrieved in the trusted source list, it is determined that the matching verification of the source header is passed, and the target protocol format, message format, and identity authentication information are continued to be matched and verified with the predefined information.

[0094] Step 1014: If the first source information consistent with the second source information is not found in the trusted source list, it is determined that the matching verification of the source header has failed, and an alarm is issued.

[0095] It should be noted that some custom target network socket requests do not include the source header, which will directly trigger an abnormal alarm. The above matching verification helps prevent cross-site WebSocket hijacking (XSSW) attacks and ensures that only legitimate and trusted clients can establish connections and communicate.

[0096] In addition, attackers may also try to bypass security checks by using non-standard protocols or formats. In order to avoid this attack, the embodiment of the present invention also performs matching verification on the target protocol format and message format. Therefore, the predefined information also includes a list of valid protocol formats and message formats for network socket requests. The specific steps of matching verification on the target protocol format and message format include:

[0097] Retrieve the target protocol format and message format from the valid protocol format and message format list;

[0098] If the retrieved valid protocol format and message format list contains a protocol and message format that is consistent with the target protocol format and message format, it is determined that the matching verification of the target protocol format and message format has passed, and the source header, identity authentication information and predefined information are further matched and verified;

[0099] If no protocol and message format consistent with the target protocol format and message format is found in the valid protocol format and message format list, it is determined that the matching verification of the target protocol format and message format has failed, and an alarm is issued.

[0100] For customized protocol formats and message formats, if they do not match, an alarm will still be issued. Through the above matching verification, the security and reliability of WebSocket communication can be ensured, and attackers can be prevented from bypassing security checks by using non-standard protocols or formats.

[0101] Furthermore, because of defects in the authentication and authorization mechanisms of the WebSocket connection, an attacker may forge requests or tamper with messages to perform unauthorized operations, resulting in a cross-site request forgery (CSRF) attack. To address this attack, the embodiment of the present invention may further set up authentication and authorization detection. At this time, the predefined information may further include a first authorized user information list about the network socket request, the first authorized user information list including an authorized first user identification list and a first token list applied for an authorized user. The specific steps of performing authentication and authorization detection include:

[0102] Extracting a second user identifier and a second token carried by the target network socket request from the authentication information;

[0103] Retrieve the second user identifier from the first user identifier list, and retrieve the second token from the first token list;

[0104] If a user identifier that is consistent with the second user identifier is retrieved in the first user identifier list, and a token that is consistent with the second token is retrieved in the first token list, it is determined that the matching verification of the identity authentication information is successful;

[0105] If no user identifier consistent with the second user identifier is found in the first user identifier list, and a token consistent with the second token is found in the first token list, it is determined that the matching verification of the identity authentication information has failed, and an alarm is issued.

[0106] The above steps can ensure the security and reliability of network socket request communication and avoid the problem of cross-site request forgery (CSRF) attacks caused by defects in the authentication and authorization mechanism of network socket requests, where attackers may forge requests or tamper with messages to perform unauthorized operations.

[0107] Step 103, when the matching verification is passed, the target timestamp, target request type, target request size and target request frequency are input into the behavior analysis algorithm model according to the division of the target feature sequence, and the target anomaly score of each target feature sequence is output.

[0108] After matching verification, the embodiment of the present invention analyzes the features in the target feature sequence through a preset behavior analysis algorithm model, and then outputs the target anomaly score of each target feature sequence.

[0109] It should be noted that the behavior analysis algorithm model needs to be trained before using it. During training, it is necessary to collect the first network socket requests of various situations including normal behaviors as baseline data so that the model can learn the characteristics of these behaviors. The data collected during collection can be divided into three categories. The first category is the WebSocket request body, including event data such as timestamp, source and target addresses, request and response content, etc. The second category is the timestamp, source and target addresses, message size, frequency and other features of the request event. The third category is the overall status of the system operation, where the source address is the sender (client) address of the request, and the target address is the request receiver (server) address. After collecting the data, it is necessary to extract the key first feature, and then pre-process the extracted first feature and convert it into a numerical type with the same scale and standard, that is, the first value, and then divide the processed data according to the time window. The data in each time window is called a feature sequence. After processing the data, these data can be input into the behavior analysis algorithm model to obtain the second value of each feature in the feature sequence. After calculating all the data, the second values ​​belonging to the same feature are counted and their average value is obtained. This average value is the baseline behavior standard value of this feature. The specific steps include:

[0110] Collecting a number of normal first network socket requests;

[0111] Perform feature extraction on each first network socket request to obtain a first feature of each first network socket request;

[0112] converting the first feature into a first value;

[0113] Dividing the first value according to a preset time window to generate a plurality of first feature sequences of each first network socket request, wherein one time window corresponds to one time step;

[0114] Input the first feature sequence into the behavior analysis algorithm model, and output the second value for each first value in each first feature sequence;

[0115] Dividing the second value according to different first features to generate a plurality of first divided regions, wherein the same first feature belongs to the same first divided region, and different first features belong to different first divided regions;

[0116] A first average value of the second value in the first divided area is obtained, where the first average value is used to represent baseline behavior standard values ​​of different features in the network socket request.

[0117] In the above process, the behavior analysis algorithm model is trained through the normal first network socket request to obtain the baseline behavior standard value belonging to the normal behavior, which is convenient for subsequent judgment of the behavior of new network socket requests, identification of abnormal behavior, and improvement of the security of network socket request communication.

[0118] Among them, the collected data needs to be preprocessed during the training process. The preprocessing process is as follows: Figure 4 As shown, it includes cleaning the data, then extracting features, preprocessing the extracted features, and then dividing the sequence data. After obtaining the sequence data, it is also necessary to divide the data according to a certain ratio.

[0119] Specifically, cleaning data includes removing duplicate or invalid data entries, processing any possible outliers or erroneous data, and deleting or marking invalid data that may be generated due to network errors or invalid requests.

[0120] When extracting features, different features can be extracted according to different types of features in the collected data. For example, for the extraction of time type features, since the collected network socket data usually has time series characteristics, the timestamp is extracted, and the timestamp extracted from the network socket data can be converted into a format such as a Unix timestamp or a time interval. The time interval between adjacent requests can also be determined based on the timestamp. This time interval can reflect the client's request frequency. Content features can also be extracted, such as extracting meaningful information from the request header and request data, such as the request type: extract the request type (such as GET, POST, etc.) from the request header and encode it, extract the size of the request (number of bytes) from the request header or request body, and count the number of parameters carried in the request. Statistical features can also be extracted, such as calculating the number of requests within a certain period of time (such as per minute, per hour) to obtain the request frequency, and the ratio of successfully responded requests to the total number of requests can also be counted to obtain the request success rate.

[0121] After feature extraction, the extracted features need to be preprocessed, including data standardization (which means converting the data to the same scale. For numerical features (such as request size, request frequency, etc.), standardization methods are used for processing), missing value processing (which means using the mean to fill in samples for missing feature values), and conversion to numerical types (which means ensuring that all features are numerical so that they can be input into the model. Therefore, for categorical features (such as request type), label encoding is used for conversion to convert them into numerical data).

[0122] After preprocessing, the features need to be integrated into feature sequences. When integrating, the processed data must first be divided into windows of fixed size in chronological order (such as each window contains requests for the past 1 minute or minutes). The data in each window will be regarded as an independent sequence sample, and then in each time window, the various features mentioned above are extracted and combined into a feature sequence. This feature sequence will represent the behavior pattern of the network socket request in the time window. It should be noted that this feature sequence includes request type features. Because the behavior patterns corresponding to different request types are different, the feature sequence can be divided and trained according to the request type during training to obtain different baseline behavior standards for different request types. Specifically, after dividing the first numerical value according to the preset time window and generating several first feature sequences for each first network socket request, the steps include:

[0123] Dividing the first feature sequence according to the request type to determine a plurality of second divided areas;

[0124] In each second divided area, the first feature sequence is input into the behavior analysis algorithm model, and a second value for each first value in each first feature sequence is output.

[0125] At this time, there is a feature of a request type in a second partition area. In addition, because the training process also needs verification and testing during model training, after the first feature sequence is generated, it will be divided according to a certain ratio. For example, 70% of the data is allocated to the training set, 15% of the data is allocated to the verification set, and 15% of the data is allocated to the test set. After the data is allocated, in order to ensure that each request type can be trained, the first feature sequence is divided according to the request type and then allocated in each second partition area. The specific steps include:

[0126] Predetermining that the first feature sequence is divided into a training set, a validation set and a test set;

[0127] Set target split ratios for training, validation, and test sets;

[0128] In each second divided area, the first feature sequence is divided according to the target division ratio.

[0129] For example, there are 60 first feature sequences, including request types of post and get. According to the request type, the second partition area 1 stores 20 first feature sequences of the post request type, and the second partition area 2 stores 40 first feature sequences of the get request type. The target partition ratio is set to 70% training set, 15% validation set, and 15% test set. In the model training for the post request type, 14 are used for the training set, 3 are used for the validation set, and 3 are used for the test set. In the model training for the get request type, 28 are used for the training set, 6 are used for the validation set, and 6 are used for the test set. It should be noted that the values ​​of the above settings can be adjusted according to actual conditions, and the present invention is not specifically limited here.

[0130] Through the above division, it can be ensured that the data distribution of each request type in each set is similar during training to avoid overfitting or underfitting problems.

[0131] The neural network of the behavior analysis algorithm model includes an input layer, a recurrent neural network layer, a dense layer, and an output layer, such as Figure 5 As shown in the figure, the input layer extracts features from the collected data and obtains network socket features (frequency, size, time), which is the data preprocessing in the above steps. The recurrent neural network layer is trained through the first feature sequence to learn the behavior pattern of network socket requests. The dense layer outputs anomaly scores or classifications (normal or abnormal), and the output layer performs binary classification based on the anomaly scores (for example, 0 represents normal and 1 represents abnormal).

[0132] Specifically, when the recurrent neural network layer is trained by the first feature sequence, the recurrent neural network includes a target input layer, a target output layer, and a target hidden layer, takes the received first feature sequence as input, and updates its internal state at each time step. The input data is processed by the recurrent unit at each time step and its internal state is updated. These recurrent units are able to remember past information and combine it with the input of the current time step to generate output. In this way, the RNN model is able to capture the time dependencies and patterns in the WebSocket request data. During the training process, the model will learn how to predict the output (i.e., whether the network socket request is abnormal) based on the input time series data. For example, there is a recurrent neural network layer with a target input value (x_t), a target hidden state value (h_t), a target output value (y_t), weights (W_xh) (the first weight from the target input layer to the target hidden layer), (W_hh) (the second weight from the target hidden layer to the target hidden layer) and (W_{hy}) (the third weight from the target hidden layer to the target output layer), and biases (b_h) (the first bias constant term of the target hidden layer) and (b_y) (the second bias constant term of the target output layer). In the forward propagation process, we first calculate the hidden state. State and output, where at time step t, the target hidden state value h_t is obtained by linear transformation (controlled by weights W_xh and W_hh) of the current target input value x_t, the hidden state value h_{t-1} of the previous time step, and the first bias constant term b_h of the target hidden layer. Because at time step t, the target output value y_t is obtained by linear transformation (controlled by weights W_hy) of the current target hidden state value h_t and the second bias constant term b_y of the target output layer, so after calculating the target hidden state value h_t, the output can be calculated. The specific steps include:

[0133] Input the first feature sequence into the recurrent neural network layer of the behavior analysis algorithm model, obtain the target input value of the first feature sequence in the target input layer in the current time step, the first weight from the target input layer to the target hidden layer, the second weight from the target hidden layer to the target hidden layer, the third weight from the target hidden layer to the target output layer, the first bias constant term of the target hidden layer and the second bias constant term of the target output layer;

[0134] Determine a target hidden state value of a target hidden layer by using a preset hidden state calculation formula, a target input value, a first weight, a second weight and a first bias constant term;

[0135] The target output value of the first feature sequence in the target output layer is determined by a preset target feature capture formula, a target hidden state value, a third weight and a second bias constant term.

[0136] Among them, the hidden state calculation formula is:

[0137]

[0138] in, is the target hidden state value, is the target constant term, is the first weight from the target input layer to the target hidden layer, is the target input value, is the second weight from the target hidden layer to the target hidden layer, is the hidden state value at the previous time step, is the first bias constant term of the target hidden layer.

[0139] The target feature capture formula is:

[0140]

[0141] in, is the target output value, is the third weight from the target hidden layer to the target output layer, is the target hidden state value, is the second bias constant term of the target output layer.

[0142] Through the above process, each feature in the first feature sequence can be learned. When there are enough values, the average value can be calculated as the baseline behavior standard value to identify abnormal requests and ensure the security of communication.

[0143] Different weights in the recurrent neural network layer are the values ​​that connect different layers or neurons in the neural network. They determine the degree of influence of the output of the neurons in the previous layer on the neurons in the next layer. Weights are used not only to capture the characteristics of the current input, but also to capture patterns in time series. Bias is a constant term added to the output of the neuron. It allows neurons to have a certain activation value even without input. Bias can help the model learn the offset or trend of the data.

[0144] During the training process, due to the concept of time steps, the update of weights and biases will involve the gradients of all time steps, and the model will calculate the error between the predicted output and the actual output. Through back propagation, the gradient of the loss function with respect to the model parameters is calculated, and the error is back propagated from the output layer to the input layer to determine the impact of each parameter (weight and bias) on the loss. Gradient descent is an optimization algorithm used to update parameters according to the gradient of the loss function with respect to the parameters. In each iteration, the model is updated in the opposite direction of the gradient (i.e., the direction in which the loss decreases), so the embodiment of the present invention calculates the gradient of the loss function (bias) with respect to the output, and uses the back propagation algorithm to calculate the gradient of the loss function with respect to all parameters. In the gradient descent process, the weights and biases are updated. For example, updating the weight (W_xh) means that at time step t+1, the value of the weight (W_xh) is updated to the value of the current time step t minus the learning rate η multiplied by the partial derivative (gradient, i.e., the deviation rate) of the loss function J with respect to (W_xh). The formula is:

[0145] W_{xh,t+1}=W_{xh,t}-η*∂J / ∂W_xh

[0146] Explanation: W_{xh,t} is the weight from the target input layer to the target hidden layer at time step t, W_{xh,t+1} is the weight from the target input layer to the target hidden layer updated at time step t+1, η is the learning rate, ∂J / ∂W_xh is the partial derivative (gradient, i.e., bias rate) of the loss function J with respect to (W_xh).

[0147] Update the weights of the target hidden layer to the target hidden layer using the same settings. The formula is:

[0148] W_{hh,t+1}=W_{hh,t}-η*∂J / ∂W_hh

[0149] Where W_{hh,t} is the weight from the target hidden layer to the target hidden layer at time step t, W_{hh,t+1} is the weight from the target hidden layer to the target hidden layer updated at time step t+1, η is the learning rate, and ∂J / ∂W_hh is the partial derivative (gradient, i.e., bias rate) of the loss function J with respect to (W_hh).

[0150] According to the same settings, the weights of the target hidden layer to the target output layer are updated. The formula is:

[0151] W_{hy,t+1}=W_{hy,t}-η*∂J / ∂W_hy

[0152] Where W_{hy,t} is the weight from the target hidden layer to the target output layer at time step t, W_{hy,t+1} is the weight from the target hidden layer to the target output layer updated at time step t+1, η is the learning rate, and ∂J / ∂W_hy is the partial derivative (gradient, i.e., bias rate) of the loss function J with respect to (W_hy).

[0153] Update the first bias constant term of the target hidden layer according to the same settings. The formula is:

[0154] b_{h,t+1}=b_{h,t}-η*∂J / ∂b_h

[0155] Where b_{h,t} is the bias constant term of the target hidden layer at time step t, b_{h,t+1} is the bias constant term of the target hidden layer updated at time step t+1, η is the learning rate, and ∂J / ∂b_h is the partial derivative (gradient, i.e., bias rate) of the loss function J with respect to (b_h).

[0156] Update the second bias constant term of the target output layer according to the same settings. The formula is:

[0157] b_{y,t+1}=b_{y,t}-η*∂J / ∂b_y

[0158] Where b_{y,t} is the bias constant term of the target output layer at time step t, b_{y,t+1} is the bias constant term of the target output layer updated at time step t+1, η is the learning rate, and ∂J / ∂b_y is the partial derivative (gradient, i.e., bias rate) of the loss function J with respect to (b_y).

[0159] It can be seen that for the update of weights and biases, except for the different specific updated parameters, the actual calculation steps are the same, so in the embodiment of the present invention, the weight and bias constant terms are integrated, and then the same formula is set to represent the update process. The specific steps include:

[0160] determining the first weight, the second weight, and the third weight as a first target weight;

[0161] determining the first bias constant term and the second bias constant term as a first target bias constant term;

[0162] The first target weight and the first target bias constant term are updated through an iterative optimization formula to reduce the gradient of the output.

[0163] The iterative optimization formula is:

[0164]

[0165] in, is the second target weight or second target bias constant term for the next iteration, is the first target weight or first target bias constant term of the current iteration, is the learning rate, About A loss function is provided, wherein the first target weight is calculated correspondingly to the second target weight, and the first target bias constant term is calculated correspondingly to the second target bias constant term.

[0166] Through the above process, the weights and bias terms can be made to minimize the prediction error as much as possible, so that the model can fit the data more accurately.

[0167] In the above process, after training the recurrent neural network layer, the normal baseline behavior standard value of each feature can be obtained. Then, for the newly input data, after data preprocessing, it is input into the model. The model judges its request behavior according to the feature value of the current request, and judges whether the current behavior is normal or abnormal according to the baseline behavior, and then outputs the abnormal score in the dense layer. The calculation principle of the abnormal score is: when an input data is input into the model after data preprocessing, the model obtains the res value of each feature value through the formula of the recurrent neural network layer. Then, due to the baseline behavior pattern trained by the model, each feature value here has a baseline behavior standard value. By calculating the difference between the res value and the baseline behavior standard value relative to the size of the standard deviation, the abnormal score corresponding to each feature is obtained. Because there are multiple features in the feature sequence, the abnormal score of each feature in the sequence can be output as the target abnormal score. The specific steps include: when the matching verification passes, the target timestamp, target request type, target request size and target request frequency are input into the behavior analysis algorithm model according to the division of the target feature sequence, and the third value of each target feature of the target feature sequence is output through the recurrent neural network of the behavior analysis algorithm model;

[0168] Determine a second average value corresponding to each target feature from the first average value;

[0169] Determine a target standard deviation corresponding to each target feature by using the third value of each target feature and the second average value;

[0170] Generate a first anomaly score for each target feature using the standard score calculation formula in the dense layer of the behavior analysis algorithm model, the third value, the second mean value, and the target standard deviation;

[0171] The first anomaly score of each target feature of the target feature sequence is output as the target anomaly score of each target feature sequence.

[0172] The standard score calculation formula is:

[0173]

[0174] in, is the first anomaly score of each target feature, is the third value of each target feature, is the second mean value corresponding to each target feature, is the target standard deviation corresponding to each target feature.

[0175] It should be noted that after calculating the anomaly score of each feature, you can also get the absolute value of each first anomaly score, and then perform weighted summation, which is implemented by the code total_res = sum(weight[i] * res[i]for iin range(len(res))) to obtain the overall deviation degree of the sequence.

[0176] The above steps determine the anomaly scores of different features, which facilitates accurate identification of abnormal behaviors based on the anomaly scores.

[0177] Step 104: If the absolute value of the target anomaly score is greater than the target threshold, an alarm is issued.

[0178] In the embodiment of the present invention, the target anomaly score can be a positive number, a negative number or 0. If it is close to 0, it means that the third value of the target feature is close to the second average value corresponding to the target feature, which means that this observation value (corresponding to the third value of the target feature) is "normal". If it is a positive number and is very large (for example, greater than 2 or 3), it indicates that the third value of the target feature is much larger than the second average value corresponding to the target feature, indicating that this observation value is larger than most normal observation values ​​and may be abnormal. If it is a negative number and the absolute value is very large (for example, less than -2 or -3), it indicates that the third value of the target feature is much smaller than the second average value corresponding to the target feature, indicating that this observation value is smaller than most normal observation values ​​and is also abnormal.

[0179] Therefore, when comparing with the target threshold, the absolute value of the target anomaly score is first obtained, and then when it is determined that the absolute value of the target anomaly score is greater than the target threshold, it is considered to deviate from the normal value and an alarm is issued.

[0180] It should be noted that after determining that the absolute value of the target anomaly score is greater than the target threshold, a binary value will be output in the output layer for classification (for example, 0 represents normal and 1 represents abnormal), and when determining the abnormality, the target anomaly score of the feature with the largest deviation will also be output as an alarm information.

[0181] In summary, the steps of performing anomaly detection using a behavior analysis algorithm model in the embodiment of the present invention are as follows: Figure 6As shown, normal network socket request data is collected, data features are extracted and preprocessed on the collected data, and a behavior analysis algorithm model is trained based on the processed content. Then, new network socket requests are obtained, and the new network socket requests are analyzed through the model to determine whether the features contained therein are normal behaviors. If not, alarms and monitoring are performed.

[0182] For example, the current target network socket request extracts the following target feature sequence (assuming three time steps):

[0183] Time step 1: [timestamp 1, request size 1, request frequency 1 ...]

[0184] Time step 2: [timestamp 2, request size 2, request frequency 2 ...]

[0185] Time step 3: [timestamp 3, request size 3, request frequency 3 ...]

[0186] Model processing

[0187] Input processing: Input the target feature sequence into the behavior analysis algorithm model. At each time step, the recurrent neural network layer of the behavior analysis algorithm model accepts a feature sequence (such as [timestamp, request size, request frequency]) as input.

[0188] Internal processing of the recurrent neural network layer:

[0189] The recurrent neural network layer captures the requests observed so far. It matches the type of request (e.g., whether it is currently acquiring data or transmitting data; transmitting text data or script data, etc.) to see if it is abnormal. It then calculates the hidden states of all features based on the current input and combines the baseline behavior standard value to obtain the target anomaly score for each feature.

[0190] Output:

[0191] Output target anomaly score, which will generate a corresponding target anomaly score for each feature of each input sequence. The target score indicates the degree of deviation of the target feature from the normal network socket request pattern. Then decide whether to alarm based on the set threshold. The feature value with the largest abnormal value is reported as an alarm anomaly. The model outputs the target anomaly score, and the higher the absolute value of the score, the greater the possibility of anomaly:

[0192] For example, the anomaly score output for the request size feature is 0.123.

[0193] An anomaly detection method provided by an embodiment of the present invention, when a target network socket request is detected, extracts the source header of the target network socket request, the target protocol format used, the message format, the identity authentication information and several target feature sequences, wherein the target feature sequence includes a target timestamp, a target request type, a target request size and a target request frequency; matches and verifies the source header, the target protocol format, the message format, the identity authentication information with predefined information to avoid cross-site request forgery attacks, connection hijacking, etc., and when the matching verification passes, inputs the target timestamp, the target request type, the target request size and the target request frequency into a behavior analysis algorithm model according to the division of the target feature sequence, and outputs each target feature The target anomaly score of the sequence; if the target anomaly score is greater than the target threshold, an alarm is issued, and the specific characteristics of the target network socket request are analyzed to avoid cross-site scripting attacks, malware injections, denial of service attacks, etc. This embodiment can detect abnormal behaviors in time and provide early warnings by matching and verifying the source header of the target network socket request, the target protocol format used, the message format, and the identity authentication information. The behavior analysis algorithm model is used to analyze the behavior feature pattern of the target network socket request, identify abnormal or potential attack behaviors and issue an alarm, thereby improving the security of the target network socket request. In addition, the behavior analysis algorithm model can be automatically updated and optimized according to new data to adapt to the ever-changing threat environment.

[0194] Reference Figure 7 , which shows a schematic diagram of the structure of an abnormality detection device provided by an embodiment of the present invention, such as Figure 7 As shown, the device may include:

[0195] The extraction module 201 is used to extract the source header of the target network socket request, the target protocol format used, the message format, the authentication information and several target feature sequences when a target network socket request is detected, wherein the target feature sequence includes a target timestamp, a target request type, a target request size and a target request frequency.

[0196] The verification module 202 is used to match and verify the source header, target protocol format, message format, and identity verification information with predefined information.

[0197] The first input-output module 203 is used to input the target timestamp, target request type, target request size and target request frequency into the behavior analysis algorithm model according to the division of the target feature sequence when the matching verification is passed, and output the target anomaly score of each target feature sequence.

[0198] The alarm module 204 is used to generate an alarm if the absolute value of the target anomaly score is greater than the target threshold.

[0199] Optionally, the predefined information includes a trusted source list regarding the network socket request, wherein the trusted source list includes several trusted first source information.

[0200] The verification module 202 specifically includes:

[0201] The first determining submodule is used to determine the second source information of the target network socket request through source header analysis.

[0202] The first retrieval submodule is used to retrieve the second source information in the trusted source list.

[0203] The second determination submodule is used to determine that the matching verification of the source header has passed if the first source information consistent with the second source information is retrieved from the trusted source list, and continue to match and verify the target protocol format, message format, and identity authentication information with the predefined information.

[0204] The third determination submodule is used to determine that the matching verification of the source header has failed and issue an alarm if the first source information consistent with the second source information is not found in the trusted source list.

[0205] Optionally, the predefined information includes a list of valid protocol formats and message formats for network socket requests.

[0206] The verification module 202 specifically includes:

[0207] The second retrieval submodule is used to retrieve the target protocol format and message format in the valid protocol format and message format list.

[0208] The fourth determination submodule is used to determine that the matching verification of the target protocol format and message format has passed if a protocol and message format consistent with the target protocol format and message format is found in the retrieved valid protocol format and message format list, and continue to match and verify the source header, identity authentication information and predefined information.

[0209] The fifth determination submodule is used to determine that the matching verification of the target protocol format and message format has failed and issue an alarm if no protocol and message format consistent with the target protocol format and message format is found in the valid protocol format and message format list.

[0210] Optionally, the anomaly detection device further includes:

[0211] The first collection module is used to collect a number of normal first network socket requests.

[0212] The first acquisition module is used to extract features from each first network socket request to obtain a first feature of each first network socket request.

[0213] The numerical conversion module is used to convert the first feature into a first numerical value.

[0214] The first generating module is used to divide the first value according to a preset time window to generate a plurality of first feature sequences of each first network socket request, wherein one time window corresponds to one time step.

[0215] The second input-output module is used to input the first feature sequence into the behavior analysis algorithm model, and output the second value for each first value in each first feature sequence.

[0216] The second generating module is used to divide the second value according to different first features to generate a plurality of first divided areas, wherein the same first feature belongs to the same first divided area, and different first features belong to different first divided areas.

[0217] The second acquisition module is used to obtain a first average value of the second value in the first divided area, where the first average value is used to represent the baseline behavior standard value of different features in the network socket request.

[0218] Optionally, the first feature sequence includes a request type feature.

[0219] The second input and output module specifically includes:

[0220] The sixth determination submodule is used to divide the first feature sequence according to the request type and determine a plurality of second divided areas.

[0221] The first input-output submodule is used to input the first feature sequence into the behavior analysis algorithm model in each second divided area, and output the second value related to each first value in each first feature sequence.

[0222] The seventh determination submodule is used to predetermine that the first feature sequence is divided into a training set, a verification set and a test set.

[0223] The setup submodule is used to set the target split ratio for the training set, validation set, and test set.

[0224] The division submodule is used to divide the first feature sequence according to the target division ratio in each second division area.

[0225] Optionally, the behavior analysis algorithm model includes a recurrent neural network layer, and the recurrent neural network layer includes a target input layer, a target output layer and a target hidden layer.

[0226] The second input-output module specifically includes:

[0227] The first acquisition submodule is used to input the first feature sequence into the recurrent neural network layer of the behavior analysis algorithm model, obtain the target input value of the first feature sequence in the target input layer in the current time step, the first weight from the target input layer to the target hidden layer, the second weight from the target hidden layer to the target hidden layer, the third weight from the target hidden layer to the target output layer, the first bias constant term of the target hidden layer and the second bias constant term of the target output layer.

[0228] The eighth determination submodule is used to determine the target hidden state value of the target hidden layer through a preset hidden state calculation formula, a target input value, a first weight, a second weight and a first bias constant term.

[0229] The ninth determination submodule is used to determine the target output value of the first feature sequence in the target output layer through a preset target feature capture formula, a target hidden state value, a third weight and a second bias constant term.

[0230] Optionally, the hidden state is calculated as:

[0231]

[0232] in, is the target hidden state value, is the target constant term, is the first weight from the target input layer to the target hidden layer, is the target input value, is the second weight from the target hidden layer to the target hidden layer, is the hidden state value at the previous time step, is the first bias constant term of the target hidden layer.

[0233] Optionally, the target feature capture formula is:

[0234]

[0235] in, is the target output value, is the third weight from the target hidden layer to the target output layer, is the target hidden state value, is the second bias constant term of the target output layer.

[0236] Optionally, the anomaly detection device further includes:

[0237] The first determination module is used to determine the first weight, the second weight and the third weight as a first target weight.

[0238] The second determining module is used to determine the first bias constant term and the second bias constant term as a first target bias constant term.

[0239] An update module is used to update the first target weight and the first target bias constant term through an iterative optimization formula to reduce the gradient of the output.

[0240] Optionally, the iterative optimization formula is:

[0241]

[0242] in, is the second target weight or second target bias constant term for the next iteration, is the first target weight or first target bias constant term of the current iteration, is the learning rate, About A loss function is provided, wherein the first target weight is calculated correspondingly to the second target weight, and the first target bias constant term is calculated correspondingly to the second target bias constant term.

[0243] Optionally, the first input-output module 203 specifically includes:

[0244] The second input-output submodule is used to input the target timestamp, target request type, target request size and target request frequency into the behavior analysis algorithm model according to the division of the target feature sequence when the matching verification is passed, and output the third numerical value of each target feature of the target feature sequence through the recurrent neural network of the behavior analysis algorithm model.

[0245] The tenth determination submodule is used to determine a second average value corresponding to each target feature from the first average value.

[0246] The eleventh determination submodule is used to determine the target standard deviation corresponding to each target feature through the third value and the second average value of each target feature.

[0247] The generation submodule is used to generate a first anomaly score for each target feature by using a standard score calculation formula in a dense layer of the behavior analysis algorithm model, a third value, a second average value, and a target standard deviation.

[0248] The output submodule is used to output the first anomaly score of each target feature of the target feature sequence as the target anomaly score of each target feature sequence.

[0249] Optionally, the standard score calculation formula is:

[0250]

[0251] in, is the first anomaly score of each target feature, is the third value of each target feature, is the second mean value corresponding to each target feature, is the target standard deviation corresponding to each target feature.

[0252] An anomaly detection method provided by an embodiment of the present invention, when a target network socket request is detected, extracts the source header of the target network socket request, the target protocol format used, the message format, the identity authentication information and several target feature sequences, wherein the target feature sequence includes a target timestamp, a target request type, a target request size and a target request frequency; matches and verifies the source header, the target protocol format, the message format, the identity authentication information with predefined information to avoid cross-site request forgery attacks, connection hijacking, etc., and when the matching verification passes, inputs the target timestamp, the target request type, the target request size and the target request frequency into a behavior analysis algorithm model according to the division of the target feature sequence, and outputs each target feature The target anomaly score of the sequence; if the target anomaly score is greater than the target threshold, an alarm is issued, and the specific characteristics of the target network socket request are analyzed to avoid cross-site scripting attacks, malware injections, denial of service attacks, etc. This embodiment can detect abnormal behaviors in time and provide early warnings by matching and verifying the source header of the target network socket request, the target protocol format used, the message format, and the identity authentication information. The behavior analysis algorithm model is used to analyze the behavior feature pattern of the target network socket request, identify abnormal or potential attack behaviors and issue an alarm, thereby improving the security of the target network socket request. In addition, the behavior analysis algorithm model can be automatically updated and optimized according to new data to adapt to the ever-changing threat environment.

[0253] Based on the same inventive concept, another embodiment of the present invention provides an electronic device 300, such as Figure 8 shown. Figure 8 3 is a schematic diagram of an electronic device according to an embodiment of the present invention. The electronic device includes a processor 301, a memory 302, and a computer program stored in the memory 302 and executable on the processor 301, wherein the computer program implements the steps of the anomaly detection method according to any of the above embodiments of the present invention when executed by the processor.

[0254] Based on the same inventive concept, another embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the anomaly detection method described in any of the above embodiments of the present invention are implemented.

[0255] Based on the same inventive concept, another embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps in the anomaly detection method described in any of the above embodiments of the present invention.

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

[0257] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the relevant technology, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, computer, server, air conditioner, or network equipment, etc.) to execute the methods described in each embodiment of the present invention.

[0258] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.

[0259] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0260] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0261] In the embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0262] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0263] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0264] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or optical disk, etc., which can store program code.

[0265] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. An anomaly detection method, characterized in that: The method comprises: When a target network socket request is detected, extract the source header of the target network socket request, the target protocol format used, the message format, the authentication information, and a number of target feature sequences, wherein the target feature sequence includes a target timestamp, a target request type, a target request size, and a target request frequency; Match and verify the source header, the target protocol format, the message format, the identity verification information and predefined information, wherein the matching verification for the target protocol format, the message format and the identity verification information is performed when the source header passes the matching verification, and the predefined information includes a trusted source list, a valid protocol format, a message format list and a first authorized user information list about the network socket request, wherein the trusted source list is used to retrieve the second source message of the network socket request to verify the source header, the valid protocol format and the message format list are used to retrieve the target protocol format and the message format for verification, and the first authorized user information list is used to retrieve the second user identifier and the second token of the target network socket request to verify the identity verification information; In the case where the matching verification passes, the target timestamp, target request type, target request size and target request frequency are input into the behavior analysis algorithm model according to the division of the target feature sequence, and the target anomaly score of each target feature sequence is output, the target anomaly score includes a first anomaly score of each target feature in the target feature sequence, the first anomaly score is obtained according to the third value, the second average value and the target standard deviation of each target feature, the third value is obtained by the recurrent neural network of the behavior analysis algorithm model, the second average value is obtained from the baseline behavior standard values ​​of different features in the network socket request, the target standard deviation is obtained by the third value and the second average value, the baseline behavior standard value is divided based on different request types, and the baseline behavior standard value characterizes the normal behavior of each feature; If the absolute value of the target anomaly score is greater than the target threshold, an alarm is issued; Before inputting the target timestamp, target request type, target request size and target request frequency into the behavior analysis algorithm model according to the division of the target feature sequence and outputting the target anomaly score of each target feature sequence, the method further includes: Collecting a number of normal first network socket requests; Performing feature extraction on each of the first network socket requests to obtain a first feature of each of the first network socket requests; converting the first feature into a first value; Dividing the first value according to a preset time window to generate a plurality of first feature sequences of each first network socket request, wherein one time window corresponds to one time step; Inputting the first feature sequence into a behavior analysis algorithm model, outputting a second value for each of the first values ​​in each of the first feature sequences, wherein the behavior analysis algorithm model comprises a recurrent neural network layer, and the recurrent neural network layer comprises a target input layer, a target output layer, and a target hidden layer; Dividing the second value according to different first features to generate a plurality of first divided regions, wherein the same first feature belongs to the same first divided region, and different first features belong to different first divided regions; Obtaining a first average value of the second value in the first divided area, wherein the first average value is used to represent a baseline behavior standard value of different features in the network socket request; The step of inputting the first feature sequence into a behavior analysis algorithm model and outputting a second value for each of the first values ​​in each of the first feature sequences further includes: Input the first feature sequence into the recurrent neural network layer of the behavior analysis algorithm model, and obtain the target input value of the first feature sequence in the target input layer in the current time step, the first weight from the target input layer to the target hidden layer, the second weight from the target hidden layer to the target hidden layer, the third weight from the target hidden layer to the target output layer, the first bias constant term of the target hidden layer, and the second bias constant term of the target output layer; Determine a target hidden state value of the target hidden layer by using a preset hidden state calculation formula, the target input value, the first weight, the second weight and a first bias constant term; Determine a target output value of the first feature sequence in the target output layer by using a preset target feature capture formula, the target hidden state value, the third weight and the second bias constant term; Wherein, the hidden state calculation formula is: in, is the target hidden state value, is the target constant term, is the first weight from the target input layer to the target hidden layer, is the target input value, is the second weight from the target hidden layer to the target hidden layer, is the hidden state value at the previous time step, is the first bias constant term of the target hidden layer.

2. The abnormality detection method according to claim 1, characterized in that: The trusted source list includes a plurality of trusted first source information; The matching and verification of the source header, the target protocol format, the message format, and the identity authentication information with the predefined information includes: Determining second source information of the target network socket request through the source header analysis; Retrieving the second source information from the trusted source list; If the first source information that is consistent with the second source information is retrieved from the trusted source list, it is determined that the matching verification of the source header is passed, and the target protocol format, the message format, and the identity verification information are matched and verified with the predefined information; If the first source information consistent with the second source information is not retrieved from the trusted source list, it is determined that the matching verification of the source header has failed, and an alarm is issued.

3. The abnormality detection method according to claim 1, characterized in that: The matching and verification of the source header, the target protocol format, the message format, and the identity authentication information with the predefined information also includes: Retrieving the target protocol format and the message format from a list of valid protocol formats and message formats; If a protocol and a message format that are consistent with the target protocol format and the message format are found in the retrieved valid protocol format and message format list, it is determined that the matching verification of the target protocol format and the message format is passed, and the source header and the identity verification information are continued to be matched and verified with the predefined information; If no protocol and message format consistent with the target protocol format and the message format is found in the valid protocol format and message format list, it is determined that the matching verification of the target protocol format and the message format has failed, and an alarm is issued.

4. The abnormality detection method according to claim 1, characterized in that: The first feature sequence includes a request type feature; The step of inputting the first feature sequence into a behavior analysis algorithm model and outputting a second value for each of the first values ​​in each of the first feature sequences further includes: Dividing the first feature sequence according to the request type to determine a plurality of second divided areas; In each of the second divided areas, the first feature sequence is input into a behavior analysis algorithm model, and a second value for each of the first values ​​in each of the first feature sequences is output.

5. The abnormality detection method according to claim 4, characterized in that: After dividing the first value according to the preset time window to generate a plurality of first characteristic sequences of each first network socket request, the method further includes: Predetermining that the first feature sequence is divided into a training set, a validation set and a test set; Setting a target partition ratio for the training set, the validation set, and the test set; In each of the second divided areas, the first feature sequence is divided according to the target division ratio.

6. The abnormality detection method according to claim 1, characterized in that: The target feature capture formula is: in, is the target output value, is the third weight from the target hidden layer to the target output layer, is the target hidden state value, is the second bias constant term of the target output layer.

7. The abnormality detection method according to claim 1, characterized in that: After determining the target output value of the first feature sequence in the target output layer by using the preset target feature capture formula, the target hidden state value, the third weight and the second bias constant term, the method further includes: Determine the first weight, the second weight and the third weight as a first target weight; Determining the first bias constant term and the second bias constant term as a first target bias constant term; The first target weight and the first target bias constant term are updated through an iterative optimization formula to reduce the gradient of the output.

8. The abnormality detection method according to claim 7, characterized in that: The iterative optimization formula is: in, is the second target weight or second target bias constant term for the next iteration, is the first target weight or first target bias constant term of the current iteration, is the learning rate, About A loss function is provided, wherein the first target weight is calculated correspondingly to the second target weight, and the first target bias constant term is calculated correspondingly to the second target bias constant term.

9. The abnormality detection method according to claim 1, characterized in that: In the case where the matching verification is passed, the target timestamp, target request type, target request size and target request frequency are input into the behavior analysis algorithm model according to the division of the target feature sequence, and the target anomaly score of each target feature sequence is output, including: When the matching verification is passed, the target timestamp, target request type, target request size and target request frequency are input into the behavior analysis algorithm model according to the division of the target feature sequence, and the third value of each target feature of the target feature sequence is output through the recurrent neural network of the behavior analysis algorithm model; Determine a second average value corresponding to each target feature from the first average value; Determine a target standard deviation corresponding to each target feature by using the third value of each target feature and the second average value; Generate a first anomaly score for each target feature using the standard score calculation formula in the dense layer of the behavior analysis algorithm model, the third value, the second average value, and the target standard deviation; The first anomaly score of each target feature of the target feature sequence is output as the target anomaly score of each target feature sequence.

10. The abnormality detection method according to claim 9, characterized in that: The standard score calculation formula is: in, is the first anomaly score of each target feature, is the third value of each target feature, is the second mean value corresponding to each target feature, is the target standard deviation corresponding to each target feature.

11. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the abnormality detection method according to any one of claims 1 to 10 are implemented.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the abnormality detection method according to any one of claims 1 to 10 are implemented.

13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps in the anomaly detection method according to any one of claims 1 to 10 are implemented.