渗透测试团队告诉我,以下 URL 导致 XSS 攻击 -
这是我的 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>
我发现jstl可以处理XSS攻击。您能否建议如果执行以下操作会很好还是我需要做其他事情?
<c:out value="<%= download_msg %>" escapeXml="true"/>