Web attack detection method and device
By extracting and decoding the characteristics of Web requests, and updating attack rules to detect new attack types, the problem of the inability of existing technologies to update rules in a timely manner is solved, and the security of the origin server is improved.
Patent Information
- Application Number
- CN202411049417.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-08-01
AI Technical Summary
Existing web attack detection methods cannot update attack rules in a timely manner, resulting in the inability to detect new attack types and causing the system to be attacked.
By receiving the user's Web request, it extracts request characteristics in multiple dimensions, identifies and decodes the request characteristics based on encoding detection, and determines whether there is a match with the preset attack rules. If it matches, the attack load update rules are extracted from the matching rules.
It can update attack rules in a timely manner, improve the security of the origin server, detect new attack types or more accurately identify original attack types, and enhance security.
Smart Images

Figure CN118740510A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a Web attack detection method and device. Background Art
[0002] With the rapid development of Internet technology, Web applications have become an indispensable part of modern society. However, the security issues of Web applications are becoming increasingly prominent. Various Web attacks such as SQL injection, cross-site scripting, and cross-site request forgery pose a serious threat to user privacy and data security. Therefore, efficient and accurate Web attack detection methods have become an important research topic in the field of network security.
[0003] Traditional Web attack detection methods are mainly based on pattern matching based on set attack rules, and the set attack rules are updated by the management at a certain period.
[0004] However, new attack types may appear in Web requests, which cannot be detected by the set attack rules. The existing methods cannot update the attack rules in time, which leads to the system being attacked. Summary of the invention
[0005] The present invention provides a Web attack detection method and device, which can timely update attack rules and improve the security of source station servers.
[0006] In a first aspect, an embodiment of the present invention provides a Web attack detection method, comprising:
[0007] Receive web requests sent by users;
[0008] Extracting request features of multiple dimensions from the Web request;
[0009] Identify the encoding mode of each of the request features based on the encoding detection;
[0010] Decoding the request feature based on the encoding method of the request feature to obtain an original feature corresponding to the request feature;
[0011] Determine whether there is an original feature that matches the preset current attack rule. If not, forward the Web request to the source server. Otherwise, extract the attack payload from the original feature that matches the current attack rule, and update the current attack rule based on the attack payload.
[0012] In a second aspect, an embodiment of the present invention provides a Web attack detection device, including:
[0013] A receiving module, configured to receive a Web request sent by a user;
[0014] An extraction module, configured to extract request features of multiple dimensions from the Web request;
[0015] A decoding module, configured to identify the encoding mode of each of the request features based on the encoding detection; decode the request features based on the encoding mode of the request features to obtain the original features corresponding to the request features;
[0016] The determination module is configured to determine whether there is an original feature that matches a preset current attack rule. If not, the Web request is forwarded to the source server; otherwise, the attack load is extracted from the original feature that matches the current attack rule, and the current attack rule is updated based on the attack load.
[0017] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0018] one or more processors;
[0019] a storage device for storing one or more programs,
[0020] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0021] In a fourth aspect, an embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the above embodiments.
[0022] An embodiment of the above invention has the following advantages or beneficial effects: for requests with Web attacks, attack payloads are further extracted from the original features. When new attack types exist or the features of the original attack types change, the attack-related features will be reflected in the attack payload. Therefore, by updating the attack rules through the attack payload, the attack rules can be used to detect new attack types or more accurately identify the original attack types, thereby improving the security of the source server.
[0023] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a flow chart of a Web attack detection method provided by an embodiment of the present invention;
[0025] Figure 2 is a flow chart of a Web attack detection method provided by another embodiment of the present invention;
[0026] Figure 3It is a schematic diagram of a Web attack detection device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0027] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0028] like Figure 1 As shown, an embodiment of the present invention provides a Web attack detection method, including:
[0029] Step 101: Receive a web request sent by a user.
[0030] The web request is used to access the origin server. The web request includes a request header, a request body, etc.
[0031] Step 102: Extract request features of multiple dimensions from the Web request.
[0032] The dimensions may include any one or more of: URL, request body, User-Agent, and cookie.
[0033] Step 103: Identify the encoding method of each request feature based on encoding detection.
[0034] Encoding detection is to decode through different decoding methods to determine the encoding method of the request feature. Encoding methods include base64 encoding, Unicode encoding, etc.
[0035] Step 104: Decode the request feature based on the encoding method of the request feature to obtain the original feature corresponding to the request feature.
[0036] The decoded request features are the original features.
[0037] Step 105: Determine whether there is an original feature that matches the preset current attack rule. If not, execute step 106; otherwise, execute step 107.
[0038] The current attack rule may include rules corresponding to any one or more matching models of equal matching, inclusion matching, and regular matching. Taking regular matching as an example, the current attack rule includes a regular expression. An attack rule is usually used to detect one type of attack. Of course, in some scenarios, multiple attack rules can also be used to detect one type of attack.
[0039] Step 106: Forward the web request to the origin server.
[0040] If there is no current attack rule that matches the original signature, it is considered that there is no web attack on the web request and it can be directly forwarded to the origin server.
[0041] Step 107: extract the attack payload from the original features that match the current attack rule, and update the current attack rule based on the attack payload.
[0042] In an embodiment of the present invention, for requests with Web attacks, attack payloads are further extracted from the original features. When new attack types exist or the features of the original attack types change, attack-related features will be reflected in the attack payload. Therefore, by updating the attack rules through the attack payload, the attack rules can be used to detect new attack types or more accurately identify the original attack types, thereby improving the security of the source server.
[0043] In one embodiment of the present invention, the attack rules include: multiple target dimensions, target matching patterns;
[0044] Determine whether there are original features that match the preset current attack rules, including:
[0045] Combine the original features of multiple target dimensions;
[0046] Determine whether the combined original features match the target matching pattern;
[0047] The target matching mode includes: equal matching, including matching and regular matching.
[0048] The current attack rule may involve multiple target dimensions. In this case, you need to combine the original features of multiple target dimensions according to the current attack rule. For example, if the current attack rule involves two dimensions, URL and request body, you need to combine the specific contents corresponding to these two dimensions and match the combined contents with the target matching pattern. Different target matching patterns contain different contents. For regular matching, the target matching pattern includes regular expressions, and for equal matching, the target matching pattern includes the set threshold.
[0049] Through the embodiments of the present invention, original features can be detected from multiple dimensions using different matching modes, thereby improving the accuracy of Web attack detection and further improving the security of the source server.
[0050] In one embodiment of the present invention, the attack rule includes: a target dimension and a target matching pattern;
[0051] Extract attack payload from the original features that match the current attack rules, including:
[0052] Determine the location of content in the original signature that matches the current attack rule;
[0053] Determine the extraction scope based on the target matching pattern and the location of the content;
[0054] Extract the attack payload from the original features based on the extraction range.
[0055] Considering that other types of attacks may exist near the current attack, the embodiment of the present invention determines the extraction range by the position of the content matching the current attack rule. For different target matching modes, the extraction range can be adaptively adjusted to reduce the amount of calculation while ensuring the accuracy of Web attack detection.
[0056] In one embodiment of the present invention, updating the current attack rule based on the attack load includes:
[0057] Determine the type of attack payload; the types of attack payload include: any one or more of malicious code, session token, and sensitive data;
[0058] Update the current attack rules based on the type of attack payload.
[0059] For example, the current attack rules only target malicious code, but there are no attack rules for sensitive data. If there is sensitive data in the attack payload, it is necessary to add attack rules for sensitive data. The added attack rules can be obtained from the pre-established rule library.
[0060] In actual application scenarios, the added attack rules may also come from the management party. In this case, the current attack rules are updated based on the attack load, including: sending the attack load to the management party so that the management party analyzes the attack load and updates the current attack rules.
[0061] Through the embodiments of the present invention, the current attack rules can be updated in time based on the attack load, so that the current attack rules are applicable to new Web attacks, thereby improving the accuracy of Web attack detection.
[0062] In one embodiment of the present invention, in the case where there is an original feature matching a preset current attack rule, the method further comprises:
[0063] Determine whether there is a target attack rule matching the attack payload among the preset multiple other attack rules; if so, determine that the attack type corresponding to the target attack rule and the attack type corresponding to the current attack rule are both the current attack type; otherwise, determine that the attack type corresponding to the current attack rule is the current attack type;
[0064] Update the current attack rules based on the type of attack payload, including:
[0065] Update attack rules based on the type of attack payload and the current attack type;
[0066] Among them, the attack type corresponding to the target attack rule is different from the attack types corresponding to other attack rules.
[0067] Considering that there may be multiple Web attacks in a Web request, in order to identify other types of Web attacks, other attack rules can be used to detect Web requests based on the current attack rules. The embodiment of the present invention can more comprehensively identify Web attacks and improve the security of the source server.
[0068] In one embodiment of the present invention, determining whether there is a target attack rule matching the attack payload among a plurality of preset other attack rules includes:
[0069] Selecting an attack rule corresponding to the type of attack payload from among a plurality of other preset attack rules;
[0070] It is determined whether there is a target attack rule matching the attack payload among the attack rules corresponding to the type of the attack payload.
[0071] The preset attack rules may correspond to the types of attack loads, for example, attack rules 1, 2 and 3 correspond to type A, and attack rules 4 and 5 correspond to type B. When the type of attack load is determined, the target attack rule matching the attack load may be determined only from the attack rules corresponding to the type of attack load. Through the embodiments of the present invention, the number of attack rules matching the attack load may be reduced, the amount of calculation may be reduced, and the detection efficiency may be improved.
[0072] In one embodiment of the present invention, the method further comprises: encoding the attack payload;
[0073] Providing the current attack type and attack payload to external management parties, including:
[0074] The current attack type and the encoded attack payload are provided to the management party for storage.
[0075] Considering that the attack payload may contain some special characters and cannot be directly saved, the embodiment of the present invention encodes the attack payload and then provides it to the management party for saving. For example, the attack payload is base64 encoded. The management party can analyze the attack payload based on the current attack type to determine whether there are other attack types in the attack payload, and if so, update the current attack rule.
[0076] like Figure 2As shown, an embodiment of the present invention provides a Web attack detection method, including:
[0077] Step 201: Receive a web request sent by a user.
[0078] Step 202: extract request features of multiple dimensions from the Web request.
[0079] Step 203: Identify the encoding mode of each request feature based on encoding detection.
[0080] Step 204: Decode the request feature based on the encoding method of the request feature to obtain the original feature corresponding to the request feature.
[0081] Step 205: Determine whether there is an original feature that matches the preset current attack rule. If not, execute step 206; otherwise, execute step 207.
[0082] Step 206: Forward the Web request to the origin server.
[0083] Step 207: Determine the location of the content in the original feature that matches the current attack rule.
[0084] Step 208: Determine the extraction scope based on the target matching pattern and the location of the content.
[0085] Step 209: Extract the attack payload from the original features based on the extraction range, and determine the type of the attack payload.
[0086] Step 210: Update the current attack rules based on the type of attack payload.
[0087] The embodiment of the present invention identifies possible attacks in requests through different dimensions, combines coding detection to identify the bypass behavior of forged attacks in requests, and further understands the possible vulnerabilities in the current request by analyzing the extracted attack payload, updates the attack rules, and improves the protection capability.
[0088] like Figure 3 As shown, an embodiment of the present invention provides a Web attack detection device, including:
[0089] The receiving module 301 is configured to receive a web request sent by a user;
[0090] An extraction module 302 is configured to extract request features of multiple dimensions from a Web request;
[0091] The decoding module 303 is configured to identify the encoding mode of each request feature based on the encoding detection; decode the request feature based on the encoding mode of the request feature to obtain the original feature corresponding to the request feature;
[0092] The determination module 304 is configured to determine whether there is an original feature that matches the preset current attack rule. If not, the Web request is forwarded to the source server. Otherwise, the attack payload is extracted from the original feature that matches the current attack rule, and the current attack rule is updated based on the attack payload.
[0093] In one embodiment of the present invention, the attack rules include: multiple target dimensions, target matching patterns;
[0094] The determination module 304 is configured to combine the original features of multiple target dimensions; determine whether the combined original features match the target matching mode; the target matching mode includes: any one of equal matching, including matching and regular matching.
[0095] In one embodiment of the present invention, the attack rule includes: a target dimension and a target matching pattern;
[0096] Determine the location of the content matching the current attack rule in the original feature; determine the extraction range based on the target matching pattern and the location of the content; and extract the attack payload from the original feature based on the extraction range.
[0097] In one embodiment of the present invention, the determination module 304 is configured to determine the type of attack payload; the type of attack payload includes: any one or more of malicious code, session token and sensitive data; and update the current attack rules based on the type of attack payload.
[0098] In one embodiment of the present invention, the determination module 304 is configured to determine whether there is a target attack rule matching the attack payload among the preset multiple other attack rules, and if so, determine that the attack type corresponding to the target attack rule and the attack type corresponding to the current attack rule are both the current attack type; otherwise, determine that the attack type corresponding to the current attack rule is the current attack type;
[0099] The determination module 304 is configured to update the attack rule based on the type of attack load and the current attack type; wherein the attack type corresponding to the target attack rule is different from the attack types corresponding to other attack rules.
[0100] In one embodiment of the present invention, the determination module 304 is configured to select an attack rule corresponding to the type of attack payload from a plurality of other preset attack rules; and determine whether there is a target attack rule matching the attack payload among the attack rules corresponding to the type of attack payload.
[0101] In one embodiment of the present invention, the determination module 304 is configured to encode the attack payload; and provide the current attack type and the encoded attack payload to the management party for storage.
[0102] An embodiment of the present invention provides a computer-readable medium, on which computer instructions are stored. When the computer instructions are executed by a processor, the processor executes the method provided in the first aspect.
[0103] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can be enabled to read and execute the program code stored in the storage medium.
[0104] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0105] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.
[0106] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0107] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0108] It is understandable that the explanation, specific implementation methods, beneficial effects, examples, etc. of the relevant contents in the computer-readable medium provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.
[0109] An embodiment of the present specification provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method in any embodiment of the specification is implemented.
[0110] It is understandable that the explanation, specific implementation, beneficial effects, examples, etc. of the relevant contents in the computing device provided by the embodiment of the present invention can be found in the corresponding parts of the method and will not be repeated here.
[0111] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0112] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, widgets, or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0113] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. A Web attack detection method, It is characterized in that include: Receive web requests sent by users; Extracting request features of multiple dimensions from the Web request; Identify the encoding mode of each of the request features based on the encoding detection; Decoding the request feature based on the encoding method of the request feature to obtain an original feature corresponding to the request feature; Determine whether there is an original feature that matches the preset current attack rule. If not, forward the Web request to the source server. Otherwise, extract the attack payload from the original feature that matches the current attack rule, and update the current attack rule based on the attack payload.
2. The method according to claim 1, It is characterized in that The attack rules include: multiple target dimensions and target matching patterns; Determine whether there are original features that match the preset current attack rules, including: Combining the original features of the multiple target dimensions; Determining whether the combined original features match the target matching pattern; The target matching mode includes: any one of equal matching, including matching and regular matching.
3. The method according to claim 1, It is characterized in that The attack rules include: target dimension and target matching mode; Extracting attack payload from original features matching the current attack rule, including: Determine the location of the content in the original feature that matches the current attack rule; Determining an extraction range based on the target matching pattern and the location of the content; An attack payload is extracted from the original feature based on the extraction range.
4. The method according to claim 1, It is characterized in that Updating the current attack rule based on the attack load includes: Determine the type of the attack payload; the type of the attack payload includes: any one or more of malicious code, session token and sensitive data; The current attack rule is updated based on the type of the attack payload.
5. The method according to claim 4, It is characterized in that In the case that there is an original feature matching the preset current attack rule, the method further includes: Determine whether there is a target attack rule matching the attack payload among the preset multiple other attack rules, and if so, determine that the attack type corresponding to the target attack rule and the attack type corresponding to the current attack rule are both the current attack type; otherwise, determine that the attack type corresponding to the current attack rule is the current attack type; Updating the current attack rule based on the type of the attack payload includes: updating the attack rule based on the type of the attack payload and the current attack type; The attack type corresponding to the target attack rule is different from the attack type corresponding to the other attack rules.
6. The method according to claim 5, It is characterized in that Determining whether there is a target attack rule matching the attack payload among a plurality of other preset attack rules includes: Selecting an attack rule corresponding to the type of the attack payload from a plurality of other preset attack rules; It is determined whether there is a target attack rule matching the attack payload among the attack rules corresponding to the type of the attack payload.
7. The method according to claim 1, It is characterized in that Further including: Encoding the attack payload; Providing the current attack type and the attack load to an external management party, including: The current attack type and the encoded attack payload are provided to the management party for storage.
8. A Web attack detection device, It is characterized in that include: A receiving module, configured to receive a Web request sent by a user; An extraction module, configured to extract request features of multiple dimensions from the Web request; A decoding module, configured to identify the encoding mode of each of the request features based on the encoding detection; decode the request features based on the encoding mode of the request features to obtain the original features corresponding to the request features; The determination module is configured to determine whether there is an original feature that matches a preset current attack rule. If not, the Web request is forwarded to the source server; otherwise, the attack load is extracted from the original feature that matches the current attack rule, and the current attack rule is updated based on the attack load.
9. An electronic device, It is characterized in that include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Attack recognition method and device and server
CN111628990A
Transformer-based malicious effective load detection method and system for application layer, equipment and medium
CN113343235A
Attack detection method and device based on flow feature matching, equipment and medium
CN117411708A
Detection method and device for network attack
CN1996892A
Methods and devices for automatically detecting attack signatures and generating attack signature identifications
US20190141061A1
Cited By
Attack detection method and device for HTTP request
CN121356816A
