Invicti detected a DOM based Cross-site Scripting (XSS).
The Document Object Model (DOM) is a convention for representing and interacting with objects in HTML, XHTML and XML documents. Objects in the DOM tree may be manipulated by using methods on the objects.
All HTML documents have an associated DOM, consisting of objects representing the document properties from the point of view of the browser.
DOM Based XSS is an XSS attack wherein the attack payload is executed as a result of modifying the DOM environment in the victim's browser used by the original client side script, so that the client side code runs in an unexpected manner. The response from the server does not change, but the client side code contained in the page executes differently due to the malicious modifications that have occurred in the DOM environment.
This is in contrast to other XSS attacks (stored or reflected), wherein the attack payload is placed in the response page (due to a server side flaw).
Suppose the following code is used to create a form to let the user choose his/her preferred language. A default language is also provided in the query string, as the parameter "default".
… Select your language: <select> <script> document.write("<OPTION value=1>" + document.location.href.substring(document.location.href.indexOf("default=") + 8) + "</OPTION>"); document.write("<OPTION value=2>English</OPTION>"); </script> </select> …
The malicious script can be embedded in the URL as follows in two ways:
Pay close attention to the second version of the attack. When the victim clicks on the second link, the browser sends a HTTP request to:
The technique to avoid sending the payload to the server hinges on the fact that URI fragments (the part in the URI after the "#") is not sent to the server by the browser. Thus, any client side code that references (i.e, document.location) may be vulnerable to an attack which uses fragments, and in such case the payload is never sent to the server.
Note that the HTTP response sent from the server does not contain the attacker’s payload. This payload manifests itself at the client-side script at runtime, when a flawed script accesses the DOM variable document.location and assumes it is not malicious.Server-side attack detection tools will fail to detect such hash (#) attacks; in some cases, depending on the type of the URL, the server might get the payload and block the request.
- Avoid use of HTML rendering properties/methods. (e.g.,
document.write). Instead use