I was told by penetration test team that the below URL is causing XSS attack -
Here is my code of download_msg.jsp
<% String download_msg = null;
if (session == null || session.getAttribute("user") == null) {
download_msg = "Error message";
} else {
download_msg =
(OLSUser)session.getAttribute("user")).getReportInfo().getDownloadMsg();
}
%>
<html>
<head>
<SCRIPT LANGUAGE='JavaScript' SRC='/Test/test.js'></SCRIPT>
<SCRIPT LANGUAGE='JavaScript'>init('StmsReps');</SCRIPT>
<script language="JavaScript">
function redirect() {
if (window.focus)
self.focus();
this.location = "/test/DownloadReport?<%=request.getQueryString()%>";
}
</script>
<title>XSS</title>
</head>
<body marginwidth='0' marginheight='0' onload='javascript:redirect()'>
<table width='90%' height='100%' align='center' border='0' cellspacing='0'
cellpadding='0'>
<tr>
<td align='center' class='header2'> <%= download_msg %></td>
</tr>
</table>
</body>
</html>
I found that jstl can handle XSS attack. Can you please advice if do the below then will it be fine or do I need to do something else?
<c:out value="<%= download_msg %>" escapeXml="true"/>