How to fix XSS Reflected in java

I have a fortification report that shows the XSS Reflected defect from the 2nd line below.

String name = request.getParameter ("name");

response.getWriter (). write ("Name:" + name);

Recommendation: All user input displayed to web clients must be HTML encoded and validated. This is Java code and I'm not sure how to fix this.

+3


source to share


1 answer


In a simple way, you can simply use the OWASP Enterprise Security API (Java Edition):

 String safe = ESAPI.encoder().encodeForHTML( request.getParameter( "input" ) );

      

See the link:



OWASP Enterprise Security API Documentation (Java Edition)

OWASP Enterprise Security API (Java Edition) Sample Code

+6


source







All Articles