XSS attack detection method and device

By putting the reply message into the JS sandbox and comparing it with the XSS attack vector, the false alarm and missed response problems of XSS attack detection in the existing technology are solved, and the accurate prediction of the XSS attack results is achieved, reducing maintenance cost.

CN114499968BActive Publication Date: 2024-11-26QI AN XIN TECHNOLOGY GROUP INC +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111615585.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-27
Publication Date
2024-11-26
Estimated Expiration
2041-12-27

AI Technical Summary

Technical Problem

The existing technology has false alarms and missed reports when detecting XSS attacks, and the traditional intrusion detection system alerts all attacks, resulting in high maintenance costs and inability to effectively distinguish between success and failure of the attack.

Method used

By detecting the received user request, determine whether it is an XSS attack, extract the XSS attack vector, and put the reply message into the JS sandbox to run, and compare the listening event with the XSS attack vector. If it is consistent, confirm that the attack is successful.

Benefits of technology

It realizes accurate prediction of XSS attack results, reduces false alarms and missed reports, reduces maintenance costs, and improves detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114499968B_ABST
    Figure CN114499968B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides an XSS attack detection method and device. The method includes: detecting a received user request to determine whether it is an XSS attack; if it is an XSS attack, extracting an XSS attack vector from the user request; obtaining a response message corresponding to the user request, putting the response message into a JS sandbox to run and execute a monitoring event, and comparing the monitored event of the corresponding response message with the XSS attack vector. If the comparison result is consistent, the XSS attack is successful. In view of the characteristics of the XSS attack, the XSS attack vector and the running result of the response message in the JS sandbox are extracted, the extracted attack vector is compared with the running result of the JS sandbox, and the attack result is analyzed and judged, thereby reducing the maintenance cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security, and in particular to an XSS attack detection method and device. Background Art

[0002] In order to launch malicious attacks on users, attackers may insert some malicious script codes into web pages. When users browse the pages, the script codes maliciously inserted by attackers may be executed, thus completing XSS attacks.

[0003] At present, XSS attacks can be detected using methods such as regular rule detection, machine learning algorithm prediction and judgment detection, or semantic analysis-based detection. However, these methods do not enter the link of the browser actually executing the JS script, and are all based on text parsing detection. Therefore, there are certain false positives and missed positives. In the prior art, XSS attacks can also be detected by rule matching of the response page: by injecting a specific attack payload (payload, the part of the virus code that implements some harmful or malicious functions is called "effective load"), and then checking whether the JS script of the attack payload in the corresponding response page is encoded by the website through a regular expression. If it is not encoded, the attack is considered successful. However, this method is prone to false positives, because the fact that the payload is not encoded does not mean that the browser will execute the payload. It is possible that the payload is displayed as text, thus causing false positives.

[0004] Moreover, since web attacks involve a large number of scanning attacks in the network, most of which are scanners, a large number of attacks are ineffective. Traditional intrusion detection systems (IDS) will alert all attacks, but protection personnel only need to care about successful attacks, so alerting all attacks will cause huge costs to maintenance personnel. Summary of the invention

[0005] In view of the problems in the prior art, an embodiment of the present invention provides a method and device for detecting XSS attacks.

[0006] Specifically, the embodiment of the present invention provides the following technical solutions:

[0007] In a first aspect, an embodiment of the present invention provides a SQL injection detection method, comprising: detecting a received user request to determine whether it is an XSS attack; if it is an XSS attack, extracting an XSS attack vector from the user request; obtaining a response message corresponding to the user request, placing the response message into a JS sandbox to run and execute monitoring events, and comparing the monitored event corresponding to the response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful.

[0008] Furthermore, the detecting of received user requests includes: detecting received user requests through XSS attack detection rules; and / or detecting received user requests through a semantic analysis method; and / or detecting received user requests through a sandbox detection method.

[0009] Furthermore, the user request includes an http request.

[0010] Furthermore, extracting the XSS attack vector from the user request includes: determining whether the user request includes a user parameter; if the user parameter is included, parsing the user parameter from the user request, and using a parameter value corresponding to the user parameter as the XSS attack vector.

[0011] Further, comparing the monitored event corresponding to the response message with the XSS attack vector includes: comparing a function of the monitored event corresponding to the response message with a parameter value corresponding to the user parameter.

[0012] Furthermore, the obtaining of a response message corresponding to the user request, placing the response message into a JS sandbox to run and execute monitoring events, includes: obtaining a response message corresponding to the user request, parsing a response page corresponding to the user request from the response message, placing the response page into a JS sandbox to run and execute monitoring events.

[0013] In the second aspect, an embodiment of the present invention also provides an XSS attack detection device, including: a first processing module, used to detect a received user request to determine whether it is an XSS attack; a second processing module, used to extract an XSS attack vector from the user request if it is an XSS attack; a third processing module, used to obtain a response message corresponding to the user request, put the response message into a JS sandbox to run and execute monitoring events, and compare the monitored events corresponding to the response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful.

[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the XSS attack detection method described in the first aspect are implemented.

[0015] In a fourth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the XSS attack detection method described in the first aspect.

[0016] In a fifth aspect, an embodiment of the present invention further provides a computer program product having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the steps of the XSS attack detection method described in the first aspect.

[0017] The XSS attack detection method and device provided by the embodiment of the present invention determines whether it is an XSS attack by detecting the received user request; if it is an XSS attack, the XSS attack vector is extracted from the user request; the response message corresponding to the user request is obtained, the response message is put into the JS sandbox to run and execute the monitoring event, and the event of the corresponding response message monitored is compared with the XSS attack vector. If the comparison result is consistent, the XSS attack is successful. Among them, by detecting the received user request, it is determined whether it is an XSS attack, and the response message to be monitored is determined; by putting the response message into the JS sandbox to run and execute the monitoring event, the event of the corresponding response message monitored is compared with the XSS attack vector to determine whether the XSS attack is successful. The prediction of the attack result of the XSS attack is achieved, and the maintenance cost is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 This is a flow chart of an embodiment of an XSS attack detection method of the present invention;

[0020] Figure 2 Flowcharts of other embodiments of an XSS attack detection method of the present invention;

[0021] Figure 3 Flowcharts of some further embodiments of an XSS attack detection method of the present invention;

[0022] Figure 4A schematic diagram of a flow chart of an application scenario of an XSS attack detection method of the present invention;

[0023] Figure 5 This is a schematic diagram of the structure of an embodiment of a detection device of the present invention;

[0024] Figure 6 It is a schematic diagram of the structure of an electronic device entity embodiment of the present invention. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0026] Figure 1 This is a flow chart of an embodiment of an XSS attack detection method of the present invention. Figure 1 As shown, the method of the embodiment of the present invention includes:

[0027] S101, detect the received user request and determine whether it is an XSS attack.

[0028] XSS attacks usually refer to exploiting loopholes left when developing web pages, using clever methods to inject malicious instruction codes into web pages, causing users to load and execute web programs maliciously created by attackers. The language of these malicious web programs can be JavaScript, Java, VBScript, ActiveX, Flash or ordinary HTML.

[0029] XSS attacks can be used to steal user passwords, force users to visit specific websites, etc. XSS vulnerabilities, like SQL injections, take advantage of incomplete web page writing.

[0030] XSS attacks can be divided into:

[0031] (1) Reflective type: It passes through the backend, not the database, and is triggered by passing parameters into the URL;

[0032] (2) Storage type: through the backend, through the database;

[0033] (3) DOM: Without going through the backend, DOM-based XSS vulnerability is a vulnerability based on the Document Object Model (DOM). DOM-XSS is triggered by passing parameters in the URL.

[0034] As an example, a user request containing a reflected XSS attack:

[0035] GET / vulnertc / vulnerabilities / xss_r / ? name=%3CIFRAME+src%3Djavascript%3Aalert%28document.cookie%29%3E%3C%2FIFRAME%3E HTTP / 1.1

[0036] Host:2.2.2.8

[0037] …

[0038] Connection:keep-alive

[0039] S102: If it is an XSS attack, extract the XSS attack vector from the user request.

[0040] Still taking the above as an example, the XSS attack vector extracted from the user request can be:

[0041] "%3CIFRAME+src%3Djavascript%3Aalert%28document.cookie%29%3E%3C%2FIFRAME%3E"

[0042] In some embodiments, XSS attack vectors may be extracted according to pre-specified extraction rules, or may be extracted through deep learning methods or other methods or tools.

[0043] S103, obtaining a response message corresponding to the user request, putting the response message into the JS sandbox to run and execute monitoring events, and comparing the monitored events of the corresponding response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful.

[0044] Sandbox: A virtual system program that allows browsers or other programs to run in a sandbox environment, and the changes made during the operation can be deleted later. Sandbox creates an independent operating environment similar to a sandbox, and the programs running inside it cannot have a permanent impact on the hard disk. In network security, sandbox refers to a tool used to test the behavior of untrusted files or applications in an isolated environment.

[0045] Events, for example, can be used to create a dynamic page using JavaScript. Each element in the web page can generate certain events that trigger JavaScript functions. That is, an event can be considered a behavior that can be detected by JavaScript.

[0046] General event monitoring method:

[0047] (1) Binding HTML element attributes:

[0048] <input type="button"value="clickMe"onclick="check(this)">

[0049] (2) Binding DOM object attributes:

[0050] document.getElementById("xxx").onclick=test;

[0051] (3) Monitoring method in IE:

[0052] [object].attachEvent("event type", "processing function"); / / Add listener

[0053] In some embodiments, after the client submits a user request to the server, the server will send a response message to the client. In order to detect whether the user request containing XSS is successfully attacked, the response message can be put into the JS sandbox and the monitoring event can be executed, that is, the sandbox runs the response message and then monitors the event when the response message is running. The monitored event is compared with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful.

[0054] As an example, the events of the monitored response message operation are:

[0055] <iframe src=javascript:alert(document.cookie)>< / iframe>

[0056] In some embodiments, comparing the monitored event with the XSS attack vector may be performing a text comparison between the code statement of the monitored event and the parsed XSS attack vector.

[0057] In some embodiments, the monitored events are compared with the XSS attack vectors. Alternatively, after the response message is placed in a JS sandbox and the monitored events are executed, the monitored events and / or the order in which the events occur are parsed, and after the XSS attack vector is extracted from the user request, the events and / or the order in which the events occur in the XSS attack vector are parsed, and then the events parsed from the monitored events (the parsed events may be functions) and / or the order in which the events occur are compared with the events and / or the order in which the events are parsed from the XSS attack vector to determine whether the user request containing the XSS attack is successfully attacked.

[0058] Still taking the above as an example, the events parsed from the events of the monitored response message are alert events (i.e., alert function) and document.cookie events (i.e., document.cookie function). Still taking the above as an example, alert(document.cookie) indicates that the order of the alert event and the document.cookie event is: document.cookie event, alert event.

[0059] The XSS attack detection method provided by the embodiment of the present invention determines whether it is an XSS attack by detecting the received user request; if it is an XSS attack, the XSS attack vector is extracted from the user request; the response message corresponding to the user request is obtained, the response message is put into the JS sandbox to run and execute the monitoring event, and the event of the corresponding response message monitored is compared with the XSS attack vector. If the comparison result is consistent, the XSS attack is successful. Among them, by detecting the received user request, it is determined whether it is an XSS attack, and the response message to be monitored is determined; by putting the response message into the JS sandbox to run and execute the monitoring event, the event of the corresponding response message monitored is compared with the XSS attack vector to determine whether the XSS attack is successful. The prediction of the attack result of the XSS attack is achieved, and the maintenance cost is reduced.

[0060] Figure 2 Flowcharts of other embodiments of an XSS attack detection method of the present invention. Figure 2 As shown, the method of the embodiment of the present invention includes:

[0061] S201, detect the received user request and determine whether it is an XSS attack.

[0062] In some optional implementations, detecting received user requests includes: detecting received user requests through XSS attack detection rules; and / or detecting received user requests through semantic analysis methods; and / or detecting received user requests through sandbox detection methods.

[0063] In some embodiments, the XSS attack detection rules may be grammatical rules formulated based on existing XSS attacks, and the received user requests may be detected through the rules, that is, through text matching, the XSS attack detection rules are traversed to determine whether the user request contains XSS attack statements.

[0064] Semantic analysis is a logical stage in the compilation process. The task of semantic analysis is to review the context-related properties of the structurally correct source program and perform type review. Semantic analysis is to review whether the source program has semantic errors and collect type information for the code generation stage. For example, one of the tasks of semantic analysis is to perform type review to check whether each operator has an operand allowed by the language specification. When it does not meet the language specification, the compiler should report an error. For example, some compilers will report an error when a real number is used as an array subscript.

[0065] In some embodiments, semantic analysis of user requests may be performed using semantic analysis tools, language models, or analysis methods.

[0066] In some embodiments, the user request may be placed in a sandbox to simulate the process of the user submitting the request, and XSS attacks may be filtered by obtaining the monitored data packets.

[0067] The present invention does not limit how to detect XSS in user requests.

[0068] In some optional implementations, the user request includes an http request.

[0069] HTTP is the Hypertext Transfer Protocol, which defines the specification of text transmission between the client and the server. HTTP uses port 80 by default, which refers to the port of the server, while the port used by the client is dynamically allocated. When no port is specified for access, the client's browser will default to port 80. You can also specify the access port, for example: http: / / www.ip138.com:80.

[0070] The HTTP protocol defines eight methods to indicate different operation modes of the resource specified by the Request-URL.

[0071] HTTP request methods include:

[0072] (1)HTTP1.0 defines three request methods: GET, POST, and HEAD.

[0073] (2)HTTP1.1 adds five new request methods: OPTIONS, PUT, DELETE, TRACE, and CONNECT.

[0074] A user request can be any of the eight methods defined by the HTTP protocol. A user request can also be a request submitted through other protocols.

[0075] S202: If it is an XSS attack, parse the user parameters from the user request and use the parameter values ​​corresponding to the user parameters as the XSS attack vector.

[0076] Still Figure 1 Take the user request in as an example:

[0077] GET / vulnertc / vulnerabilities / xss_r / ? name=%3CIFRAME+src%3Djavascript%3Aalert%28document.cookie%29%3E%3C%2FIFRAME%3E HTTP / 1.1

[0078] Host:2.2.2.8

[0079] …

[0080] Connection:keep-alive

[0081] The part after "?" in the user request is the user parameter part: name = %3CIFRAME+src%3Djavascript%3Aalert%28document.cookie%29%3E%3C%2FIFRAME%3E, "name" indicates the keyword of the user parameter, and "%3CIFRAME+src%3Djavascript%3Aalert%28document.cookie%29%3E%3C%2FIFRAME%3E" indicates the parameter value of the user parameter. HTTP / 1.1 represents the protocol type and version.

[0082] That is, the parameter value corresponding to the user parameter is:

[0083] %3CIFRAME+src%3Djavascript%3Aalert%28document.cookie%29%3E%3C%2FIFRAME%3E

[0084] As an example, the user parameters may be parsed out by a preset rule, and the preset rule may be: intercepting data from "?" to "HTTP". The present invention does not limit how to parse the user parameters.

[0085] S203, obtain a response message corresponding to the user request, put the response message into the JS sandbox to run and execute monitoring events, compare the monitored events of the corresponding response message with the XSS attack vector, if the comparison results are consistent, the XSS attack is successful.

[0086] In some optional implementations, the monitored event corresponding to the response message is compared with the XSS attack vector, including: comparing the function of the monitored event corresponding to the response message with the function in the parameter value corresponding to the user parameter.

[0087] Still taking the above as an example, the events of the monitored response message running are:

[0088] <iframe src=javascript:alert(document.cookie)>< / iframe>

[0089] Among them, the function of the event of the response message is alert(document.cookie).

[0090] Still taking the above as an example, the parameter values ​​corresponding to the above user parameters are obtained after URL encoding conversion:

[0091] <IFRAME+src=javascript.Aalert(document.cookie)>

[0092] The function in the parameter value is Aalert(document.cookie).

[0093] Among them, if the function of the event in the response message is the same as the function in the parameter value, the XSS attack is successful.

[0094] The XSS attack detection method provided by the embodiment of the present invention is Figure 1 Compared with the embodiment, Figure 2 The provided XSS attack detection method highlights how to extract the XSS attack vector. By parsing the user parameters from the user request, the function in the parameter value corresponding to the user parameter is used as the XSS attack vector. The detection of whether the XSS attack is successful is realized.

[0095] Figure 3 Flowcharts of some further embodiments of an XSS attack detection method of the present invention. Figure 3 As shown, the method of the embodiment of the present invention includes:

[0096] S301, detect the received user request and determine whether it is an XSS attack.

[0097] In some embodiments, the specific implementation of step 301 and the technical effects thereof can be referred to in Figure 1 The corresponding step 101 in the embodiment will not be described in detail here.

[0098] S302: If it is an XSS attack, extract the XSS attack vector from the user request.

[0099] In some embodiments, the specific implementation of step 302 and the technical effects thereof can be referred to in Figure 1 The corresponding step 102 in the embodiment will not be described in detail here.

[0100] S303, obtain the response message corresponding to the user request, parse the response page corresponding to the user request from the response message, put the response page into the JS sandbox to run and execute the monitoring event, compare the monitored event of the corresponding response message with the XSS attack vector, if the comparison results are consistent, the XSS attack is successful.

[0101] As an example, the reply message could be:

[0102]

[0103] Among them, everything after "<!DOCTYPE html PUBLIC"- / / W3C / / DTD XHTML 1.0Strict / / EN""http: / / www.w3.org / TR / xhtml1 / DTD / xhtml1-strict.dtd">" belongs to the response page (html page). Put the response page into the JS sandbox and execute the monitoring event. Compare the monitored events of the corresponding response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful.

[0104] The XSS attack detection method provided by the embodiment of the present invention is Figure 1 and Figure 2 Compared with the embodiment, Figure 3 The provided XSS attack detection method highlights how to run in the JS sandbox through the response message. By obtaining the response message corresponding to the user request, the response page corresponding to the user request is parsed from the response message, and the response page is put into the JS sandbox to run and execute the monitoring event. The simulation operation of the response page in the sandbox is realized, and the success of the XSS attack is detected through the simulation operation.

[0105] like Figure 4 The flowchart of an application scenario of an XSS attack detection method shown in FIG. The input is an HTTP request message, and the output is a bool value (indicating whether the attack is successful).

[0106] The steps are:

[0107] (1) Detect HTTP requests through XSS attack detection rules to determine the parameter part of the XSS attack (i.e., payload, the part of the virus code that implements some harmful or malicious actions is called "payload");

[0108] (2) Parse the parameters in the HTTP request and extract the XSS attack vector;

[0109] (3) Monitor the HTTP response page and put it into the JS sandbox to execute the monitoring event;

[0110] (4) Compare the monitored event with the original attack payload. If the two are the same, the attack is successful.

[0111] Among them, the HTTP request is detected through the XSS attack detection rules to determine the parameter part of the XSS attack, mainly through the Deep Packet Inspection (DPI) engine, loading the XSS attack detection rules to detect the XSS attack.

[0112] Among them, parsing the parameters in the HTTP request and extracting the XSS attack vector is to parse the parameters submitted by the attacker and extract the attack vector matched by the attack rule from the parameters.

[0113] Among them, monitoring the HTTP response page and putting it into the JS sandbox to execute the monitoring event is to monitor and record the HTTP response page (usually an HTML page) according to the link of the XSS attack, and put the HTTP response page into the JS sandbox to run the JS script in the HTML page.

[0114] Among them, the monitored events are compared with the payload of the original attack. If the two are the same, the attack is successful. That is, the extracted XSS attack vector is compared with the corresponding event monitored by the JS sandbox. If the payload in the HTTP request is found to be consistent with the event monitored by the actual operation of the JS sandbox, the attack is successful.

[0115] Figure 5 FIG. 1 is a schematic diagram of the structure of an embodiment of an XSS attack detection device of the present invention. Figure 5 As shown, the device comprises:

[0116] The first processing module 501 is used to detect the received user request and determine whether it is an XSS attack;

[0117] The second processing module 502 is used to extract the XSS attack vector from the user request if it is an XSS attack;

[0118] The third processing module 503 is used to obtain a response message corresponding to the user request, put the response message into the JS sandbox to run and execute monitoring events, and compare the monitored events corresponding to the response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful.

[0119] Optionally, the first processing module 501 is further used for:

[0120] Check received user requests using XSS attack detection rules; and / or

[0121] Detect received user requests through semantic analysis methods; and / or

[0122] Received user requests are inspected through sandbox detection methods.

[0123] Optionally, the user request includes an http request.

[0124] Optionally, the second processing module 502 is further used to: parse out user parameters from the user request, and use a function in a parameter value corresponding to the user parameter as an XSS attack vector.

[0125] Optionally, the third processing module 503 is further configured to compare the monitored function of the event corresponding to the response message with the function in the parameter value corresponding to the user parameter.

[0126] Optionally, the third processing module 503 is further used to: obtain a response message corresponding to the user request, parse a response page corresponding to the user request from the response message, put the response page into a JS sandbox to run and execute monitoring events.

[0127] Here is an example:

[0128] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor (processor) 601, a communication interface (Communications Interface) 602, a memory (memory) 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 complete mutual communication through the communication bus 604. The processor 601 can call the logic instructions in the memory 603 to execute the following method: detect the received user request and determine whether it is an XSS attack; if it is an XSS attack, extract the XSS attack vector from the user request; obtain the response message corresponding to the user request, put the response message into the JS sandbox to run and execute the monitoring event, and compare the monitored event of the corresponding response message with the XSS attack vector. If the comparison result is consistent, the XSS attack is successful.

[0129] In addition, the logic instructions in the above-mentioned memory 603 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0130] On the other hand, an embodiment of the present invention further provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the XSS attack detection method provided by the above embodiments, for example, including: detecting a received user request to determine whether it is an XSS attack; if it is an XSS attack, extracting an XSS attack vector from the user request; obtaining a response message corresponding to the user request, putting the response message into a JS sandbox to run and execute monitoring events, and comparing the monitored events of the corresponding response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful.

[0131] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the XSS attack detection method provided by the above-mentioned embodiments, for example, including: detecting a received user request to determine whether it is an XSS attack; if it is an XSS attack, extracting an XSS attack vector from the user request; obtaining a response message corresponding to the user request, putting the response message into a JS sandbox to run and execute monitoring events, and comparing the monitored events of the corresponding response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful.

[0132] The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, i.e., they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without paying creative labor.

[0133] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

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

Claims

1. A XSS attack detection method, It is characterized in that The method comprises: Detect received user requests to determine whether they are XSS attacks; If it is an XSS attack, extract the XSS attack vector from the user request; Obtain a response message corresponding to the user request, put the response message into a JS sandbox to run and execute monitoring events, and compare the monitored events corresponding to the response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful; The comparing the monitored event corresponding to the response message with the XSS attack vector includes: performing a text comparison between the code statement of the monitored event and the parsed XSS attack vector, or parsing the monitored event and / or the order of event occurrence after putting the response message into a JS sandbox to run and execute the monitored event, parsing the event and / or the order of event occurrence in the XSS attack vector after extracting the XSS attack vector from the user request, and then comparing the event and / or the order of event occurrence parsed from the monitored event with the event and / or the order of event occurrence parsed from the XSS attack vector; The obtaining of a response message corresponding to the user request, placing the response message into a JS sandbox to run and execute a monitoring event, includes: obtaining a response message corresponding to the user request, parsing a response page corresponding to the user request from the response message, placing the response page into a JS sandbox to run and execute a monitoring event.

2. The XSS attack detection method according to claim 1, It is characterized in that The detecting of the received user request comprises: Check received user requests using XSS attack detection rules; and / or Detect received user requests through semantic analysis methods; and / or Received user requests are inspected through sandbox detection methods.

3. The XSS attack detection method according to any one of claims 1 to 2, It is characterized in that The user request includes an http request.

4. The XSS attack detection method according to claim 1, It is characterized in that The extracting the XSS attack vector from the user request includes: A user parameter is parsed from the user request, and a function in a parameter value corresponding to the user parameter is used as the XSS attack vector.

5. The XSS attack detection method according to claim 4, It is characterized in that The comparing the monitored event corresponding to the response message with the XSS attack vector includes: The monitored function of the event corresponding to the response message is compared with the function in the parameter value corresponding to the user parameter.

6. An XSS attack detection device, It is characterized in that The method comprises: The first processing module is used to detect the received user request and determine whether it is an XSS attack; A second processing module is used to extract an XSS attack vector from the user request if it is an XSS attack; The third processing module is used to obtain a response message corresponding to the user request, put the response message into a JS sandbox to run and execute monitoring events, and compare the monitored events corresponding to the response message with the XSS attack vector. If the comparison results are consistent, the XSS attack is successful; wherein, the comparison of the monitored events corresponding to the response message with the XSS attack vector includes: text comparison of the code statements of the monitored events with the parsed XSS attack vector, or after putting the response message into a JS sandbox to run and execute the monitoring events, parsing the monitored events and / or the sequence of events. sequence, after extracting the XSS attack vector from the user request, parsing the events and / or the order of event occurrence in the XSS attack vector, and then comparing the events and / or the order of event occurrence parsed from the monitoring event with the events and / or the order of event occurrence parsed from the XSS attack vector; the obtaining of a response message corresponding to the user request, placing the response message in a JS sandbox to run and execute the monitoring event, includes: obtaining a response message corresponding to the user request, parsing a response page corresponding to the user request from the response message, placing the response page in a JS sandbox to run and execute the monitoring event.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the XSS attack detection method according to claims 1 to 5 are implemented.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the XSS attack detection method according to claims 1 to 5 are implemented.

9. A computer program product having executable instructions stored thereon, It is characterized in that When the instruction is executed by the processor, the processor implements the steps of the XSS attack detection method as described in claims 1 to 5.