Automated Detection of Cross Site Scripting Attacks
20220210180 · 2022-06-30
Inventors
Cpc classification
H04L67/02
ELECTRICITY
International classification
Abstract
Embodiments detect cross site scripting attacks. An embodiment captures a web request and captures a response to the captured web request. In turn, it is determined if one or more elements associated with the captured web request and one or more elements of the captured response, in combination, cause a malicious action. A cross site scripting attack is then declared in response to determining the one or more elements associated with the captured web request and the one or more elements of the captured response, in combination, cause a malicious action. Embodiments can take one or more protection actions in response to declaring a cross site scripting attack.
Claims
1. A method of detecting a cross site scripting attack, the method comprising: capturing a web request; capturing a response to the captured web request; determining if one or more elements associated with the captured web request and one or more elements of the captured response, in combination, cause a malicious action; and declaring a cross site scripting attack in response to determining the one or more elements associated with the captured web request and the one or more elements of the captured response, in combination, cause a malicious action.
2. The method of claim 1 wherein the one or more elements associated with the captured web request and the one or more elements of the captured response include at least one of: a scripting verb; and a Document Object Model (DOM).
3. The method of claim 1 wherein the one or more elements associated with the captured web request include a first scripting verb and the one or more elements of the captured response include a second scripting verb and where, if the first scripting verb and the second scripting verb match, the determining identifies the first scripting verb in combination with the second script verb cause a malicious action.
4. The method of claim 1 wherein the one or more elements associated with the captured web request include a first DOM element and the one or more elements of the captured response include a second DOM element.
5. The method of claim 4 wherein: the determining identifies the first DOM element in combination with the second DOM element cause a malicious action; and the declared cross site scripting attack is a DOM scripting attack.
6. The method of claim 1 wherein the determining and the declaring are performed by computer programming code implemented in a browser associated with the web request.
7. The method of claim 6 wherein the computer programming code is in a scripting language.
8. The method of claim 1 wherein the captured response includes both a database response and a Hypertext Transfer Protocol (HTTP) response.
9. The method of claim 8 wherein the one or more elements associated with the captured web request include a first scripting verb and the one or more elements of the captured response include a second scripting verb in the database response and a third scripting verb in the HTTP response.
10. The method of claim 9 wherein: if the first scripting verb and the third scripting verb match: (i) the determining identifies the first scripting verb in combination with the third scripting verb cause a malicious action and (ii) the declared cross site scripting attack is a reflected cross site scripting attack; and if the first scripting verb and the second scripting verb match: (i) the determining identifies the first scripting verb in combination with the second scripting verb cause a malicious action and (ii) the declared cross site scripting attack is a stored cross site scripting attack.
11. The method of claim 1 wherein the web request is captured after being decrypted and decoded.
12. The method of claim 1 further comprising: in response to declaring the cross site scripting attack, implementing a protection action.
13. The method of claim 12 wherein the protection action is at least one of: executing a user indicated script; terminating an Internet Protocol (IP) connection; terminating a web session; providing a compensating control to a web application firewall; and displaying an indication of the cross site scripting attack to a user.
14. A system for detecting a cross site scripting attack, the system comprising: a processor; and a memory with computer code instructions stored thereon, the processor and the memory, with the computer code instructions, being configured to cause the system to: capture a web request; capture a response to the captured web request; determine if one or more elements associated with the captured web request and one or more elements of the captured response, in combination, cause a malicious action; and declare a cross site scripting attack in response to determining the one or more elements associated with the captured web request and the one or more elements of the captured response, in combination, cause a malicious action.
15. The system of claim 14 wherein the one or more elements associated with the captured web request and the one or more elements of the captured response include at least one of: a scripting verb; and a Document Object Model (DOM).
16. The system of claim 14 wherein the one or more elements associated with the captured web request include a first DOM element and the one or more elements of the captured response include a second DOM element.
17. The system of claim 16 wherein: the determining identifies the first DOM element in combination with the second DOM element cause a malicious action; and the declared cross site scripting attack is a DOM scripting attack.
18. The system of claim 14 wherein (i) the captured response includes both a database response and a Hypertext Transfer Protocol (HTTP) response and (ii) the one or more elements associated with the captured web request include a first scripting verb and the one or more elements of the captured response include a second scripting verb in the database response and a third scripting verb in the HTTP response, and where: if the first scripting verb and the third scripting verb match: (i) the determining identifies the first scripting verb in combination with the third scripting verb cause a malicious action and (ii) the declared cross site scripting attack is a reflected cross site scripting attack; and if the first scripting verb and the second scripting verb match: (i) the determining identifies the first scripting verb in combination with the second scripting verb cause a malicious action and (ii) the declared cross site scripting attack is a stored cross site scripting attack.
19. The system of claim 14 wherein the processor and the memory, with the computer code instructions, are further configured to cause the system to: in response to declaring the cross site scripting attack, implement a protection action.
20. A computer program for detecting a cross site scripting attack, the computer program product comprising: one or more non-transitory computer read-able storage devices and program instructions stored on at least one of the one or more storage devices, the program instructions, when loaded and executed by a processor, cause an apparatus associated with the processor to: capture a web request; capture a response to the captured web request; determine if one or more elements associated with the captured web request and one or more elements of the captured response, in combination, cause a malicious action; and declare a cross site scripting attack in response to determining the one or more elements associated with the captured web request and the one or more elements of the captured response, in combination, cause a malicious action.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The foregoing will be apparent from the following more particular description of example embodiments, as illustrated in the accompanying drawings in which like reference characters refer to the same parts throughout the different views. The drawings are not necessarily to scale, emphasis instead being placed upon illustrating embodiments.
[0017]
[0018]
[0019]
[0020]
[0021]
DETAILED DESCRIPTION
[0022] A description of example embodiments follows. Embodiments provide improved functionality to detect cross site scripting attacks.
[0023] Cross site scripting attacks appear in three main variants: (1) Reflected Cross Site Scripting (RXSS) attacks, (2) Stored Cross Site Scripting (SXSS) attacks, an (3) Document Object Model (DOM) based Scripting (DOMXSS) attacks.
[0024] A RXSS attack occurs when an application receives scripting (JavaScript, VBScript, SVG, Active HTML etc.) data in an HTTP request and dispatches that data in the corresponding HTTP response without neutralizing, i.e., making scripting verbs inactive and simply text, the active verbs. The end-user's browser executes the scripting element which causes harm to the end-user. JavaScript actions that can escape the browser's sandbox can cause serious damage to the end user.
[0025] A SXSS attack occurs when an application receives scripting (JavaScript, VBScript, SVG, Active HTML etc.) data in an HTTP request and dispatches that data in a later HTTP response, e.g., where the later HTTP response includes a database response, without neutralizing the active verbs. The end-user's browser executes the scripting element which causes harm to the end-user. JavaScript actions that can escape the browser's sandbox can cause serious damage to the end user.
[0026] A DOMXSS attack occurs when a JavaScript takes untrusted DOM elements that have been reflected via an HTTP Response and combines it with a user supplied DOM element in the HTTP Request (the browser does not send DOM elements in the HTTP Request line to the server). A DOM element reflected via the HTTP Response can execute malicious code on the end-user's browser.
[0027] Some of the challenges faced by existing solutions, like the Web Application Firewall (WAF), is that the user content comes over the wire in encrypted and/or heavily multi-encoded format which makes it difficult for the WAF to detect cross site scripting attacks without dramatically affecting latency. Another issue is that detecting reflection between HTTP Requests and HTTP Responses requires maintaining state. This is a very expensive operation especially when the WAF is being subject to thousands of concurrent sessions.
[0028] As such, improved functionality is needed to detect cross site scripting attacks. Embodiments provide such functionality and automatically detect cross site scripting attacks.
[0029]
[0030] The method 100 begins at step 101 by capturing a web request. Similarly, at step 102, the method 100 captures a response to the captured web request. According to an embodiment of the method 100, the web request is captured after being decrypted and decoded. In an embodiment, the capturing is done using a framework that implements byte code sensors, e.g., the sensors 223a-d, that are configured to hook, i.e., capture, the web request and response. According to an embodiment, the capturing 101 and 102 is implemented by instrumenting strategic code, such as the HTTP Event pipeline, to detect and intercept traffic at the web server or application server or monitoring specific APIs at the web server or application server. In another embodiment, the capturing is done using a packet capture tool, such as PCAP, Wireshark, or BURP.
[0031] To continue, at step 103, the method 100 determines if one or more elements associated with the captured web request and one or more elements of the captured response, in combination, cause a malicious action.
[0032] In turn, at step 104, the method 100 declares a cross site scripting attack in response to determining the one or more elements associated with the captured web request and the one or more elements of the captured response, in combination, cause a malicious action.
[0033] According to an embodiment of the method 100, the one or more elements associated with the captured (101) web request and the one or more elements of the captured (102) response include at least one of a scripting verb and a Document Object Model (DOM).
[0034] In an embodiment of the method 100, the one or more elements associated with the captured web request include a first scripting verb and the one or more elements of the captured response include a second scripting verb. In such an embodiment, if the first scripting verb and the second scripting verb match, the determining identifies the first scripting verb in combination with the second script verb cause a malicious action. As such, a cross site scripting attack is declared. In an embodiment, the first and second scripting verb are the same, i.e., match, because the script passes from the request, through the application, and back to the user's browser. In turn, the script will execute in the user's browser, causing the malicious action.
[0035] The one or more elements associated with the captured (101) web request may include a first DOM element and the one or more elements of the captured (102) response may include a second DOM element. In an embodiment, the determining (103) can identify that the first DOM element in combination with the second DOM element causes a malicious action. When the occurs, the declared (104) cross site scripting attack is a DOM scripting attack. In yet another embodiment, the determining (103) and the declaring (104) are performed by computer programming code implemented in a browser associated with the web request. In such an embodiment, the computer programming code can be in a Java format. Such an implementation may be utilized to detect a DOM cross site scripting attack.
[0036] In an example embodiment, the captured (102) response includes both a database response and a Hypertext Transfer Protocol (HTTP) response. In such an embodiment, the one or more elements associated with the captured (101) web request may include a first scripting verb and the one or more elements of the captured (102) response may include a second scripting verb in the database response and a third scripting verb in the HTTP response. According to such an example embodiment, if the first scripting verb and the third scripting verb match: (i) the determining (103) identifies the first scripting verb in combination with the third scripting verb cause a malicious action and (ii) the declared (104) cross site scripting attack is a reflected cross site scripting attack. Further, if the first scripting verb and the second scripting verb match: (i) the determining (103) identifies the first scripting verb in combination with the second scripting verb cause a malicious action and (ii) the declared (104) cross site scripting attack is a stored cross site scripting attack.
[0037] Embodiments of the method 100 may also implement a protection action in response to declaring (104) the cross site scripting attack. Example protection actions include (i) executing a user indicated script, (ii) terminating an Internet Protocol (IP) connection, (iii) terminating a web session, (iv) providing a compensating control to a web application firewall, and/or (v) displaying an indication of the cross site scripting attack to a user, amongst other examples.
[0038]
[0039] The system 220 processes a user 221 input HTTP request 224 (which is received by the network 222) at a server computing device (not shown) that includes byte code instrumentation sensors 223a-d. The user 221 input HTTP request 224 is processed by the business logic 225 and induces a downstream interpreter request 226. The request 226 induces a downstream interpreter response 227 which is processed by the business logic 228 to create the HTTP response 229 that is sent back to the user 221 via the network 222.
[0040] Throughout these steps, the byte code instrumentation sensors 223a-d collect data which is analyzed by an analysis engine, e.g., the engine 331 described hereinbelow in relation to
[0041] The functionality of the system 220 provides significantly deeper analysis of web requests, e.g., the HTTP request 224, in comparison to existing tools. For instance, an existing tool may only consider the interpreter syntax in the HTTP request 224 when determining if the request 224 is malicious, but the system 220 goes further and looks to the actual resulting actions, e.g., downstream interpreter request 226, downstream interpreter response 227, and business logic 228 response, induced by the request 224 to determine if there is an attack.
[0042] In an example implementation of the system 220, input 224 from the user 221 is instrumented and inspected at the entrance of the HTTP Pipeline application by the sensor 223a. Unlike WAF functionality, the instrumentation in the proposed solution 220 does not have to deal with encryption or encoding issues because the data is picked up just in time for consumption by a web application that is receiving the HTTP input, which means all decrypting and decoding has already been done upstream. Relevant data such as HTTP Session ID, URL, User Info, and Scripting language verbs in user input 224 etc., is appended into a HTTP Context object.
[0043] The data returned by the downstream database (an interpreter 226) is also inspected for the presence of scripting verbs that may have been stored by the attacker previously. This is for the purpose of establishing a baseline for stored scripting content. Any scripting verbs are stored in the HTTP Context object.
[0044] Finally, the data returned by the end of the HTTP pipeline in the HTTP Response 229 is also inspected for the presence of the same scripting verbs that were found in the two possible inputs (HTTP Request 224 and DB Response 227). If a match is found then a RXSS or SXSS attack is declared. RXSS is declared if the scripting verb was found in the HTTP Request 224 and SXSS attack is declared if scripting elements were found in the database output 227.
[0045] One further round of inspection occurs in the user's browser. This is because, if there are DOM elements present in the HTTP request 224 line, these are not transmitted to the server. However, an attacker can reflect DOM elements and cause them to be reflected back to the browser where the DOM object used in the HTTP input 224 can process the DOM element being received via the HTTP Response 229. This can result in the DOM interpreter reacting adversely and performing malicious actions on the user's 221 browser. In an embodiment, this inspection is performed in the user's browser by a JavaScript specially dispatched by the proposed solution 220 into the browser. This JavaScript can perform DOM element sanitizing and declare an attack if dangerous DOM elements arrived via the HTTP Response 229.
[0046]
[0047] In the system 330, new code and upgrades for VSP code are delivered into the VSP Infra Service (337).
[0048] Users (some good, some bad) 332 send HTTP or web requests to the one or more clusters of application server(s) 334. These HTTP or web requests can be inspected by a WAF 333 which may or may not be able to decode the contents since these HTTP or web requests may be encrypted or encoded.
[0049] However, in the system 330, the instrumentation 340 in the servers 334, extracts the data (as described in relation to
[0050] The analysis by the system 330 also pushes forensic details about the attack such as URL, User, Web Session, offending script details etc. into the Central Monitoring System 338 for display in a dashboard.
[0051] In all the three cases, RXSS, SXSS, and DOMXSS, the Analysis Engine 331 triggers one or more desired protection actions. In an embodiment, protection actions are implemented by firing a user chosen/provided script that can execute any of several protection actions. Example protection actions include terminating the IP connection or terminating the web session. One protection action may also include firing a Compensating Control into a Web Application firewall. This allows the WAF to know the details of which parameter in which URL is subject to an XSS vulnerability.
[0052] Embodiments have numerous benefits compared to existing solutions. For instance, unlike WAF solutions, embodiments do not suffer from having to perform decryption and encryption upstream of the application. This prevents latency in the HTTP pipeline and avoids large processing overheads. Embodiments can also maintain state between the two types of inputs (from HTTP Request as well as DBB Response) on the one hand and the HTTP Response on the other hand. Unlike WAF, embodiments can dispatch a JavaScript into user browsers. This allows embodiments to detect and block DOM XSS.
[0053] Further, since the WAF does not save state and declares an attack based on scripting input being present in the HTTP input, there is a possibility that this is a false negative. The application's business logic could have neutralized scripting input and, therefore, there was no need to have raised an alert and thereby create work on a forensic analyst. The scripting verbs may have been present in some text box in which case it would not have caused harm. A WAF would not be in a position to know the details of how the application handles user input and therefore may trip a wholly not required alert in this case. Embodiments do not suffer from this problem.
[0054] Below, Table 1 summarizes benefits of embodiments compared to existing methods:
TABLE-US-00001 TABLE 1 WAF RASP Embodiments Practical Out-Of-The Requires Limited protection Full protection Box-Protection extensive without integration without learning or learning, tuning, and tuning tuning adjusting Code Impact No code impact Code changes and No code integration for modification advanced required functionality Performance Heavy loads Increases transaction High performance Under Load force fail-open latency substantially minimal latency mode impact Effective App Surface Limited breadth More depth with Full stack coverage Coverage and depth customization File System Not supported Not supported Fully integrated Monitoring Malware Not supported Not supported Full protection from Protection file based, fileless, and WRT Accurate Context Stateless: Limited Stateless: More Stateful: Full Awareness context based context with context awareness only on HTTP extensive integration analysis and tuning High accuracy, Low fidelity, Limited fidelity, high Deterministic, low false high false false positives eliminate false positives positives positives Protection Basic protection Limited protection Extensive, flexible Actions actions actions protection.
[0055]
[0056] Client computer(s)/devices 50 and server computer(s) 60 provide processing, storage, and input/output devices executing application programs and the like. The client computer(s)/devices 50 can also be linked through communications network 70 to other computing devices, including other client devices/processes 50 and server computer(s) 60. The communications network 70 can be part of a remote access network, a global network (e.g., the Internet), a worldwide collection of computers, local area or wide area networks, and gateways that currently use respective protocols (TCP/IP, Bluetooth®, etc.) to communicate with one another. Other electronic device/computer network architectures are suitable.
[0057] Client computers/devices 50 and/or servers 60 may be configured, alone or in combination, to implement the embodiments described herein, e.g., the method 100, amongst other examples. The server computers 60 may not be separate server computers but part of cloud network 70.
[0058]
[0059] Embodiments or aspects thereof may be implemented in the form of hardware including but not limited to hardware circuitry, firmware, or software. If implemented in software, the software may be stored on any non-transient computer readable medium that is configured to enable a processor to load the software or subsets of instructions thereof. The processor then executes the instructions and is configured to operate or cause an apparatus to operate in a manner as described herein.
[0060] Further, hardware, firmware, software, routines, or instructions may be described herein as performing certain actions and/or functions of the data processors. However, it should be appreciated that such descriptions contained herein are merely for convenience and that such actions in fact result from computing devices, processors, controllers, or other devices executing the firmware, software, routines, instructions, etc.
[0061] It should be understood that the flow diagrams, block diagrams, and network diagrams may include more or fewer elements, be arranged differently, or be represented differently. But it further should be understood that certain implementations may dictate the block and network diagrams and the number of block and network diagrams illustrating the execution of the embodiments be implemented in a particular way.
[0062] Accordingly, further embodiments may also be implemented in a variety of computer architectures, physical, virtual, cloud computers, and/or some combination thereof, and, thus, the data processors described herein are intended for purposes of illustration only and not as a limitation of the embodiments.
[0063] The teachings of all patents, published applications and references cited herein are incorporated by reference in their entirety.
[0064] While example embodiments have been particularly shown and described, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the embodiments encompassed by the appended claims.