In my Java EE project, I set a filter in web.xml file which will use the Class MyHttpServeltRequestWrapper
(extends HttpServletRequestWrapper
). I am overriding the methods getParameter/ getParametervalues method in it inorder to prevent any XSS attacks.
I'm performing HTML escaping on parameter values.
Can someone please tell if it is a good idea to redefine the methods like
getRequestURL()
,getRequestURI()
,getQueryString()
,getCookies()
methods to put in XSS prevention logic.
Can I use URLEncoder
on values returned by getRequestURL()
, getRequestURI()
, getQueryString()
?
And what about the getCookies methods? In what way it makes my pages vulnerable to attacks if I leave my getcookies()
method unsanitized?