Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why/How is `value="javascript:alert(1)"` considered as a XSS vulnerability in OWASP's ZAP tool?

The results for OWASP's ZAP has been very useful for eliminating vulnerable parts of my website.

However, I've found a lot of results that I simply cannot fix. For example, one of the get parameters it has put javascript:alert(1); in to the variable. This variable is then output by PHP in a hidden element's value attribute. So the final HTML looks like:

<input type="hidden" name="someName" id="someID" value="javascript:alert(1);"/>

This value is normally used to populate a drop down with JavaScript. If it's 1 it shows optional search filters, if 0 it shows nothing. So it's only used in a string comparison that fails.

I see no way for this to be exploited, the alert does not run like other attacks ZAP has shown me. The output is encoded so they cannot inject HTML by ending the quotes or element early with "/> like previously found attacks, as these characters become their HTML entities counterpart.

Is this just a false positive from ZAP matching the input string in the page source, as encoding javascript:alert(1); still equals exactly the same as javascript:alert(1);?

like image 595
MatthewMcGovern Avatar asked May 17 '13 15:05

MatthewMcGovern


People also ask

What does Alert 1 do JavaScript?

One useful function that's native to JavaScript is the alert() function. This function will display text in a dialog box that pops up on the screen.

How can you test whether the website is vulnerable to XSS or not?

Analyze Input Vectors Analyze each input vector to detect potential vulnerabilities. To detect an XSS vulnerability, the tester will typically use specially crafted input data with each input vector. Such input data is typically harmless, but trigger responses from the web browser that manifests the vulnerability.

What types of HTML tags can be used to execute XSS attacks?

XSS attacks may be conducted without using <script>...</script> tags. Other tags will do exactly the same thing, for example: <body onload=alert('test1')> or other attributes like: onmouseover , onerror .


1 Answers

The vulnerability means that ZAP managed to insert arbitrary code into that input field. This means that you're most likely not validating user input somewhere in the app.

You should be more careful about generating that input field, and ensure that the GET parameter(s) used to generate it are validate accordingly.

Remember, it's better to be safe, than sorry (i.e. have your app compromised).

like image 129
Andrei Bârsan Avatar answered Oct 22 '22 20:10

Andrei Bârsan