A website logic vulnerability detection method and system based on finite state machine
By constructing feature attribute graphs and generating test cases based on finite state machine methods, the problem of difficulty in detecting Web logic vulnerabilities in the existing technology is solved, the accurate location and type judgment of Web logic vulnerabilities are achieved, and detection efficiency and standardization are improved. Recognition ability.
Patent Information
- Application Number
- CN202210409638.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-19
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-04-19
AI Technical Summary
Existing technologies are difficult to efficiently detect and locate Web logic vulnerabilities, causing logic vulnerabilities to cause interference in the safe operation of the business. They also rely on manual testing and experienced penetration testing engineers, making it difficult to identify and detect them in batches and standardization.
Using a method based on finite state machines, by constructing feature attribute graphs and generating test cases, reading database logs and network request sequences, matching the correspondence between data behavior and network requests, identifying key nodes and security-independent nodes, and establishing a finite state machine Model, generate new test cases to detect web logic vulnerabilities.
It achieves accurate location and type judgment of Web logic vulnerabilities, improves detection efficiency, and can identify logic vulnerabilities in batches and standardization to avoid interference with business logic.
Smart Images

Figure CN114844689B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security, and in particular to a website logic vulnerability detection method and system based on a finite state machine. Background Art
[0002] With the continuous development of Web security technology, traditional injection security issues have been widely and deeply studied. At present, both academia and industry have relatively mature solutions for this type of security defects. With the continuous increase in the technical cost of traditional vulnerability exploitation process, more and more attackers are turning their attention to the attack and exploitation of Web logic vulnerabilities. Web business logic vulnerabilities are mainly caused by the fact that program developers do not strictly verify user input when writing Web programs, or completely rely on user invisibility for certain security verification behaviors, which can lead to Web logic vulnerabilities. In actual scenarios, we often divide Web logic vulnerabilities into key process skipping, unauthorized access, unauthorized vulnerabilities, and unchecked parameters. Unlike traditional Web security vulnerabilities, logical vulnerabilities do not pose a threat to the system itself, but will greatly interfere with the safe operation of the business. The impacts that this attack can cause include but are not limited to: user privacy leakage due to unauthorized access, arbitrary password modification due to lax verification, e-commerce payment vulnerabilities due to lax verification, etc.
[0003] However, since logical vulnerabilities are difficult to detect and rely on manual testing, how to efficiently detect logical vulnerabilities has become a major problem in Web security. The mainstream scanning tools currently used in the industry for Web vulnerabilities, including AWVS, Nessus, OWASP Zed, Polar Bear Scanner, etc., do not support automated and efficient detection of Web logical vulnerabilities. Take the open source unauthorized vulnerability detection tool of the Zhongtong Security Team as an example. The tool processes the captured HTTP data packets, replaces (or sets to zero) the identity token in the data packet, and replays the data packet to identify the existence of unauthorized vulnerabilities. Due to the limitations of the technology itself, this type of tool cannot locate and identify logical vulnerabilities other than unauthorized vulnerabilities, and has great limitations in actual application.
[0004] At present, the location and detection of Web logic vulnerabilities require experienced penetration test engineers to conduct tedious penetration tests and code audits before they can be discovered. In addition, due to the gap in engineers' professional qualities and technical conditions, it is difficult to identify and detect logic vulnerabilities in batches and in a standardized manner. Therefore, there is an urgent need for a website logic vulnerability detection tool to locate potential logic vulnerabilities in the program and avoid interference with normal business logic. Summary of the invention
[0005] In order to achieve the above objectives, the present invention provides a website logic vulnerability detection method and system based on finite state machine. The method constructs a feature attribute graph based on finite state machine theory, constructs a user behavior model at the application logic level, and then generates test cases to detect Web logic vulnerabilities.
[0006] The present invention adopts the following technical solution:
[0007] A website logic vulnerability detection method based on a finite state machine comprises the following steps:
[0008] Step 1: Read the database log and network request sequence, match the corresponding relationship between data behavior and network request, and obtain the data operation information corresponding to each network request;
[0009] Step 2: Based on the data operation information, obtain the security attributes corresponding to each network request and determine the key nodes and security-irrelevant nodes;
[0010] Step 3: Establish a finite state machine to model the business logic of the network and obtain a feature attribute graph model to represent the logical behavior pattern of user operations;
[0011] Step 4: Parameters are mutated based on the original network request to generate new test cases. The execution effect of the new test cases is evaluated, and different types of logical vulnerabilities are determined based on different mutation objects.
[0012] As a preferred embodiment of the present invention, the step 1 comprises:
[0013] (1-1) Obtain the HTTP data packets and corresponding timestamps generated by each user's visit to the website, and read the database log file on the server;
[0014] (1-2) Parse the database log file, obtain the timestamp and the original SQL statement in the log file, and extract the table name and column name information involved in the original SQL statement. This can be implemented based on Python's sql_metadata module.
[0015] (1-3) Parse HTTP data packets, obtain the browser URL address after each data packet is generated (the URL address can be obtained from the browser tab), and record the HTTP data packets generated during the URL address change and the corresponding timestamp;
[0016] (1-4) Match the SQL statement timestamp with the HTTP data packet timestamp to obtain the data operation information generated by all HTTP data packets during each URL jump event.
[0017] As a preferred embodiment of the present invention, the step 2 is specifically as follows:
[0018] Determine the data operation information corresponding to each network request. If the data operation does not include the addition, deletion, and modification of data (i.e., UPDATE, DELETE, and INSERT), and does not include the query operation of the key table name and field name related to security identified by the user (i.e., SELECT), then the network request is considered to be irrelevant to security, and the URL address corresponding to the network request is defined as a security-irrelevant node; otherwise, the URL address corresponding to the network request is defined as a critical node.
[0019] As a preferred embodiment of the present invention, the key nodes include query nodes, modification nodes, deletion nodes and addition nodes; the query node is the URL address corresponding to the data query operation network request containing the key table name and field name related to security containing the user identifier, the modification node is the URL address corresponding to the data modification operation network request, the deletion node is the URL address corresponding to the data deletion operation network request, and the addition node is the URL address corresponding to the data addition operation network request.
[0020] In step 3, the characteristic attribute graph is constructed using the finite state machine theory, which can specifically describe the various operations and logical conversion processes of users starting from visiting the website, effectively express the website logic conversion information, and thus quickly locate the logical vulnerability node. As a preferred embodiment of the present invention, the step 3 includes:
[0021] (3-1) The query node corresponding to the query operation of the key table name and field name related to security containing the user identifier is used as the initial node of the finite state machine to construct the attribute graph;
[0022] (3-2) Every time a user operation involves URL address conversion, a new node is created on the attribute graph. The name of the new node is the corresponding URL address, and the data operation information (HTTP status code, request result, etc.) corresponding to all network requests under the new URL address is used as the new node attribute, and the network request that triggers the URL jump is used as the edge connecting two adjacent nodes;
[0023] (3-3) Repeat step (3-2) until the newly created node is a modified node, a deleted node, or an added node, and the next node of the node is used as the termination node. If no network request corresponding to the modified node, deleted node, or added node is found until the end of the network request sequence, the initial node of the attribute graph is used as an independent query node.
[0024] In step 3, the node is defined as the URL address of the user's browser, and the state transition is defined as the browser URL address jump. For example, when a user accesses address A, the user's browser address bar displays address A, which means that the user is currently in node A, and no matter what operation the user performs in the current node (mouse click, input, adjust page size, etc.), it will not cause a node jump. When the user clicks each button or clicks a certain URL address, so that the address displayed in the current user's browser address bar is converted to B, it is considered that the user has a state transition from the previous node A to the current node B.
[0025] As a preferred embodiment of the present invention, the step 4 comprises:
[0026] (4-1) Identify the parameter types in the network requests that constitute the edges of the feature attribute graph model, which are divided into int type, String type, and cookies type;
[0027] (4-2) If the parameter of the original network request is of int type, algebraic operation, zeroing operation and negation operation are performed on the original network request to generate a new test case;
[0028] If the parameter of the original network request is of String type, the closest string parameter is selected from the adjacent network requests corresponding to the original network request to be replaced, and a new test case is generated;
[0029] If the parameters of the original network request are of the cookies type, the cookies value of the original network request is set to zero to generate a new test case;
[0030] (4-3) Execute the newly generated test case to test whether the newly generated test case can reproduce the trajectory in the feature attribute graph model in step 3. If so, there is a logic vulnerability in the website. The type of logic vulnerability is determined according to the type of the new test case: for int type or String type test cases, if they can be reproduced, it is considered that there is a "parameter unchecked" type of logic vulnerability; for cookies type test cases, if they can be reproduced, it is considered that there is an "overstepping authority" type of logic vulnerability;
[0031] If not, there is no logical loophole in the website.
[0032] The present invention also proposes a website logic vulnerability detection system based on a finite state machine, which is used to implement the above-mentioned website logic vulnerability detection method. The website logic vulnerability detection system includes:
[0033] The user operation tracking module is used to read the database log and network request sequence, match the corresponding relationship between data behavior and network request, and obtain the data operation information corresponding to each network request.
[0034] The property graph modeling module is used to obtain the security attributes corresponding to each network request based on data operation information, determine the key nodes and security-irrelevant nodes; and to establish a feature property graph model based on a finite state machine to represent the logical behavior pattern of user operations; the modeling information required by the property graph modeling module is provided by the user operation tracking module.
[0035] The test case generation and execution module is used to generate new test cases at three levels: int type, String type, and cookies type according to the original network request provided by the user operation tracking module and the characteristic attribute graph model provided by the attribute graph modeling module, to evaluate and determine the existence and type of logical vulnerabilities. For example, Python's request-html module can be used to accurately replay test cases based on a headless browser to achieve detection.
[0036] As a preferred embodiment of the present invention, the user operation tracking module includes:
[0037] The user operation collector is deployed on the client browser to capture the user's network request sequence and monitor the jump of the browser address bar. The network request sequence during the address jump is defined as a user operation;
[0038] The user data tracker is deployed on the server side to read the server database log and parse the SQL statements involved during each address jump, matching each user operation with the database behavior it triggers.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] The present invention collects user behaviors and data information triggered by user behaviors to model the business logic level of Web applications. The network layer and data layer information are considered simultaneously during modeling, and the real logical behavior of website users can be accurately modeled. The test cases generated by the three dimensions can accurately determine whether a logic vulnerability exists and infer the specific type of the logic vulnerability. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of a website logic vulnerability detection method based on a finite state machine proposed by the present invention;
[0042] Figure 2 Provide a flow chart for user operation tracking module;
[0043] Figure 3 Flowchart for security sensitive identification;
[0044] Figure 4 Modeling module flow chart for property graph;
[0045] Figure 5 Flowchart for generating and verifying test cases. DETAILED DESCRIPTION
[0046] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be pointed out that the examples described below are intended to further illustrate the technical process and details of the present invention without having any limiting effect thereon.
[0047] The present invention realizes website logic vulnerability detection through a user operation tracking module, an attribute graph modeling module, and a test case generation and execution module. Figure 1 As shown in the figure, the main workflow is as follows: When a user accesses a Web application, the user operation tracking module obtains the HTTP request information and URL address generated by the user, and reads the server's database log file to obtain log information. Based on the information obtained by the user operation tracking module, the attribute graph modeling module models the business logic of the Web application and obtains a feature attribute graph model to represent the logical behavior pattern of the user operation. Based on the original HTTP request information, the parameters are mutated to generate new test cases, and the execution effect of the test cases is evaluated. Different types of logical vulnerabilities are determined according to different mutation objects.
[0048] In a specific implementation of the present invention, consider the following example: a news browsing and discussion web program provides a home page A (index.php), a news browsing page B (news.php) and a user personal information page C (user.php). In the user personal information page C, a personal password modification function is provided, and the user needs to first enter the correct original password to pass the verification, and then enter the new password to complete the password modification.
[0049] For the above example, perform the following operations:
[0050] (1) The user operation tracking module tracks the user's operation sequence at the network level and data level to provide sufficient information basis for modeling. The process is as follows: Figure 2As shown. The user accesses the Web application in the browser according to the above example process, and the user operation tracking module extracts the HTTP data packets generated in each access and their corresponding timestamps. The HTTP data packets generated in this process include the first data packet for accessing the homepage, the second data packet for jumping from the homepage to the news page, the third data packet for jumping from the news page to the user's personal homepage, the fourth data packet for the user to enter the old password and send to the server for verification, and the fifth data packet for the user to enter the new password and send to the server for password modification.
[0051] The user operation tracking module processes these HTTP packets to extract the information required for modeling. The process is as follows:
[0052] (1-1) Obtain the browser URL address after each data packet is generated.
[0053] (1-2) Parse and obtain the timestamp generated by each data packet.
[0054] (1-3) Read the database log file on the server, extract the SQL statements recorded in the log file and obtain the timestamp.
[0055] (1-4) Match the SQL statement timestamp with the HTTP data packet timestamp to obtain the data operation information generated by all HTTP data packets during each browser URL address jump.
[0056] (2) Using the data operation information obtained in the previous step, extract node information and identify nodes related to security, such as Figure 3 As shown, the process includes:
[0057] (2-1) Extract nodes. Take each browser URL address as a node, and all server-side data operations caused by all HTTP requests occurring on the node as the attributes of the node.
[0058] (2-2) Label node attributes and identify the security sensitivity of nodes.
[0059] According to the data operation information corresponding to the HTTP data packet, determine whether the node involves the addition, deletion, and modification of data, and whether it contains query operations on key table names and field names related to security identified by the user. If not, mark the node attribute as a security-independent node; if so, mark the node attribute as a security-sensitive node.
[0060] Continue to classify security-sensitive nodes. If the data operation information involved in the node is a query operation on a database field, it is considered a security-sensitive query node. If the node involves a modification operation on a database field, it is considered a security-sensitive modification node. In this example, the user's personal homepage is a security-sensitive node because it contains both query and modification operations on the password field in the database.
[0061] (3) Construct a feature attribute graph model based on finite state machine theory, such as Figure 4 As shown, the process is as follows:
[0062] (3-1) Identify the modeling starting point. The security-sensitive query node is used as the model initial node q0. In this example, the browser URL address corresponding to the page where the user enters the original password is the initial node.
[0063] (3-2) Add new model nodes. Starting from the initial node q0, mark the new node q that the user enters each time x , and mark the node name and attributes on the node; for example, the request script file address, GET request parameters, POST request parameters, HTTP-Referer, and Cookies can be used to represent the input activation variable of a logical conversion, and the destination script address can be combined with the GET parameter name as the node name, and the HTTP status code, database operation identifier, and HTTP response body length can be used as additional attributes to express the unique request status of a Web page.
[0064] Each model node is connected with the HTTP request that causes the node to jump as an edge. In this example, the browser URL address corresponding to the new password input interface entered after the original password is verified is the first newly added node.
[0065] (3-3) Identify the end node. When the model is constructed to the security-sensitive modification node q F , the modeling enters the end stage, and the next node of this node is used as the end node. In this example, the browser URL address corresponding to the page showing the successful password change is the end node.
[0066] (4) Generate and reproduce test cases based on model information to determine the type and existence of logical vulnerabilities, such as Figure 5 As shown, the process includes:
[0067] (4-1) Generate each round of test cases and make only one mutation on one HTTP request. The mutation types include int type mutation, String type mutation and cookies type mutation.
[0068] For each int type mutation, the simple algebraic operation is to add 1 and subtract 1 respectively; the instruction operation is to set the original value to 0; and the inversion operation is to multiply the original value by -1.
[0069] For each String type mutation, other String type parameters are searched in the adjacent HTTP request. For example, in this example, the original password entered by the user is "abcdefg", and the new password entered by the user is "aaaaaaa". Since these two parameters are of the same type and have the closest (same) length, the original parameter "abcdefg" is mutated into the new parameter "aaaaaaa".
[0070] For each cookie type mutation, replace a cookie value from the original request with NULL.
[0071] (4-2) For the test cases generated after mutation, reproduce the user request sequence through a headless browser, that is, test whether the newly generated test cases can reproduce the same feature attribute graph model as step (3). For test cases mutated by int type or String type, if they can be reproduced correctly, it is considered that there is a logic vulnerability of the "parameter not verified" type; for test cases generated by cookies mutation, if they can be reproduced correctly, it is considered that there is a logic vulnerability of the "overstepping authority" type.
[0072] In this example, after several rounds of test case generation and reproduction, the String type original password field in the HTTP request of the original password verification phase was finally mutated, and the correct original password parameter in the original model was changed to another String type parameter. Since this example lacks the correctness verification operation for the original password, the test case generated after the mutation can be executed correctly and the password modification operation can be completed smoothly. It can be determined that the program has a logic vulnerability of the "parameter not verified" type in the original password verification phase.
[0073] The above examples are only specific embodiments of the present invention. Obviously, the present invention is not limited to the above examples, and many variations are possible. All variations that can be directly derived or associated with the contents disclosed by a person skilled in the art should be considered as the protection scope of the present invention.
Claims
1. A website logic vulnerability detection method based on a finite state machine, characterized in that: The following steps are involved: Step 1: Read the database log and network request sequence, match the corresponding relationship between data behavior and network request, and obtain the data operation information corresponding to each network request; Step 2: Based on the data operation information, obtain the security attributes corresponding to each network request and determine the key nodes and security-irrelevant nodes; The step 2 is specifically as follows: Determine the data operation information corresponding to each network request. If the data operation does not include the addition, deletion, or modification of data, and does not include the query operation of the key table name and field name related to security identified by the user, then the network request is considered to be irrelevant to security, and the URL address corresponding to the network request is defined as a security-irrelevant node. Otherwise, the URL address corresponding to the network request is defined as a key node; the key nodes include query nodes, modify nodes, delete nodes and add nodes; the query node is the URL address corresponding to the network request for data query operation containing the key table name and field name related to security and the user identifier, the modify node is the URL address corresponding to the network request for data modification operation, the delete node is the URL address corresponding to the network request for data deletion operation, and the add node is the URL address corresponding to the network request for data addition operation; Step 3: Establish a finite state machine to model the business logic of the network and obtain a feature attribute graph model to represent the logical behavior pattern of user operations; The step 3 comprises: (3-1) Using the query node corresponding to the query operation of the key table name and field name related to security containing the user identifier as the initial node of the finite state machine to construct the attribute graph; (3-2) Every time a user operation involves URL address conversion, a new node is created on the attribute graph. The name of the new node is the corresponding URL address, and the data operation information corresponding to all network requests under the new URL address is used as the new node attribute. The network request that triggers the URL jump is used as the edge connecting two adjacent nodes; (3-3) Repeat step (3-2) until the newly created node is a modified node, a deleted node, or an added node, then the next node of the node is used as the termination node; Step 4: Parameters are mutated based on the original network request to generate new test cases. The execution effect of the new test cases is evaluated, and different types of logical vulnerabilities are determined based on different mutation objects.
2. The website logic vulnerability detection method based on finite state machine according to claim 1 is characterized in that: The step 1 comprises: (1-1) Obtain the HTTP data packets and corresponding timestamps generated by each user's visit to the website, and read the database log files on the server side; (1-2) Parse the database log file, obtain the timestamp and original SQL statement in the log file, and extract the table name and column name information involved in the original SQL statement; (1-3) Parse HTTP data packets, obtain the browser URL address after each data packet is generated, and record the HTTP data packets generated during the URL address change and the corresponding timestamp; (1-4) Match the SQL statement timestamp with the HTTP data packet timestamp to obtain the data operation information generated by all HTTP data packets during each URL jump event.
3. The website logic vulnerability detection method based on finite state machine according to claim 1 is characterized in that: In the step (3-3), if no corresponding network request for modifying a node, deleting a node, or adding a node is found until the end of the network request sequence, the initial node of the property graph is used as an independent query node.
4. The website logic vulnerability detection method based on finite state machine according to claim 1 is characterized in that: The step 4 comprises: (4-1) Identify the parameter types in the network requests that constitute the edges of the feature attribute graph model, which are divided into int type, string type, and cookies type; (4-2) If the parameter of the original network request is of int type, algebraic operation, zeroing operation and negation operation are performed on the original network request to generate a new test case; If the parameter of the original network request is of String type, the closest string parameter is selected from the adjacent network requests corresponding to the original network request to be replaced, and a new test case is generated; If the parameters of the original network request are of the cookies type, the cookies value of the original network request is set to zero to generate a new test case; (4-3) Execute the newly generated test case to test whether the newly generated test case can reproduce the trajectory in the feature attribute graph model in step 3. If it can, there is a logic vulnerability on the website, and the type of logic vulnerability is determined based on the type of the new test case; if not, there is no logic vulnerability on the website.
5. The website logic vulnerability detection method based on finite state machine according to claim 4 is characterized in that: For int or String type test cases, if they can be reproduced, it is considered that there is a "parameter not verified" type logic vulnerability; for cookies type test cases, if they can be reproduced, it is considered that there is an "overstepping authority" type logic vulnerability.
6. A website logic vulnerability detection system based on a finite state machine, used to implement the website logic vulnerability detection method according to claim 1, characterized in that: The website logic vulnerability detection system comprises: User operation tracking module, which is used to read database logs and network request sequences, match the corresponding relationship between data behavior and network requests, and obtain data operation information corresponding to each network request; The attribute graph modeling module is used to obtain the security attributes corresponding to each network request based on data operation information, determine key nodes and security-irrelevant nodes; and to establish a feature attribute graph model based on a finite state machine to represent the logical behavior pattern of user operations; The test case generation and execution module is used to generate new test cases at three levels: int type, String type, and cookies type based on the original network request provided by the user operation tracking module and the characteristic attribute graph model provided by the attribute graph modeling module, to evaluate and determine the existence and type of logical vulnerabilities.
7. The website logic vulnerability detection system based on finite state machine according to claim 6 is characterized in that: The user operation tracking module includes: The user operation collector is deployed on the client browser to capture the user's network request sequence and monitor the jump of the browser address bar. The network request sequence during the address jump is defined as a user operation; The user data tracker is deployed on the server side to read the server database log and parse the SQL statements involved during each address jump, matching each user operation with the database behavior it triggers.
Citation Information
Patent Citations
Method and system for detecting SQL injection vulnerabilities of power information system
CN111064735A
Vulnerability detection method and system for application rules of Internet of Things
CN113221120A
