Is it possible to perform a cross-site scripting attack by entering my script into a field that is required to match a specific value?
I am scanning an application for vulnerabilities, and my scanning tool (OWASP ZAP) is returning several cross-site scripting vulnerabilities. The returned results include a path for a REST request, the associated method (GET or POST) and the parameter used to include the script.
The issue is that for each vulnerability, the parameter used is an id for a unique value. For example, a getUserPrivileges
GET request is showing vulnerability using the parameter 'userId'. If I were to try to make this request in SoapUI, using an invalid userId, I would get a "Bad Request" response. There is also no place in the UI that would allow me to enter my own value for this parameter.
My assumption is that issues like these are all false positives, but, not being highly knowledgeable on this topic, I wanted to check my assumption.
If I am correct in this assumption, would there be any reason why such a false positive would come up? Is there something that would cause my scanning tool to mistake this for an issue?
Edit: Here are two example requests. One of them that I think may actually be a problem is Example 2. I notice that the "" text in that example is present in the raw response, but not in the html response.
(When I say that html content is not accepted, i am referring to the content in the request response. The settings for this are on the server-side. In Spring, this seems to appear with the absence of something like "produces=MediaType.TEXT_HTML_VALUE" in the method declaration and its substitution with something like "produces=MediaType.APPLICATION_JSON_VALUE".)
Example 1:
Request:
GET http://###.##.##.###:####/AAAAAAAA/BBBBBBBB/CCCCCCCC? requestId=%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E&comments=%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E HTTP/1.1
Accept-Encoding: gzip,deflate
token: 2cd68a38-c3bd-a56b-e65c-b76da893cd4d
Response (Raw):
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
token: 2cd68a38-c3bd-a56b-e65c-b76da893cd4d
token: 2cd68a38-c3bd-a56b-e65c-b76da893cd4d
Content-Type: application/json;charset=UTF-8
Content-Length: 167
Date: Wed, 22 Aug 2018 ##:##:## GMT
Connection: close
{"timestamp":#############,"status":400,"error":"Bad Request","exception":"java.lang.NumberFormatException","message":"For input string: '<script>alert(1);</script>'"}
Response (HTML):
unsupported content-type [application/json;charset=UTF-8]
Example 2:
Request:
GET http://###.##.#.###:####/AAAAAAAA/BBBBBBBB/CCCCCCCC?requestId=%3Cscript%3Ealert%28%22hello%22%29%3B%3C%2Fscript%3E HTTP/1.1
Accept-Encoding: gzip,deflate
token: 2cd68a38-c3bd-a56b-e65c-b76da893cd4d
Host: ###.##.#.###:####
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Response (raw):
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
token: 2cd68a38-c3bd-a56b-e65c-b76da893cd4d
token: 2cd68a38-c3bd-a56b-e65c-b76da893cd4d
Content-Type: text/html;charset=UTF-8
Content-Length: 173
Date: Wed, 22 Aug 2018 ##:##:## GMT
Connection: close
{"timestamp":#############,
"status":400,
"error":"BadRequest",
"exception":"java.lang.NumberFormatException",
"message":"For input string: '<script>alert('hello');</script>'"}
Response (HTML):
{"timestamp":#############,
"status":400,
"error":"Bad Request",
"exception":"java.lang.NumberFormatException",
"message":"For input string: ''"}
Response (HTML)
There is only ever one response. How are you executing these requests? With your browser or some HTTP agent (e.g. curl, postman)?