java - Struts XSS Prevention - Prevent a GET XSS -


i have been able prevent xss attack in struts 1.2 through combination of filter="true" in bean:write messages , using stringescapeutils.escapehtml4(string) in tag libs using. can attack site through attack in url in following form...

www.mysite.com/app/start.do?logo=mylogo'><script>alert("attack")</script> 

any advice on best way prevent this. tried using servlet filter don't want convert request inputs special characters.

easiest way i've found block xss replacing >, < , " characters &lt;, &gt; , &quot; before writing webpage. should protect xss long aren't placing user input inside places such script tags, image tags (xss has been possible src= of image tags) etc won't able create own tags.

in php htmlspecialchars method encodes characters that. java doesn't have method quickest way replace those, should go through entire list yourself. shouldn't hard implement 5 replaceall()


the docs stringescapeutils method using claims perform suggest above, should check using method correctly example shouldn't survive form of prevention.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -