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.
//create a variable for handling requests to be reused var http = null;
function sendMail() { //validate form fields var sErrorMessage = ""; var sPageName = window.document.emailpage.hidPageName.value; var sPageURL = window.document.emailpage.hidPageURL.value; var sMailServer = window.document.emailpage.hidMailServer.value; var sTo = window.document.emailpage.txtTo.value; var sFrom = window.document.emailpage.txtFrom.value; var sMessage = window.document.emailpage.txtMessage.value; var sNewLine = "";
if (Trim(sMailServer) == "") { toggleIt('emailpageform'); document.getElementById('emailMessage').className = "popShow"; document.getElementById('emailMessage').innerHTML = "<font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font>"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; } else {
if (Trim(sTo) == "") { sErrorMessage = sErrorMessage + "You must enter a value in the To: field."; sNewLine = "\n"; } if (Trim(sFrom) == "") { sErrorMessage = sErrorMessage + sNewLine + "You must enter a value in the From: field."; sNewLine = "\n"; } if (sMessage.length > 500) { sErrorMessage = sErrorMessage + sNewLine + "Your message contains " + sMessage.length + " characters. Please limit it to 500 characters."; } if (Trim(sErrorMessage) != "") { alert(sErrorMessage); return false; } else { try { http = new XMLHttpRequest(); // non-IE } catch (error){ try { http = new ActiveXObject("Microsoft.XMLHTTP"); // IE } catch (error) { return false; } } //create a url for the lookup to call //var sURL = 'http://www.mwe.com//index.cfm/fuseaction/email.send_email'; var sURL = 'http://www.mwe.com/dir_email/act_send_mail.cfm'; // more error checking try { parameters = "t=" + sTo + "&f=" + sFrom + "&m=" + escape(sMessage) + "&n=" + escape(sPageName) + "&s=" + sMailServer + "&u=" + sPageURL; //open the http page http.open("POST", sURL , true); //http.onreadystatechange = handleHttpResponseTest; http.onreadystatechange = handleHttpResponse; http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.setRequestHeader('Content-length', parameters.length); http.setRequestHeader("Connection", "close"); http.send(parameters); } catch (error) { alert(error); return false; } //upon a change of status of the request for the send mail page, call the javascript handler //http.onreadystatechange = handleHttpResponse; //close the connection (very important for memory leaks) //http.send(""); return true; } } return false; } //function called once a result is returned from our lookup page function handleHttpResponse() { var xmlDoc; //readystate of 4 means the request is complete if (http.readyState == 4) { //status code of 200 means OK (regular status codes) if (http.status == 200) { xmlDoc = http.responseXML; var mailMessages = xmlDoc.documentElement.getElementsByTagName("mailMessage"); var msgType = mailMessages[0].getAttribute("msgType"); //var msgText = mailMessages[0].firstChild.nodeValue; if (msgType == "SUCCESS") { //document.getElementById('emailMessage').innerHTML = "Your email has been sent."; //document.getElementById('emailMessage').className = "popShow"; toggleIt('emailpageform'); toggleIt('emailMessage'); document.getElementById("emailMessage").innerHTML = "<div id=userMsg>Your email has been sent.</div>"; setTimeout("toggleIt('emailMessage')", 2000); document.getElementById('txtTo').value = ""; } else if (msgType == "INVALID") { //we have to go through this process because the \n was not being recognized in the text coming back var sMessages = ''; var arMessages = new Array(); arMessages = mailMessages[0].firstChild.nodeValue.split('|'); for (var i=0;i<arMessages.length;i++) { sMessages = sMessages + '\n' + arMessages[i]; } alert(sMessages); } else { alert(http.responseText); toggleIt('emailpageform'); toggleIt('emailMessage'); document.getElementById('emailMessage').innerHTML = "<div id=userMsg><font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font></div>"; document.getElementById('emailMessage').className = "popShow"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; setTimeout("toggleIt('emailMessage')", 2000); } } else { toggleIt('emailMessage'); document.getElementById('emailMessage').innerHTML = "<div id=userMsg><font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font></div>"; //document.getElementById('emailMessage').className = "popShow"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; setTimeout("toggleIt('emailMessage')", 2000); return false; } } }
</script>
<li id="savePageLink" class="save"><a href="javascript:save_page('eccdabf9-2276-47ef-9730-31e5884b2bbd.cfm'"--><')">Save this page</a></li>
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.
<p>Elizabeth K. Isbey is an associate in the law firm of McDermott Will & Emery LLP and is based in the Firm’s Washington, D.C., office.<span style="mso-spacerun: yes"> </span> She focuses her practice on health law.</p>
<p>While in law school, Elizabeth was senior articles editor of the <i>Wake Forest Law Review</i> <span style="mso-bidi-font-style: italic">and was awarded the Law Review Prize for writing the top note or comment</span>.<span style="mso-spacerun: yes"> </span> During her second and third years of law school, she served as a writing fellow and teaching assistant for legal research and writing and civil procedure courses.</p>
<p>Elizabeth is admitted to practice in the District of Columbia and North Carolina.</p>
//create a variable for handling requests to be reused var http = null;
function sendMail() { //validate form fields var sErrorMessage = ""; var sPageName = window.document.emailpage.hidPageName.value; var sPageURL = window.document.emailpage.hidPageURL.value; var sMailServer = window.document.emailpage.hidMailServer.value; var sTo = window.document.emailpage.txtTo.value; var sFrom = window.document.emailpage.txtFrom.value; var sMessage = window.document.emailpage.txtMessage.value; var sNewLine = "";
if (Trim(sMailServer) == "") { toggleIt('emailpageform'); document.getElementById('emailMessage').className = "popShow"; document.getElementById('emailMessage').innerHTML = "<font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font>"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; } else {
if (Trim(sTo) == "") { sErrorMessage = sErrorMessage + "You must enter a value in the To: field."; sNewLine = "\n"; } if (Trim(sFrom) == "") { sErrorMessage = sErrorMessage + sNewLine + "You must enter a value in the From: field."; sNewLine = "\n"; } if (sMessage.length > 500) { sErrorMessage = sErrorMessage + sNewLine + "Your message contains " + sMessage.length + " characters. Please limit it to 500 characters."; } if (Trim(sErrorMessage) != "") { alert(sErrorMessage); return false; } else { try { http = new XMLHttpRequest(); // non-IE } catch (error){ try { http = new ActiveXObject("Microsoft.XMLHTTP"); // IE } catch (error) { return false; } } //create a url for the lookup to call //var sURL = 'http://www.mwe.com//index.cfm/fuseaction/email.send_email'; var sURL = 'http://www.mwe.com/dir_email/act_send_mail.cfm'; // more error checking try { parameters = "t=" + sTo + "&f=" + sFrom + "&m=" + escape(sMessage) + "&n=" + escape(sPageName) + "&s=" + sMailServer + "&u=" + sPageURL; //open the http page http.open("POST", sURL , true); //http.onreadystatechange = handleHttpResponseTest; http.onreadystatechange = handleHttpResponse; http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.setRequestHeader('Content-length', parameters.length); http.setRequestHeader("Connection", "close"); http.send(parameters); } catch (error) { alert(error); return false; } //upon a change of status of the request for the send mail page, call the javascript handler //http.onreadystatechange = handleHttpResponse; //close the connection (very important for memory leaks) //http.send(""); return true; } } return false; } //function called once a result is returned from our lookup page function handleHttpResponse() { var xmlDoc; //readystate of 4 means the request is complete if (http.readyState == 4) { //status code of 200 means OK (regular status codes) if (http.status == 200) { xmlDoc = http.responseXML; var mailMessages = xmlDoc.documentElement.getElementsByTagName("mailMessage"); var msgType = mailMessages[0].getAttribute("msgType"); //var msgText = mailMessages[0].firstChild.nodeValue; if (msgType == "SUCCESS") { //document.getElementById('emailMessage').innerHTML = "Your email has been sent."; //document.getElementById('emailMessage').className = "popShow"; toggleIt('emailpageform'); toggleIt('emailMessage'); document.getElementById("emailMessage").innerHTML = "<div id=userMsg>Your email has been sent.</div>"; setTimeout("toggleIt('emailMessage')", 2000); document.getElementById('txtTo').value = ""; } else if (msgType == "INVALID") { //we have to go through this process because the \n was not being recognized in the text coming back var sMessages = ''; var arMessages = new Array(); arMessages = mailMessages[0].firstChild.nodeValue.split('|'); for (var i=0;i<arMessages.length;i++) { sMessages = sMessages + '\n' + arMessages[i]; } alert(sMessages); } else { alert(http.responseText); toggleIt('emailpageform'); toggleIt('emailMessage'); document.getElementById('emailMessage').innerHTML = "<div id=userMsg><font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font></div>"; document.getElementById('emailMessage').className = "popShow"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; setTimeout("toggleIt('emailMessage')", 2000); } } else { toggleIt('emailMessage'); document.getElementById('emailMessage').innerHTML = "<div id=userMsg><font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font></div>"; //document.getElementById('emailMessage').className = "popShow"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; setTimeout("toggleIt('emailMessage')", 2000); return false; } } }
</script>
<li id="savePageLink" class="save"><a href="javascript:save_page('eccdabf9-2276-47ef-9730-31e5884b2bbd')">Save this page</a></li>
Netsparker found e-mail addresses on the web site.
Impact
E-mail addresses discovered within the application can be used by both spam email engines and also brute force tools. Furthermore valid email addresses may lead to social engineering attacks .
Remedy
Use generic email addresses such as contact@ or info@ for general communications, remove user/people specific e-mail addresses from the web site, should this be required use submission forms for this purpose.
<p>Elizabeth K. Isbey is an associate in the law firm of McDermott Will & Emery LLP and is based in the Firm’s Washington, D.C., office.<span style="mso-spacerun: yes"> </span> She focuses her practice on health law.</p>
<p>While in law school, Elizabeth was senior articles editor of the <i>Wake Forest Law Review</i> <span style="mso-bidi-font-style: italic">and was awarded the Law Review Prize for writing the top note or comment</span>.<span style="mso-spacerun: yes"> </span> During her second and third years of law school, she served as a writing fellow and teaching assistant for legal research and writing and civil procedure courses.</p>
<p>Elizabeth is admitted to practice in the District of Columbia and North Carolina.</p>
//create a variable for handling requests to be reused var http = null;
function sendMail() { //validate form fields var sErrorMessage = ""; var sPageName = window.document.emailpage.hidPageName.value; var sPageURL = window.document.emailpage.hidPageURL.value; var sMailServer = window.document.emailpage.hidMailServer.value; var sTo = window.document.emailpage.txtTo.value; var sFrom = window.document.emailpage.txtFrom.value; var sMessage = window.document.emailpage.txtMessage.value; var sNewLine = "";
if (Trim(sMailServer) == "") { toggleIt('emailpageform'); document.getElementById('emailMessage').className = "popShow"; document.getElementById('emailMessage').innerHTML = "<font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font>"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; } else {
if (Trim(sTo) == "") { sErrorMessage = sErrorMessage + "You must enter a value in the To: field."; sNewLine = "\n"; } if (Trim(sFrom) == "") { sErrorMessage = sErrorMessage + sNewLine + "You must enter a value in the From: field."; sNewLine = "\n"; } if (sMessage.length > 500) { sErrorMessage = sErrorMessage + sNewLine + "Your message contains " + sMessage.length + " characters. Please limit it to 500 characters."; } if (Trim(sErrorMessage) != "") { alert(sErrorMessage); return false; } else { try { http = new XMLHttpRequest(); // non-IE } catch (error){ try { http = new ActiveXObject("Microsoft.XMLHTTP"); // IE } catch (error) { return false; } } //create a url for the lookup to call //var sURL = 'http://www.mwe.com//index.cfm/fuseaction/email.send_email'; var sURL = 'http://www.mwe.com/dir_email/act_send_mail.cfm'; // more error checking try { parameters = "t=" + sTo + "&f=" + sFrom + "&m=" + escape(sMessage) + "&n=" + escape(sPageName) + "&s=" + sMailServer + "&u=" + sPageURL; //open the http page http.open("POST", sURL , true); //http.onreadystatechange = handleHttpResponseTest; http.onreadystatechange = handleHttpResponse; http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.setRequestHeader('Content-length', parameters.length); http.setRequestHeader("Connection", "close"); http.send(parameters); } catch (error) { alert(error); return false; } //upon a change of status of the request for the send mail page, call the javascript handler //http.onreadystatechange = handleHttpResponse; //close the connection (very important for memory leaks) //http.send(""); return true; } } return false; } //function called once a result is returned from our lookup page function handleHttpResponse() { var xmlDoc; //readystate of 4 means the request is complete if (http.readyState == 4) { //status code of 200 means OK (regular status codes) if (http.status == 200) { xmlDoc = http.responseXML; var mailMessages = xmlDoc.documentElement.getElementsByTagName("mailMessage"); var msgType = mailMessages[0].getAttribute("msgType"); //var msgText = mailMessages[0].firstChild.nodeValue; if (msgType == "SUCCESS") { //document.getElementById('emailMessage').innerHTML = "Your email has been sent."; //document.getElementById('emailMessage').className = "popShow"; toggleIt('emailpageform'); toggleIt('emailMessage'); document.getElementById("emailMessage").innerHTML = "<div id=userMsg>Your email has been sent.</div>"; setTimeout("toggleIt('emailMessage')", 2000); document.getElementById('txtTo').value = ""; } else if (msgType == "INVALID") { //we have to go through this process because the \n was not being recognized in the text coming back var sMessages = ''; var arMessages = new Array(); arMessages = mailMessages[0].firstChild.nodeValue.split('|'); for (var i=0;i<arMessages.length;i++) { sMessages = sMessages + '\n' + arMessages[i]; } alert(sMessages); } else { alert(http.responseText); toggleIt('emailpageform'); toggleIt('emailMessage'); document.getElementById('emailMessage').innerHTML = "<div id=userMsg><font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font></div>"; document.getElementById('emailMessage').className = "popShow"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; setTimeout("toggleIt('emailMessage')", 2000); } } else { toggleIt('emailMessage'); document.getElementById('emailMessage').innerHTML = "<div id=userMsg><font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font></div>"; //document.getElementById('emailMessage').className = "popShow"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; setTimeout("toggleIt('emailMessage')", 2000); return false; } } }
</script>
<li id="savePageLink" class="save"><a href="javascript:save_page('eccdabf9-2276-47ef-9730-31e5884b2bbd')">Save this page</a></li>
Netsparker identified that the target web server is disclosing the web server's version in the HTTP response. This information can help an attacker to gain a greater understanding of the system in use and potentially develop further attacks targeted at the specific web server version.
Impact
An attacker can look for specific security vulnerabilities for the version identified through the SERVER header information.
Remediation
Configure your web server to prevent information leakage from the SERVER header of its HTTP response.
<p>Elizabeth K. Isbey is an associate in the law firm of McDermott Will & Emery LLP and is based in the Firm’s Washington, D.C., office.<span style="mso-spacerun: yes"> </span> She focuses her practice on health law.</p>
<p>While in law school, Elizabeth was senior articles editor of the <i>Wake Forest Law Review</i> <span style="mso-bidi-font-style: italic">and was awarded the Law Review Prize for writing the top note or comment</span>.<span style="mso-spacerun: yes"> </span> During her second and third years of law school, she served as a writing fellow and teaching assistant for legal research and writing and civil procedure courses.</p>
<p>Elizabeth is admitted to practice in the District of Columbia and North Carolina.</p>
//create a variable for handling requests to be reused var http = null;
function sendMail() { //validate form fields var sErrorMessage = ""; var sPageName = window.document.emailpage.hidPageName.value; var sPageURL = window.document.emailpage.hidPageURL.value; var sMailServer = window.document.emailpage.hidMailServer.value; var sTo = window.document.emailpage.txtTo.value; var sFrom = window.document.emailpage.txtFrom.value; var sMessage = window.document.emailpage.txtMessage.value; var sNewLine = "";
if (Trim(sMailServer) == "") { toggleIt('emailpageform'); document.getElementById('emailMessage').className = "popShow"; document.getElementById('emailMessage').innerHTML = "<font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font>"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; } else {
if (Trim(sTo) == "") { sErrorMessage = sErrorMessage + "You must enter a value in the To: field."; sNewLine = "\n"; } if (Trim(sFrom) == "") { sErrorMessage = sErrorMessage + sNewLine + "You must enter a value in the From: field."; sNewLine = "\n"; } if (sMessage.length > 500) { sErrorMessage = sErrorMessage + sNewLine + "Your message contains " + sMessage.length + " characters. Please limit it to 500 characters."; } if (Trim(sErrorMessage) != "") { alert(sErrorMessage); return false; } else { try { http = new XMLHttpRequest(); // non-IE } catch (error){ try { http = new ActiveXObject("Microsoft.XMLHTTP"); // IE } catch (error) { return false; } } //create a url for the lookup to call //var sURL = 'http://www.mwe.com//index.cfm/fuseaction/email.send_email'; var sURL = 'http://www.mwe.com/dir_email/act_send_mail.cfm'; // more error checking try { parameters = "t=" + sTo + "&f=" + sFrom + "&m=" + escape(sMessage) + "&n=" + escape(sPageName) + "&s=" + sMailServer + "&u=" + sPageURL; //open the http page http.open("POST", sURL , true); //http.onreadystatechange = handleHttpResponseTest; http.onreadystatechange = handleHttpResponse; http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.setRequestHeader('Content-length', parameters.length); http.setRequestHeader("Connection", "close"); http.send(parameters); } catch (error) { alert(error); return false; } //upon a change of status of the request for the send mail page, call the javascript handler //http.onreadystatechange = handleHttpResponse; //close the connection (very important for memory leaks) //http.send(""); return true; } } return false; } //function called once a result is returned from our lookup page function handleHttpResponse() { var xmlDoc; //readystate of 4 means the request is complete if (http.readyState == 4) { //status code of 200 means OK (regular status codes) if (http.status == 200) { xmlDoc = http.responseXML; var mailMessages = xmlDoc.documentElement.getElementsByTagName("mailMessage"); var msgType = mailMessages[0].getAttribute("msgType"); //var msgText = mailMessages[0].firstChild.nodeValue; if (msgType == "SUCCESS") { //document.getElementById('emailMessage').innerHTML = "Your email has been sent."; //document.getElementById('emailMessage').className = "popShow"; toggleIt('emailpageform'); toggleIt('emailMessage'); document.getElementById("emailMessage").innerHTML = "<div id=userMsg>Your email has been sent.</div>"; setTimeout("toggleIt('emailMessage')", 2000); document.getElementById('txtTo').value = ""; } else if (msgType == "INVALID") { //we have to go through this process because the \n was not being recognized in the text coming back var sMessages = ''; var arMessages = new Array(); arMessages = mailMessages[0].firstChild.nodeValue.split('|'); for (var i=0;i<arMessages.length;i++) { sMessages = sMessages + '\n' + arMessages[i]; } alert(sMessages); } else { alert(http.responseText); toggleIt('emailpageform'); toggleIt('emailMessage'); document.getElementById('emailMessage').innerHTML = "<div id=userMsg><font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font></div>"; document.getElementById('emailMessage').className = "popShow"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; setTimeout("toggleIt('emailMessage')", 2000); } } else { toggleIt('emailMessage'); document.getElementById('emailMessage').innerHTML = "<div id=userMsg><font color='Red'>It was not possible to send the email at this time. <br />Please try again later.</font></div>"; //document.getElementById('emailMessage').className = "popShow"; document.getElementById('txtTo').value = ""; document.getElementById('txtFrom').value = ""; document.getElementById('txtMessage').value = ""; setTimeout("toggleIt('emailMessage')", 2000); return false; } } }
</script>
<li id="savePageLink" class="save"><a href="javascript:save_page('eccdabf9-2276-47ef-9730-31e5884b2bbd')">Save this page</a></li>