Two Laptop Bag*
The moose likes Security and the fly likes DOM Based XSS and check Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "DOM Based XSS and check" Watch "DOM Based XSS and check" New topic

DOM Based XSS and check

Sandy Saahil

Joined: Apr 06, 2006
Posts: 9
Hi Techies,

I am trying to block DOM Based XSS attacks. I want to redirect user to error page if he enters any javascript functions like onMouseHover or window.location etc.

[url=http://domainname/context/somepath/somepage.htm?printable=true"+onmouseover="window.location='//';"+" ]Xss inserted URL[/url]

Encoding is an option but I dont even want to handle such requests. Is there any way of doing that? I browsed OWASP and other security sites but everybody is explaining encoding user input. I want to throw such requests to error page and log them in server logs.


Keep Faith
manjesh ipp

Joined: Jan 01, 2011
Posts: 9
I think you should validate the inputs and process only trusted data. In this case you know "printable" query parameter should take only "true" or "false" .If you find anything other than these possible values just return some default value or generate a user defined DataValidationException to you can map a global error page.

Sandy Saahil

Joined: Apr 06, 2006
Posts: 9
Thanks Manjesh for your reply.

I have used ESAPI decode to decode the URL. In my case it would be unable to decode it properly and give error which is what I wanted.

jQuery in Action, 2nd edition
subject: DOM Based XSS and check
Similar Threads
Redirect to the requested page failed using form-based authentication
Info on Servlet Filters
filters in java
Google Search Using JavaScript
How to get the path of the server in HTML