<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hacking-Gurus &#187; Critical Web</title>
	<atom:link href="http://www.hacking-gurus.net/tag/critical-web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hacking-gurus.net</link>
	<description>Security Blog</description>
	<lastBuildDate>Thu, 19 Jan 2012 21:06:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>The Top 10 Web Application security vulnerabilities</title>
		<link>http://www.hacking-gurus.net/2009/09/30/the-top-10-web-application-security-vulnerabilities/</link>
		<comments>http://www.hacking-gurus.net/2009/09/30/the-top-10-web-application-security-vulnerabilities/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 05:24:02 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tutorialz]]></category>
		<category><![CDATA[Website Security]]></category>
		<category><![CDATA[Common Security]]></category>
		<category><![CDATA[Critical Web]]></category>
		<category><![CDATA[Cyber Security]]></category>
		<category><![CDATA[Example Web]]></category>
		<category><![CDATA[Html Page]]></category>
		<category><![CDATA[Input Data]]></category>
		<category><![CDATA[Open Web]]></category>
		<category><![CDATA[Owasp]]></category>
		<category><![CDATA[Proper Html]]></category>
		<category><![CDATA[Query Parameters]]></category>
		<category><![CDATA[Security Problems]]></category>
		<category><![CDATA[Security Project]]></category>
		<category><![CDATA[Security Vulnerabilities]]></category>
		<category><![CDATA[Swingset]]></category>
		<category><![CDATA[Top Ten Security]]></category>
		<category><![CDATA[Web Application Security]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Webgoat]]></category>
		<category><![CDATA[Writeln]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=164</guid>
		<description><![CDATA[The Top 10 Web Application security vulnerabilities This and the next series of blog entries will highlight the Top 10 most critical web application security vulnerabilities identified by the Open Web Application Security Project (OWASP). You can use OWASP&#8217;s WebGoat to learn more about the OWASP Top Ten security vulnerabilties. WebGoat is an example web application, which has [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2009/09/30/the-top-10-web-application-security-vulnerabilities/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "The+Top+10+Web+Application+security+vulnerabilities";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "The Top 10 Web Application security vulnerabilitiesThis and the next series of blog entries will highlight the Top 10 most critical web application security vulnerabilities identified by the Open Web Application Security Project (OWASP).You can use OWASP&#8217;s WebGoat to learn more about the OWASP Top Ten security vulnerabilties. WebGoat is an...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;">The Top 10 Web Application security vulnerabilities<br />
<span id="more-164"></span></p>
<h1></h1>
<p>This and the next series of blog entries will highlight the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project" target="_blank">Top 10 most critical web application security vulnerabilities</a> identified by the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Main_Page" target="_blank">Open Web Application Security Project (OWASP)</a>.</p>
<p>You can use OWASP&#8217;s <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_WebGoat_Project" target="_blank">WebGoat</a> to learn more about the OWASP Top Ten security vulnerabilties. WebGoat is an example web application, which has lessons showing &#8220;what not to do code&#8221;, how to exploit the code, and corrected code for each vulnerability.</p>
<p><img style="width: 300px; height: 252px;" src="http://blogs.sun.com/carolmcdonald/resource/300px-WebGoat-Phishing-XSS-Lesson.JPG" alt="" /></p>
<p>You can use the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API" target="_blank">OWASP Enterprise Security API </a>Toolkit to protect against the OWASP Top Ten security vulnerabilties.</p>
<p><img style="width: 550px; height: 314px;" src="http://blogs.sun.com/carolmcdonald/resource/550px-Esapi-before-after.JPG" alt="" /></p>
<p><a style="color: #2244bb;" href="http://www.owasp.org/index.php/ESAPI_Swingset" target="_blank">The ESAPI Swingset </a>is a web application which demonstrates the many uses of the Enterprise Security API.</p>
<p><img style="width: 352px; height: 325px;" src="http://blogs.sun.com/carolmcdonald/resource/swingset.jpg" alt="" /></p>
<h2>OWASP Top 10 number 1: XSS = Cross Site Scripting</h2>
<p>Cross Site Scripting (XSS) is one of the most common security problems in today&#8217;s web applications. According to the <a style="color: #2244bb;" href="http://www.sans.org/top-cyber-security-risks/" target="_blank">SANS Top Cyber Security Risks</a>, 60% of the total attack attempts observed on the Internet are against Web applications and SQL injection and Cross-Site Scripting account for more than 80% of the vulnerabilities being discovered. You are at risk of an XSS attack any time you put content that could contain scripts from someone un-trusted into your web pages.<br />
There are 3 types of cross site scripting:</p>
<ul>
<li><span style="font-weight: bold;">Reflected XSS: </span>is when an html page reflects user input data, e.g. from HTTP query parameters or a HTML form, back to the browser, without properly sanitizing the response. Below is an example of this in a servlet:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;"> out.writeln(“You searched for: “+request.getParameter(“query”);</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li></li>
<li><span style="font-weight: bold;">Stored XSS:</span> is when an Attacker’s input script is stored on the server (eg a database) and later displayed in the web server html pages, without proper HTML filtering. Examples of this are in blogs, or forums where users can input data that will be displayed to others. Below is an example of this in a servlet data is retrieved from the database and returned in the HTML page without any validation:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">out.writeln("&lt;tr&gt;&lt;td&gt;" + guest.name + "&lt;td&gt;" + guest.comment);</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li></li>
<li><span style="font-weight: bold;">DOM XSS</span>: is when JavaScript uses input data or data from the server to write dynamic HTML (DOM) elements, again without HTML sanitizing/escaping/filtering.</li>
</ul>
<p>XSS can be used to:</p>
<ul>
<li>deface web pages</li>
<li>hijack user sessions</li>
<li>conduct phishing attacks</li>
<li>execute malicious code in the context of the user&#8217;s session</li>
<li>spread malware</li>
</ul>
<h3>Protecting against XSS</h3>
<p>To protect against XSS all the parameters in the application should be validated and/or encoded before being output in HTML pages.</p>
<ul>
<li>Always validate on the server side for data integrity and security:
<ul>
<li>Validate all input data to the application:</li>
<li>Validate for type, format, length, range, and context before storing or displaying</li>
<li>Use white-listing (what is allowed), reject if invalid, instead of filtering out black-list (what is not allowed)</li>
</ul>
</li>
<li>Output encoding:
<ul>
<li>Explicitly set character encoding for all web pages (ISO-8859-1 or UTF 8):<br />
<span style="font-family: monospace;">&lt;%@ page contentType=&#8221;text/html;charset=ISO-8859-1&#8243; language=&#8221;java&#8221; %&gt;</span></li>
<li>all user supplied data should be HTML or XML entity encoded before rendering</li>
</ul>
</li>
</ul>
<h3>Java specific Protecting against XSS</h3>
<h4>Validating Input with Java</h4>
<ul>
<li>You can use Java regular expressions to validate input, this example from WebGoat allows whitespace, a-zA-Z_0-9, and the characters &#8211; and ,</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">
String regex = "[\s\w-,]*";
Pattern pattern = Pattern.compile(regex);
validate(stringToValidate, pattern);</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li></li>
<li>Use Framework (Struts, JSF, Spring&#8230;) validators. With Java EE 6 you can use the Bean Validation Framework to centrally define validation constraints on model objects and with JSF 2.0 to extend model validation to the UI. For example here is a JSF 2.0 input field:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">&lt;h:inputText id="creditCard" value="#{booking.creditCardNumber}"/&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li><span style="font-weight: bold;"> </span>Here is the JSF 2.0 booking Managed Bean using the Bean Validation Framework :</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">@ManagedBean
public class Booking {
 ...
 @NotNull(message = "Credit card number is required")
 @Size(min = 16, max = 16,
 message = "Credit card number must 16 digits long")
 @Pattern(regexp = "^\d*$",
 message = "Credit card number must be numeric")
 public String getCreditCardNumber() {
 return creditCardNumber;
 }
}</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li>In addition there are new JSF 2.0 Validators:
<ul>
<li><a style="color: #2244bb;" href="https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/f/validateBean.html" target="_blank">&lt;f:validateBean&gt;</a> is a validator that delegates the validation of the local value to the Bean Validation API.</li>
<li>&lt;f:validateRequired&gt; provides required field validation.</li>
<li><a style="color: #2244bb;" href="https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/f/validateRegex.html" target="_blank">&lt;f:validateRegexp&gt;</a> provides regular expression-based validation</li>
</ul>
</li>
<li>Use the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API" target="_blank">OWASP Enterprise Security API</a> Java Toolkit&#8217;s Validator interface:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td>
<pre style="font-size: 11px;">ESAPI.validator().getValidInput(String context,String input,String type,int maxLength,
   boolean allowNull,ValidationErrorList errorList)</pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, sans-serif; line-height: normal; border-collapse: collapse;"></p>
<ul>
<li><span style="font-family: monospace;">ESAPI.validator().getValidInput() </span>returns canonicalized and validated input as a String. Invalid input will generate a descriptive ValidationErrorList, and input that is clearly an attack will generate a descriptive IntrusionException.</li>
</ul>
<h4>Output Encoding with Java</h4>
<ul>
<li>You can use Struts output mechanisms such as <span style="font-family: monospace;">&lt;bean:write… &gt;, </span>or use the default JSTL<span style="font-family: monospace;">escapeXML=&#8221;true&#8221;</span> attribute in <span style="font-family: monospace;">&lt;c:out … &gt; </span></li>
<li>You can use the <a style="color: #2244bb;" href="http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API" target="_blank">OWASP Enterprise Security API</a> Java Toolkit&#8217;s <span style="font-family: monospace;">ESAPI Encoder.encodeForHTML()</span>method to encode data for use in HTML content. The encodeForHTML() method uses a &#8220;whitelist&#8221; HTML entity encoding algorithm to ensure that encoded data can not be interpreted as script. This call should be used to wrap any user input being rendered in HTML element content. For example:</li>
</ul>
<p></span></p>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tbody>
<tr>
<td><span style="font-family: monospace;">&lt;p&gt;Hello, &lt;%=ESAPI.encoder().encodeForHTML(name)%&gt;&lt;/p&gt;</span></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2009/09/30/the-top-10-web-application-security-vulnerabilities/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

