XSS (Cross-site Scripting) allows an attacker to execute a dynamic script (Javascript, VbScript) in the context of the application. This allows several different attack opportunities, mostly hijacking the current session of the user or changing the look of the page by changing the HTML on the fly to steal the user's credentials. This happens because the input entered by a user has been interpreted as HTML/Javascript/VbScript by the browser.
XSS targets the users of the application instead of the server. Although this is a limitation, since it allows attackers to hijack other users' session, an attacker might attack an administrator to gain full control over the application.
Impact
There are many different attacks that can be leveraged through the use of XSS, including:
Hi-jacking users' active session
Changing the look of the page within the victims browser.
Mounting a successful phishing attack.
Intercept data and perform man-in-the-middle attacks.
Remedy
The issue occurs because the browser interprets the input as active HTML, Javascript or VbScript. To avoid this, all input and output from the application should be filtered. Output should be filtered according to the output format and location. Typically the output location is HTML. Where the output is HTML ensure that all active content is removed prior to its presentation to the server.
Prior to sanitizing user input, ensure you have a pre-defined list of both expected and acceptable characters with which you populate a white-list. This list needs only be defined once and should be used to sanitize and validate all subsequent input.
There are a number of pre-defined, well structured white-list libraries available for many different environments, good examples of these include, OWASP Reform and Microsoft Anti Cross-site Scripting libraries are good examples.
<!-- begin adaptive technology instructions and top banner/top nav/search-->
<!-- begin adaptive technology instructions --> <table width="740" cellpadding="0" cellspacing="0" border="0"> <tr> <td bgcolor="#ffffff" class="assistive" tabindex="1">Welcome to the Official State Web Site of Mississippi. This site is compatible with assistive technology. <a href="#nonav" class="assistive">Skip navigation links</a></td> </tr> </table> <!-- end adaptive technology instructions -->
<!-- begin top banner/top nav/search --> <table width="760" cellpadding="0" cellspacing="0" border="0"> <tr> <td rowspan="3"> <table width="76" cellpadding="0" cellspacing="0" border="0"> <tr> <td><img src="images/gfx_banner_01.jpg" width="76" height="100" border="0" alt="State outline on swamp"></td> </tr> </table> </td> <td valign="top"><img src="images/gfx_banner_02.jpg" width="445" height="57" border="0" alt="Mississippi.gov logo and photo of state capitol"></td> <td valign="top"><img src="images/gfx_banner_03.jpg" width="239" height="57" border="0" alt="Photo of antebellum home"></td> </tr> <tr> <td valign="top" bgcolor="#406618"> <table width="445" cellpadding="0" cellspacing="0" border="0"> <tr> <td colspan="6" valign="top"><img src="images/gfx_banner_04.jpg" width="445" height="24" border="0" alt=""></td> </tr>
<!-- begin main content area --> <td width="431" valign="top"> <table width="431" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="3"><!-- begin left gutter, please leave this here! please! --><img src="images/nothing.gif" width="3" height="1" border="0" alt=""><!-- end left gutter, please leave this here! please! --></td> <td width="428" align="center">
<!-- begin mississippi government sub-nav - split into rows to maintain horizontal alignment -->
<HTML><HEAD><title>JSP Processing Error</title><style type="text/css">#mybox{padding: 0.5em;border: noborder; border-width: thin; width: 100%;}</style><style type="text/css">h2 { text-align: justify;color:#5555FF;font-size:15pt;font-family: Verdana, Helvitica, sans-serif;font-weight:bold}</style></HEAD><BODY><h2>JSP Processing Error</h2><TABLE BORDER=2 BGCOLOR="#DDDDFF"><TR VALIGN="BOTTOM"><TD BGCOLOR="#C2B0D6" ><B><FONT FACE="Verdana, Helvitica, sans-serif" COLOR="black" SIZE="4PT">HTTP Error Code: 404</B><BR><BR></TD></TR><TR><TD><B>Error Message:</B><div id="mybox"><PRE>JSPG0036E: Failed to find resource /components/" stYle="x:expre/**/ssion(netsparker(9)).jsp<BR></PRE></div></TD></TR><TR><TD><B>Root Cause:</B><div id="mybox"><PRE>java.io.FileNotFoundException: JSPG0036E: Failed to find resource /components/" stYle="x:expre/**/ssion(netsparker(9)).jsp<BR> at java.lang.Throwable.<init>(Throwable.java:67)<BR> at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.findWrapper(AbstractJSPExtensionProcessor.java:353)<BR> at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:336)<BR> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:673)<BR> at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1045)<BR> at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1006)<BR> at com.ibm._jsp._ms_5F_sub_5F_template._jspService(_ms_5F_sub_5F_template.java:372)<BR> at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:98)<BR> at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)<BR> at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)<BR> at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)<BR> at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)<BR> at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)<BR> at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)<BR> at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:239)<BR> at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)<BR> at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)<BR> at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)<BR> at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)<BR> at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)<BR> at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)<BR> at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)<BR> at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)<BR> at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)<BR> at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)<BR> at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)<BR> at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)<BR> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)<BR><BR></PRE></div></TD></TR></TABLE></BODY></HTML>
<!-- end mississippi governement sub-nav - split into rows to maintain horizontal alignment -->
<!-- begin state seal --> <table width="416" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="center"><img src="images/gfx_state_seal.gif" width="57" height="57" border="0" alt="Mississippi State Seal"></td> </tr> </table> <!-- end state seal -->
Cookie was not marked as HTTPOnly. HTTPOnly cookies can not be read by client-side scripts therefore marking a cookie as HTTPOnly can provide an additional layer of protection against Cross-site Scripting attacks..
Impact
During a Cross-site Scripting attack an attacker might easily access cookies and hijack the victim's session.
Actions to Take
See the remedy for solution
Consider marking all of the cookies used by the application as HTTPOnly (After these changes javascript code will not able to read cookies.
Remedy
Mark the cookie as HTTPOnly. This will be an extra layer of defence against XSS. However this is not a silver bullet and will not protect the system against Cross-site Scripting attacks. An attacker can use a tool such as XSS Tunnel to bypass HTTPOnly protection.
<!-- begin adaptive technology instructions and top banner/top nav/search-->
<!-- begin adaptive technology instructions --> <table width="740" cellpadding="0" cellspacing="0" border="0"> <tr> <td bgcolor="#ffffff" class="assistive" tabindex="1">Welcome to the Official State Web Site of Mississippi. This site is compatible with assistive technology. <a href="#nonav" class="assistive">Skip navigation links</a></td> </tr> </table> <!-- end adaptive technology instructions -->
<!-- begin top banner/top nav/search --> <table width="760" cellpadding="0" cellspacing="0" border="0"> <tr> <td rowspan="3"> <table width="76" cellpadding="0" cellspacing="0" border="0"> <tr> <td><img src="images/gfx_banner_01.jpg" width="76" height="100" border="0" alt="State outline on swamp"></td> </tr> </table> </td> <td valign="top"><img src="images/gfx_banner_02.jpg" width="445" height="57" border="0" alt="Mississippi.gov logo and photo of state capitol"></td> <td valign="top"><img src="images/gfx_banner_03.jpg" width="239" height="57" border="0" alt="Photo of antebellum home"></td> </tr> <tr> <td valign="top" bgcolor="#406618"> <table width="445" cellpadding="0" cellspacing="0" border="0"> <tr> <td colspan="6" valign="top"><img src="images/gfx_banner_04.jpg" width="445" height="24" border="0" alt=""></td> </tr>
<!-- begin main content area --> <td width="431" valign="top"> <table width="431" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="3"><!-- begin left gutter, please leave this here! please! --><img src="images/nothing.gif" width="3" height="1" border="0" alt=""><!-- end left gutter, please leave this here! please! --></td> <td width="428" align="center">
<!-- begin mississippi government sub-nav - split into rows to maintain horizontal alignment -->
<HTML><HEAD><title>JSP Processing Error</title><style type="text/css">#mybox{padding: 0.5em;border: noborder; border-width: thin; width: 100%;}</style><style type="text/css">h2 { text-align: justify;color:#5555FF;font-size:15pt;font-family: Verdana, Helvitica, sans-serif;font-weight:bold}</style></HEAD><BODY><h2>JSP Processing Error</h2><TABLE BORDER=2 BGCOLOR="#DDDDFF"><TR VALIGN="BOTTOM"><TD BGCOLOR="#C2B0D6" ><B><FONT FACE="Verdana, Helvitica, sans-serif" COLOR="black" SIZE="4PT">HTTP Error Code: 404</B><BR><BR></TD></TR><TR><TD><B>Error Message:</B><div id="mybox"><PRE>JSPG0036E: Failed to find resource /components/46e740"><img src=a onerror=alert(document.cookie)>a3b5706621b.jsp<BR></PRE></div></TD></TR><TR><TD><B>Root Cause:</B><div id="mybox"><PRE>java.io.FileNotFoundException: JSPG0036E: Failed to find resource /components/46e740"><img src=a onerror=alert(document.cookie)>a3b5706621b.jsp<BR> at java.lang.Throwable.<init>(Throwable.java:67)<BR> at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.findWrapper(AbstractJSPExtensionProcessor.java:353)<BR> at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:336)<BR> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:673)<BR> at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1045)<BR> at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1006)<BR> at com.ibm._jsp._ms_5F_sub_5F_template._jspService(_ms_5F_sub_5F_template.java:372)<BR> at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:98)<BR> at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)<BR> at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)<BR> at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)<BR> at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)<BR> at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)<BR> at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)<BR> at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:239)<BR> at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)<BR> at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)<BR> at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)<BR> at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)<BR> at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)<BR> at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)<BR> at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)<BR> at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)<BR> at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)<BR> at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)<BR> at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)<BR> at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)<BR> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)<BR><BR></PRE></div></TD></TR></TABLE></BODY></HTML>
<!-- end mississippi governement sub-nav - split into rows to maintain horizontal alignment -->
<!-- begin state seal --> <table width="416" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="center"><img src="images/gfx_state_seal.gif" width="57" height="57" border="0" alt="Mississippi State Seal"></td> </tr> </table> <!-- end state seal -->