Is it possible to inject and execute javascript in the following context? Or terminate the JavaScript string?
- The URL is inserted into a JavaScript string (double-quote delimited)
- The URL is URL encoded by the browser and not the server side. (for simplicity, only using Firefox and Chrome)
- The URL is never decoded (either in JavaScript or the back end)
Example:
var baseURL = "http://example.com/?[USER CONTROLLED INPUT]";
Note that one may cause a unterminated string literal JavaScript error by providing a string that ends in "\
". Assume this error does not impact other use of user input.
Note: Browser URI encoding currently varies.
Given the following URL:
example.com?!*'();:@&=+$,/?[]"%-.<>\^_`{|}~#
FireFox 27.01 submits:
http://example.com/?!*%27%28%29;:@&=+$,/[]%22%-.%3C%3E\^_%60{|}~#
Chromium 32.0 submits:
http://example.com/?!*%27();:@&=+$,/?[]%22%-.%3C%3E\^_`{|}~#
#
is actually submitted. :) – Gumbo Mar 13 at 21:45[USER CONTROLLED INPUT]
is being outputted by your server, then yes, it's possible for a user to input";alert('foobar');_ = "
to alert "foobar" without breaking the code. If it is instead being built by javascript, then no it won't break, unless it's used to generate html. – Kevin B Mar 13 at 21:50