<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rknell</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rknell"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Rknell"/>
		<updated>2026-05-06T10:06:31Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=21494</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=21494"/>
				<updated>2007-09-06T14:38:18Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: /* Browsers Supporting HTTPOnly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in 2002 by Microsoft Internet Explorer developers for Internet Explorer 6 SP1. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], HTTPOnly is an ''additional flag'' included in a Set-Cookie HTTP response header. Using the HTTPOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script (again if the browser supports this flag). As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser (primarily Internet Explorer) will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the HTTPOnly flag will be ignored by the browser, thus creating a traditional, script accessible cookie. As a result, the cookie (typically your session cookie) becomes vulnerable to theft of modification by malicious script. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks target theft of session cookies. A server could help mitigate this issue by setting the HTTPOnly flag on a cookie it creates, indicating the cookie should not be accessible on the client.&lt;br /&gt;
&lt;br /&gt;
If a browser that supports HTTPOnly detects a cookie containing the HTTPOnly flag, and client side script code attempts to read the cookie, the browser ''returns an empty string'' as the result. This causes the attack to fail by preventing the malicious (usually XSS) code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide a mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using .NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
C# Code:&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
VB.NET Code:&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly support. If the browsers enforces HTTPOnly, a client side script will be unable to read or write the session cookie. However, there is currently no prevention of reading or writing the session cookie via a XMLHTTPRequest. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Reads'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Writes'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents XMLHTTPRequests*'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.6&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b3&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.23&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the ''HTTPOnly flag'' is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly, and you ''enable'' it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=21493</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=21493"/>
				<updated>2007-09-06T14:37:52Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: /* Browsers Supporting HTTPOnly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in 2002 by Microsoft Internet Explorer developers for Internet Explorer 6 SP1. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], HTTPOnly is an ''additional flag'' included in a Set-Cookie HTTP response header. Using the HTTPOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script (again if the browser supports this flag). As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser (primarily Internet Explorer) will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the HTTPOnly flag will be ignored by the browser, thus creating a traditional, script accessible cookie. As a result, the cookie (typically your session cookie) becomes vulnerable to theft of modification by malicious script. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks target theft of session cookies. A server could help mitigate this issue by setting the HTTPOnly flag on a cookie it creates, indicating the cookie should not be accessible on the client.&lt;br /&gt;
&lt;br /&gt;
If a browser that supports HTTPOnly detects a cookie containing the HTTPOnly flag, and client side script code attempts to read the cookie, the browser ''returns an empty string'' as the result. This causes the attack to fail by preventing the malicious (usually XSS) code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide a mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using .NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
C# Code:&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
VB.NET Code:&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly support. If the browsers enforces HTTPOnly, a client side script will be unable to read or write the session cookie. However, there is currently no prevention of reading or writing the session cookie via a XMLHTTPRequest. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Reads'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Writes'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents XMLHTTPRequests*'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.6&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b3&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the ''HTTPOnly flag'' is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly, and you ''enable'' it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=21492</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=21492"/>
				<updated>2007-09-06T14:35:29Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: /* Browsers Supporting HTTPOnly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in 2002 by Microsoft Internet Explorer developers for Internet Explorer 6 SP1. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], HTTPOnly is an ''additional flag'' included in a Set-Cookie HTTP response header. Using the HTTPOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script (again if the browser supports this flag). As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser (primarily Internet Explorer) will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the HTTPOnly flag will be ignored by the browser, thus creating a traditional, script accessible cookie. As a result, the cookie (typically your session cookie) becomes vulnerable to theft of modification by malicious script. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks target theft of session cookies. A server could help mitigate this issue by setting the HTTPOnly flag on a cookie it creates, indicating the cookie should not be accessible on the client.&lt;br /&gt;
&lt;br /&gt;
If a browser that supports HTTPOnly detects a cookie containing the HTTPOnly flag, and client side script code attempts to read the cookie, the browser ''returns an empty string'' as the result. This causes the attack to fail by preventing the malicious (usually XSS) code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide a mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using .NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
C# Code:&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
VB.NET Code:&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly support. If the browsers enforces HTTPOnly, a client side script will be unable to read or write the session cookie. However, there is currently no prevention of reading or writing the session cookie via a XMLHTTPRequest. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Reads'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Writes'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents XMLHTTPRequests*'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.6&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b3&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the ''HTTPOnly flag'' is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly, and you ''enable'' it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=21491</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=21491"/>
				<updated>2007-09-06T14:22:48Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: /* Browsers Supporting HTTPOnly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in 2002 by Microsoft Internet Explorer developers for Internet Explorer 6 SP1. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], HTTPOnly is an ''additional flag'' included in a Set-Cookie HTTP response header. Using the HTTPOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script (again if the browser supports this flag). As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser (primarily Internet Explorer) will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the HTTPOnly flag will be ignored by the browser, thus creating a traditional, script accessible cookie. As a result, the cookie (typically your session cookie) becomes vulnerable to theft of modification by malicious script. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks target theft of session cookies. A server could help mitigate this issue by setting the HTTPOnly flag on a cookie it creates, indicating the cookie should not be accessible on the client.&lt;br /&gt;
&lt;br /&gt;
If a browser that supports HTTPOnly detects a cookie containing the HTTPOnly flag, and client side script code attempts to read the cookie, the browser ''returns an empty string'' as the result. This causes the attack to fail by preventing the malicious (usually XSS) code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide a mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using .NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
C# Code:&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
VB.NET Code:&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly support. If the browsers enforces HTTPOnly, a client side script will be unable to read or write the session cookie. However, there is currently no prevention of reading or writing the session cookie via a XMLHTTPRequest. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Reads'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Writes'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents XMLHTTPRequests*'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.6&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the ''HTTPOnly flag'' is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly, and you ''enable'' it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20948</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20948"/>
				<updated>2007-08-20T13:39:29Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: /* Browsers Supporting HTTPOnly */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in 2002 by Microsoft Internet Explorer developers for Internet Explorer 6 SP1. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], HTTPOnly is an ''additional flag'' included in a Set-Cookie HTTP response header. Using the HTTPOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script (again if the browser supports this flag). As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser (primarily Internet Explorer) will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the HTTPOnly flag will be ignored by the browser, thus creating a traditional, script accessible cookie. As a result, the cookie (typically your session cookie) becomes vulnerable to theft of modification by malicious script. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks target theft of session cookies. A server could help mitigate this issue by setting the HTTPOnly flag on a cookie it creates, indicating the cookie should not be accessible on the client.&lt;br /&gt;
&lt;br /&gt;
If a browser that supports HTTPOnly detects a cookie containing the HTTPOnly flag, and client side script code attempts to read the cookie, the browser ''returns an empty string'' as the result. This causes the attack to fail by preventing the malicious (usually XSS) code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide a mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using .NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
C# Code:&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
VB.NET Code:&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly support. If the browsers enforces HTTPOnly, a client side script will be unable to read or write the session cookie. However, there is currently no prevention of reading or writing the session cookie via a XMLHTTPRequest. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Reads'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents Writes'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Prevents XMLHTTPRequests*'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Yes&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the ''HTTPOnly flag'' is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly, and you ''enable'' it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20730</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20730"/>
				<updated>2007-08-10T20:24:26Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in 2002 by Microsoft Internet Explorer developers for Internet Explorer 6 SP1. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HTTPOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the ''HTTPOnly flag'' is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly, and you ''enable'' it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20729</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20729"/>
				<updated>2007-08-10T20:21:04Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in 2002 by Microsoft Internet Explorer developers for Internet Explorer 6 SP1. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the ''HTTPOnly flag'' is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly, and you ''enable'' it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20553</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20553"/>
				<updated>2007-08-02T13:32:00Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article in 2002 by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the ''HTTPOnly flag'' is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly, and you ''enable'' it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20552</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20552"/>
				<updated>2007-08-02T13:28:50Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article in 2002 by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers supporting HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20551</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20551"/>
				<updated>2007-08-02T13:27:57Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article in 2002 by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have installed and launched WebGoat, begin by navigating to the '''‘HTTPOnly Test’ lesson''' located within the Cross-Site Scripting ('''XSS''') category. After loading the ‘HTTPOnly Test’ lesson, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20550</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20550"/>
				<updated>2007-08-02T13:23:50Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article in 2002 by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20549</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20549"/>
				<updated>2007-08-02T13:17:50Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to a daily blog article in 2002 by Jordan Wiens, “No cookie for you!,” HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20503</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20503"/>
				<updated>2007-07-31T16:29:13Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Added: Safari&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Safari&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 3.0&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20474</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20474"/>
				<updated>2007-07-30T13:51:09Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20308</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20308"/>
				<updated>2007-07-27T18:30:21Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and discuss language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. As a result, your session cookie becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20307</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20307"/>
				<updated>2007-07-27T18:29:27Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and discuss language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. Unfortunately, your session cookie now becomes vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20306</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20306"/>
				<updated>2007-07-27T18:27:30Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and discuss language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The example below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. Unfortunately, this makes your session cookie vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20305</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20305"/>
				<updated>2007-07-27T18:24:10Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and discuss language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The figure below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. Unfortunately, this makes your session cookie vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using Java to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using C#.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Using VB.NET to Set HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20304</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20304"/>
				<updated>2007-07-27T18:20:44Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and discuss language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The figure below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. Unfortunately, this makes your session cookie vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Java: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &lt;br /&gt;
                    &amp;quot;originalcookiename=originalvalue; &lt;br /&gt;
                    HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; C#.NET: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; VB.NET: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20303</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20303"/>
				<updated>2007-07-27T18:19:37Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and discuss language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The figure below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. Unfortunately, this makes your session cookie vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Java: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &amp;quot;originalcookiename=originalvalue; HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; C#.NET: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; VB.NET: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By ''default'', '''.NET 2.0''' sets the HTTPOnly attribute for&lt;br /&gt;
*#Session ID&lt;br /&gt;
*#Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via '''web.config''' in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or '''programmatically'''&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in '''.NET 1.1''', you would have to do this ''manually'', e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20302</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20302"/>
				<updated>2007-07-27T18:10:10Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Updated Overview Section: Added Programming Language Specifics for setting HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce, discuss, and discuss language specific mitigation techniques for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The figure below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. Unfortunately, this makes your session cookie vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Java: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*'''Problem'''&lt;br /&gt;
**Most environments (e.g., Java EE) do not provide mechanism to set the HTTPOnly flag&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
 response.setHeader(&amp;quot;Set-Cookie&amp;quot;, &amp;quot;originalcookiename=originalvalue; HTTPOnly=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
'''Note''': This works OK for custom cookies, but the JSESSIONID is created and handled by the Java EE container, so you really cannot override the framework to add HTTPOnly to JSESSIONID&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; C#.NET: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By default, .NET 2.0 sets the HTTPOnly attribute for&lt;br /&gt;
**Session ID&lt;br /&gt;
**Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
*In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
*Via web.config in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or programmatically&lt;br /&gt;
 HttpCookie myCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;);&lt;br /&gt;
 myCookie.HttpOnly = true;&lt;br /&gt;
 Response.AppendCookie(myCookie);&lt;br /&gt;
&lt;br /&gt;
*However, in .NET 1.1, you’d have to do this manually, e.g.,&lt;br /&gt;
 Response.Cookies[cookie].Path += &amp;quot;;HTTPOnly&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; VB.NET: Setting HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*By default, .NET 2.0 sets the HTTPOnly attribute for&lt;br /&gt;
**Session ID&lt;br /&gt;
**Forms Authentication cookie&lt;br /&gt;
&lt;br /&gt;
*In .NET 2.0, HTTPOnly can also be set via the HttpCookie object for all custom application cookies&lt;br /&gt;
**Via web.config in the system.web/httpCookies element&lt;br /&gt;
 &amp;lt;httpCookies httpOnlyCookies=&amp;quot;true&amp;quot; …&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Or programmatically&lt;br /&gt;
 Dim myCookie As HttpCookie = new HttpCookie(&amp;quot;myCookie&amp;quot;)&lt;br /&gt;
 myCookie.HttpOnly = True&lt;br /&gt;
 Response.AppendCookie(myCookie)&lt;br /&gt;
&lt;br /&gt;
*However, in .NET 1.1, you would have to do this manually, e.g.,&lt;br /&gt;
 Response.Cookies(cookie).Path &amp;amp;= &amp;quot;;HTTPOnly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Support ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to provide a step-by-step example of testing your browser for HTTPOnly support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Stinger_3_Ideas&amp;diff=20296</id>
		<title>OWASP Stinger 3 Ideas</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Stinger_3_Ideas&amp;diff=20296"/>
				<updated>2007-07-27T17:43:44Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Linked keyword: HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Stinger 3.x series will be heavily driven by the community. Everyone is encouraged to contribute ideas and suggestions to make Stinger 3.x the most powerful and flexible web application firewall as possible. One major goal of the OWASP Stinger 3.x series is to develop a solid and flexible validation engine capable of implementing common web application security features.. With the help of the community, I believe this goal can be achieved!&lt;br /&gt;
&lt;br /&gt;
==Development Complete==&lt;br /&gt;
&lt;br /&gt;
The following is a list of ideas that have been fully implemented in the Stinger 3.x baseline:&lt;br /&gt;
&lt;br /&gt;
:*  Validation of the entire HTTP request: including URI, headers, cookies, and parameters&lt;br /&gt;
:* A robust &amp;quot;learning&amp;quot; mode to make rule generation simplistic and efficient.&lt;br /&gt;
:* A more flexible &amp;quot;Action&amp;quot; framework. Actions will be able to execute logic before and/or after the request is processed by the web application&lt;br /&gt;
&lt;br /&gt;
==Under Development==&lt;br /&gt;
&lt;br /&gt;
The following is a list of ideas currently under development in the Stinger 3.x baseline:&lt;br /&gt;
&lt;br /&gt;
:* The ability to enforce web application firewall logic&lt;br /&gt;
::* Defining and enforcing URI level access control&lt;br /&gt;
::* Cross Site Request Forgery Guard&lt;br /&gt;
::* HTTP Cookie Guard&lt;br /&gt;
::* No-Cache Guard&lt;br /&gt;
::* 200 Response Codes (fooling web application scanners)&lt;br /&gt;
::* Request Rate Throttler&lt;br /&gt;
::* Enforce [[HTTPOnly]] on all cookies&lt;br /&gt;
&lt;br /&gt;
==Planning to Develop==&lt;br /&gt;
&lt;br /&gt;
The following is a list of ideas that will be integrated into the Stinger 3.x baseline:&lt;br /&gt;
&lt;br /&gt;
:* A full web application dedicated to editing the OWASP Stinger configuration files&lt;br /&gt;
&lt;br /&gt;
==Ideas Under Consideration==&lt;br /&gt;
&lt;br /&gt;
The following is a list of ideas that are under consideration for the Stinger 3.x baseline:&lt;br /&gt;
&lt;br /&gt;
:* The ability to validate the Java properties files used by the web application&lt;br /&gt;
:* The ability to to build rules for and validate rules against serialized objects&lt;br /&gt;
&lt;br /&gt;
If you have an idea that you would like seen in Stinger 3.x, please email me at [mailto:eric.sheridan@owasp.org eric dot sheridan at owasp.org]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Testing_for_Cross_site_scripting&amp;diff=20295</id>
		<title>Talk:Testing for Cross site scripting</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Testing_for_Cross_site_scripting&amp;diff=20295"/>
				<updated>2007-07-27T17:42:08Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Linked keyword: HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(Meucci) NOTE: We can add this recommendations in the OWASP Guide. Are you agree?&lt;br /&gt;
&lt;br /&gt;
The following general recommendations can help mitigate the risk associated with Cross-Site Scripting vulnerabilities. This is a complex problem area &lt;br /&gt;
&lt;br /&gt;
so there is no one simple fix or solution:&lt;br /&gt;
* Ensure that your web application validates all forms, headers, cookie fields, hidden fields, and parameters, and converts scripts and script tags &lt;br /&gt;
&lt;br /&gt;
to a non-executable form.&lt;br /&gt;
* Ensure that any executables on your server do not return scripts in executable form when passed scripts as malformed command parameters.&lt;br /&gt;
* Consider converting JavaScript and HTML tags into alternate HTML encodings (such as “&amp;lt;” to “&amp;amp;lt;&amp;gt;.&lt;br /&gt;
* If your site runs online forums or message boards, disallow the use of HTML tags and Scripting in these areas.&lt;br /&gt;
* Keep up with the latest security vulnerabilities and bugs for all production applications and servers.&lt;br /&gt;
* Update your production servers with the latest XSS vulnerabilities by downloading current patches, and perform frequent security audits on all &lt;br /&gt;
&lt;br /&gt;
deployed applications.&lt;br /&gt;
The root cause of Cross-Site Scripting is a failure to filter hazardous characters from web application input and output. The two most critical &lt;br /&gt;
&lt;br /&gt;
programming practices you can institute to guard against Cross-Site Scripting are:&lt;br /&gt;
* Validate Input&lt;br /&gt;
* Encode output&lt;br /&gt;
Always filter data originating from outside your application by disallowing the use of special characters. Only display output to the browser that &lt;br /&gt;
&lt;br /&gt;
has been sufficiently encoded. When possible, avoid simple character filters and write routines that validate user input against a set of allowed, &lt;br /&gt;
&lt;br /&gt;
safe characters. Use regular expressions to confirm that data conforms to the allowed character set. This enhances application security and makes it &lt;br /&gt;
&lt;br /&gt;
harder to bypass input validation routines.&lt;br /&gt;
There are different tools you can use to validate and encode your data, depending upon your development environment. Your goal in remediating &lt;br /&gt;
&lt;br /&gt;
Cross-Site Scripting attacks is to filter and encode all potentially dangerous characters so that the application does not return data that the &lt;br /&gt;
&lt;br /&gt;
browser will interpret as executable.  Any unescaped or unecoded data that is returned to the browser is a potential security risk.&lt;br /&gt;
The following characters can be harmful and should be filtered whenever they appear in the application input or output. In output, you should &lt;br /&gt;
&lt;br /&gt;
translate these characters to their HTML equivalents before returning data to the browser.&amp;lt;BR&amp;gt;&lt;br /&gt;
'''&amp;gt;     &amp;lt;   (     )     [     ]     '     &amp;quot;     ;     :     /     |'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;PHP&amp;lt;/b&amp;gt;&lt;br /&gt;
The following PHP functions help mitigate Cross-Site Scripting Vulnerabilities:&lt;br /&gt;
* '''Strip_tags()''' removes HTML and PHP scripting tags from a string.&lt;br /&gt;
* '''Utf8_decode()''' converts UTF-8 encoding to single byte ASCII characters. Decoding Unicode input prior to filtering it can help you detect &lt;br /&gt;
&lt;br /&gt;
attacks that the attacker has obfuscated with Unicode encoding.&lt;br /&gt;
* '''Htmlspecialcharacters()''' turns characters such as '''&amp;amp;,&amp;gt;,&amp;lt;,”''' into their HTML equivalents. Converting special characters to HTML prevents &lt;br /&gt;
&lt;br /&gt;
them from being executed within browsers when outputted by an application.&lt;br /&gt;
* '''Strtr()''' filters any characters you specify. Make sure to filter  “; : ( )” characters so that attackers cannot craft strings that generate &lt;br /&gt;
&lt;br /&gt;
alerts. Many XSS attacks are possible without the use of HTML characters, so filtering and encoding parentheses mitigates these attacks.&amp;lt;BR&amp;gt;For &lt;br /&gt;
&lt;br /&gt;
example:&lt;br /&gt;
'''&amp;quot; style=&amp;quot;background:url(JavaScript:alert(Malicious Content));'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ASP.NET&amp;lt;/b&amp;gt;&lt;br /&gt;
With ASP.NET, you can use the following functions to help prevent Cross-Site Scripting:&lt;br /&gt;
* Constrain input submitted via server controls by using ASP.NET validater controls, such as '''RegularExpressionValidator''', '''RangeValidator''', &lt;br /&gt;
&lt;br /&gt;
and '''System.Text.RegularExpression.Regex'''. Using these methods as server-side controls to limit data input to only allowable character sequences &lt;br /&gt;
&lt;br /&gt;
by validating input type, length, format, and character range.&lt;br /&gt;
* Use the '''HtmlUtility.HtmlEncode''' method to encode data if it originates from either a user or from a database. HtmlEncode replaces special &lt;br /&gt;
&lt;br /&gt;
characters with their HTML equivalents, thus preventing the output from being executable in the browser. Use HtmlUtility.UrlEncode when writing URLs &lt;br /&gt;
&lt;br /&gt;
that may have originated from user input or stored database information.&lt;br /&gt;
* Use the '''[[HTTPOnly]] cookie''' option for added protection.&lt;br /&gt;
* As a best practice, you should use regular expressions to constrain input to known safe characters. Do not rely solely on ASP.NET validateRequest, &lt;br /&gt;
&lt;br /&gt;
but use it in addition to your other input validation and encoding mechanisms.&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Kansas_City_June_2007_Meeting&amp;diff=20294</id>
		<title>Kansas City June 2007 Meeting</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Kansas_City_June_2007_Meeting&amp;diff=20294"/>
				<updated>2007-07-27T17:40:56Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Linked keyword: HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The OWASP [[Kansas City|Kansas City chapter]] meeting in June 2007 was held from 6:30 to 8:30 pm on 6/13/2007.  The location of the meeting was at the offices of FishNet Security at 1627 Main Street in Kansas City, MO.&lt;br /&gt;
&lt;br /&gt;
=== Meeting Summary ===&lt;br /&gt;
&lt;br /&gt;
Dave Ferguson of FishNet Security started the meeting with a welcome and overview of OWASP.  Attendee Rohini Sulatycki briefly described the new OWASP AJAX project, for which she is the project leader.  Next, Dave Ferguson announced that he would be stepping down as the OWASP Kansas City chapter leader due to the fact that he is relocating to the Dallas, TX area.  A search for a new chapter leader will begin.&lt;br /&gt;
&lt;br /&gt;
Our first speaker was Jake Reynolds from FishNet Security.  Jake described more than a dozen different Firefox extensions that involve some aspect of web application security.  Some, such as TamperData and Web Developer, provide useful functionality for auditing/assessing the security of an application.  Others, such as [[HTTPOnly]] and NoScript, are specialized extensions that can keep you safer when surfing the Internet.&lt;br /&gt;
&lt;br /&gt;
Following a break, Barry Archer from American Century Investments presented on the topic of web application firewalls.  Specifically, Barry talked about his experience with evaluating mod_security for Apache and a particular commercial WAF product.  Issues such as negative vs. positive security models, the importance of having a well-designed log format, and how to handle updates to an application were discussed.   Barry also explained why you need to understand HTTP in order to properly &amp;quot;tune&amp;quot; a WAF.&lt;br /&gt;
&lt;br /&gt;
=== Documents ===&lt;br /&gt;
[[Media:KC_June_2007_Firefox_as_AppSec_Tool.zip|Firefox as a Web Application Security Assessment Tool]] (ppt within a zip)&amp;lt;br/&amp;gt;&lt;br /&gt;
[[Media:KC_June_2007_Evaluating_and_Tuning_WAFs.pdf|Evaluating and Tuning Web Application Firewalls]] (pdf)&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=20293</id>
		<title>Searching for Code in J2EE/Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=20293"/>
				<updated>2007-07-27T17:39:17Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Searching for key indicators ==&lt;br /&gt;
The basis of the code review is to locate and analyse areas of code which may have application security implications.&lt;br /&gt;
Assuming the code reviewer has a thorough understanding of the code, what it is intended to do and the context upon which it is to be used, firstly one needs to sweep the code base for areas of interest.&lt;br /&gt;
&lt;br /&gt;
This can be done by performing a text search on the code base looking for keywords relating to API's and functions.&lt;br /&gt;
Below is a guide for .NET framework 1.1 &amp;amp; 2.0&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in .NET ===&lt;br /&gt;
&lt;br /&gt;
Firstly one needs to be familiar with the tools one can use in order to perform text searching following on from this one need to know what to look for.&lt;br /&gt;
 &lt;br /&gt;
In this section we will assume you have a copy of Visual Studio (VS) .NET at hand. VS has two types of search &amp;quot;'''Find in Files'''&amp;quot; and a cmd line tool called '''Findstr'''&lt;br /&gt;
  &lt;br /&gt;
The test search tools in XP is not great in my experience and if one has to use this make sure SP2 in installed as it works better.&lt;br /&gt;
To start off one should scan thorough the code looking for common patterns or keywords such as &amp;quot;User&amp;quot;, &amp;quot;Password&amp;quot;, &amp;quot;Pswd&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Http&amp;quot;, etc...&lt;br /&gt;
This can be done using the &amp;quot;Find in Files&amp;quot; tool in VS or using findstring as follows:&lt;br /&gt;
 &lt;br /&gt;
[Find In Files HERE]&lt;br /&gt;
&lt;br /&gt;
 '''findstr /s /m /i /d:c:\projects\codebase\sec &amp;quot;http&amp;quot; *.*'''&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
====Http Request Strings====&lt;br /&gt;
Requests from external sources are onviously a key area of a secure code review. We need to ensure that all HTTP requests received are datavalidated for composition, max and min length and if the data falls with the relms of the parameter whitelist.&lt;br /&gt;
Bottom-line is this is a key area to look at and ensure security is enabled.&lt;br /&gt;
&lt;br /&gt;
 request.querystring&lt;br /&gt;
 request.form &lt;br /&gt;
 request.cookies&lt;br /&gt;
 request.certificate&lt;br /&gt;
 request.servervariables&lt;br /&gt;
 request.IsSecureConnection&lt;br /&gt;
 request.TotalBytes&lt;br /&gt;
 request.BinaryRead&lt;br /&gt;
&lt;br /&gt;
====HTML Output====&lt;br /&gt;
Here we are looking for responses to the client. Responses which go unvalidated or which echo external input without data validation are key areas to examine. Many client side attacks result from poor response validation. XSS relies on this somewhat.&lt;br /&gt;
&lt;br /&gt;
 response.write&lt;br /&gt;
 &amp;lt;% =&lt;br /&gt;
 HttpUtility&lt;br /&gt;
 HtmlEncode&lt;br /&gt;
 UrlEncode&lt;br /&gt;
 innerText&lt;br /&gt;
 innerHTML&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Locating where a database may be involved in the code is an important aspect of the code review. Looking at the database code will help determine if the application is vulnerable to SQL injection. One aspect of this is to verify that the code uses either ''SqlParameter'', ''OleDbParameter'', or ''OdbcParameter''(System.Data.SqlClient). These are typed and treats parameters as the literal value and not executable code in the database. &lt;br /&gt;
&lt;br /&gt;
 exec sp_executesql&lt;br /&gt;
 execute sp_executesql&lt;br /&gt;
 select from&lt;br /&gt;
 Insert&lt;br /&gt;
 update&lt;br /&gt;
 delete from where&lt;br /&gt;
 delete&lt;br /&gt;
 exec sp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec xp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec @&lt;br /&gt;
 execute @&lt;br /&gt;
 executestatement&lt;br /&gt;
 executeSQL&lt;br /&gt;
 setfilter&lt;br /&gt;
 executeQuery&lt;br /&gt;
 GetQueryResultInXML&lt;br /&gt;
 adodb&lt;br /&gt;
 sqloledb&lt;br /&gt;
 sql server&lt;br /&gt;
 driver&lt;br /&gt;
 Server.CreateObject&lt;br /&gt;
 .Provider&lt;br /&gt;
 .Open&lt;br /&gt;
 ADODB.recordset&lt;br /&gt;
 New OleDbConnection&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 DataSource&lt;br /&gt;
 SqlCommand&lt;br /&gt;
 Microsoft.Jet&lt;br /&gt;
 SqlDataReader&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 GetString&lt;br /&gt;
 SqlDataAdapter &lt;br /&gt;
 CommandType&lt;br /&gt;
 StoredProcedure&lt;br /&gt;
 System.Data.sql&lt;br /&gt;
&lt;br /&gt;
====Cookies====&lt;br /&gt;
Cookie manipulation can be key to various application security exploits such as session hijacking/fixation and parameter manipulation. One should examine any code relating to cookie functionality as this would have a bearing on session security.&lt;br /&gt;
 System.Net.Cookie &lt;br /&gt;
 [[HTTPOnly]]&lt;br /&gt;
 document.cookie&lt;br /&gt;
&lt;br /&gt;
==== HTML Tags====&lt;br /&gt;
Many of the HTML tags below can be used for client side attacks such as cross site scritping. It is important to examine the context in which these tags are used and to examine any relevant data validation associated with the display and use of such tags withing a web application.&lt;br /&gt;
&lt;br /&gt;
 HtmlEncode &lt;br /&gt;
 URLEncode&lt;br /&gt;
 &amp;lt;applet&amp;gt; &lt;br /&gt;
 &amp;lt;frameset&amp;gt; &lt;br /&gt;
 &amp;lt;embed&amp;gt; &lt;br /&gt;
 &amp;lt;frame&amp;gt; &lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;iframe&amp;gt; &lt;br /&gt;
 &amp;lt;img&amp;gt; &lt;br /&gt;
 &amp;lt;style&amp;gt; &lt;br /&gt;
 &amp;lt;layer&amp;gt; &lt;br /&gt;
 &amp;lt;ilayer&amp;gt; &lt;br /&gt;
 &amp;lt;meta&amp;gt; &lt;br /&gt;
 &amp;lt;object&amp;gt; &lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &amp;lt;frame security&lt;br /&gt;
 &amp;lt;iframe security&lt;br /&gt;
&lt;br /&gt;
====Input Controls====&lt;br /&gt;
The input controls below are server classes used to produce and display web application form fields. Looking for such references helps locate entry points into the application.&lt;br /&gt;
&lt;br /&gt;
 system.web.ui.htmlcontrols.htmlinputhidden&lt;br /&gt;
 system.web.ui.webcontrols.textbox&lt;br /&gt;
 system.web.ui.webcontrols.listbox&lt;br /&gt;
 system.web.ui.webcontrols.checkboxlist&lt;br /&gt;
 system.web.ui.webcontrols.dropdownlist&lt;br /&gt;
&lt;br /&gt;
====web.config====&lt;br /&gt;
The .NET Framework relies on .config files to define configuration settings. The .config files are text-based XML files. Many .config files can, and typically do, exist on a single system. Web applications refer to a web.config file located in the application’s root directory. For ASP.NET applications, web.config contains information about most aspects of the application’s operation.&lt;br /&gt;
&lt;br /&gt;
 requestEncoding&lt;br /&gt;
 responseEncoding&lt;br /&gt;
 trace&lt;br /&gt;
 authorization&lt;br /&gt;
 CustomErrors&lt;br /&gt;
 httpRuntime &lt;br /&gt;
 maxRequestLength&lt;br /&gt;
 debug&lt;br /&gt;
 forms protection&lt;br /&gt;
 appSettings&lt;br /&gt;
 ConfigurationSettings&lt;br /&gt;
 authentication mode&lt;br /&gt;
 allow&lt;br /&gt;
 deny&lt;br /&gt;
 credentials&lt;br /&gt;
 identity impersonate&lt;br /&gt;
 timeout&lt;br /&gt;
&lt;br /&gt;
====global.asax====&lt;br /&gt;
Each application has its own Global.asax if one is required. Global.asax sets the event code and values for an application using scripts. One must ensure that application variables do not contain sensitive information, as they are accessible to the whole application and to all users within it.&lt;br /&gt;
&lt;br /&gt;
 Application_OnAuthenticateRequest&lt;br /&gt;
 Application_OnAuthorizeRequest&lt;br /&gt;
 Session_OnStart&lt;br /&gt;
 Session_OnEnd&lt;br /&gt;
&lt;br /&gt;
====logging====&lt;br /&gt;
Logging can be a source of information leakage. It is important to examing all calls to the logging subsystem and to determine if any sensitive information is being logged. Common mistakes are logging userID in conjunction with passwords within the authentication functionality or logging database requests which may contains sensitive data.&lt;br /&gt;
&lt;br /&gt;
 log4net&lt;br /&gt;
 Console.WriteLine&lt;br /&gt;
 System.Diagnostics.Debug&lt;br /&gt;
 System.Diagnostics.Trace&lt;br /&gt;
&lt;br /&gt;
====Machine.config====&lt;br /&gt;
Its important that many variables in machine.config can be overridden in the web.config file for a particular application.&lt;br /&gt;
 validateRequest&lt;br /&gt;
 enableViewState&lt;br /&gt;
 enableViewStateMac&lt;br /&gt;
&lt;br /&gt;
====Threads and Concurrancy====&lt;br /&gt;
Locating code that contains multithreaded functions. Concurrancy issues can result in race conditions which may result in security vulnerabilities. The Thread keyword is where new threads objects are created. Code that uses static global variables which hold sensitive security information may cause session issues. Code that uses static constructors may also cause issues between threads. Not synchronizing the Dispose method may cause issues if a number of threads call Dispose at the same time, this may cause resource release issues.&lt;br /&gt;
&lt;br /&gt;
 Thread&lt;br /&gt;
 Dispose&lt;br /&gt;
&lt;br /&gt;
====Class Design====&lt;br /&gt;
Public and Sealed relate to the design at class level. Classes whicch are not intended to be derived from should be sealed. Make sure all class fields are Public for a reason. Dont expose anything you dont need to.&lt;br /&gt;
&lt;br /&gt;
 Public&lt;br /&gt;
 Sealed&lt;br /&gt;
&lt;br /&gt;
====Reflection, Serialization====&lt;br /&gt;
Code may be generated dynamically at runtime. Code that is generated dynamically as a function of external input may give rise to issues. If your code contains sensitive data does it need to be serialized. &lt;br /&gt;
&lt;br /&gt;
 Serializable &lt;br /&gt;
 AllowPartiallyTrustedCallersAttribute&lt;br /&gt;
 GetObjectData &lt;br /&gt;
 StrongNameIdentityPermission&lt;br /&gt;
 StrongNameIdentity&lt;br /&gt;
 System.Reflection&lt;br /&gt;
&lt;br /&gt;
====Exceptions &amp;amp; Errors====&lt;br /&gt;
Ensure that the catch blocks do not leak information to the user in the case of an exception. Ensure when dealing with resources that the finally block is used. Having trace enabled is not great from an information leakage perspective. Ensure custonised errors are properly implemented.&lt;br /&gt;
&lt;br /&gt;
 catch{&lt;br /&gt;
 Finally&lt;br /&gt;
 trace enabled&lt;br /&gt;
 customErrors mode&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
If cryptography is used then is a strong enough cipher used i.e. AES or 3DES. What size key is used, the larger the better. Where is hashing performed. Are passwords that are being persisted hashed, they should be.&lt;br /&gt;
How are random numbers generated? Is the PRNG &amp;quot;random enough&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
 RNGCryptoServiceProvider&lt;br /&gt;
 SHA&lt;br /&gt;
 MD5&lt;br /&gt;
 base64&lt;br /&gt;
 xor&lt;br /&gt;
 DES&lt;br /&gt;
 RC2&lt;br /&gt;
 System.Random&lt;br /&gt;
 Random&lt;br /&gt;
 System.Security.Cryptography&lt;br /&gt;
&lt;br /&gt;
====Storage====&lt;br /&gt;
If storing sensitive data in memory recommend one uses the following. &lt;br /&gt;
 SecureString&lt;br /&gt;
 ProtectedMemory&lt;br /&gt;
&lt;br /&gt;
====Authorization, Assert &amp;amp; Revert====&lt;br /&gt;
Bypassing the code access security permission? Not a good idea. Also below is a list of potentially dangerous permissions such as calling unmanaged code, outside the CLR.&lt;br /&gt;
&lt;br /&gt;
 .RequestMinimum&lt;br /&gt;
 .RequestOptional&lt;br /&gt;
 Assert&lt;br /&gt;
 Debug.Assert&lt;br /&gt;
 CodeAccessPermission&lt;br /&gt;
 ReflectionPermission.MemberAccess&lt;br /&gt;
 SecurityPermission.ControlAppDomain&lt;br /&gt;
 SecurityPermission.UnmanagedCode&lt;br /&gt;
 SecurityPermission.SkipVerification&lt;br /&gt;
 SecurityPermission.ControlEvidence&lt;br /&gt;
 SecurityPermission.SerializationFormatter&lt;br /&gt;
 SecurityPermission.ControlPrincipal&lt;br /&gt;
 SecurityPermission.ControlDomainPolicy&lt;br /&gt;
 SecurityPermission.ControlPolicy&lt;br /&gt;
&lt;br /&gt;
====Leagcy methods====&lt;br /&gt;
 printf&lt;br /&gt;
 strcpy&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in J2EE/Java ===&lt;br /&gt;
&lt;br /&gt;
====Input Streams====&lt;br /&gt;
 Java.io&lt;br /&gt;
 FileInputStream&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 FilterInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 SequenceInputStream&lt;br /&gt;
 StringBufferInputStream&lt;br /&gt;
 BufferedReader&lt;br /&gt;
 ByteArrayInputStream&lt;br /&gt;
 CharArrayReader&lt;br /&gt;
 File&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 StreamTokenizer&lt;br /&gt;
 getResourceAsStream&lt;br /&gt;
&lt;br /&gt;
====Servlets====&lt;br /&gt;
 javax.servlet.&lt;br /&gt;
 getParameterNames&lt;br /&gt;
 getParameterValues&lt;br /&gt;
 getAttribute&lt;br /&gt;
 getAttributeNames&lt;br /&gt;
 isSecure&lt;br /&gt;
 HttpServletRequest&lt;br /&gt;
 getQueryString&lt;br /&gt;
 getHeader&lt;br /&gt;
 getPrincipal&lt;br /&gt;
 isUserInRole&lt;br /&gt;
 getOutputStream&lt;br /&gt;
 getWriter&lt;br /&gt;
 addCookie&lt;br /&gt;
 addHeader&lt;br /&gt;
 setHeader&lt;br /&gt;
 &lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Searching for Java Database related code this list should help you pinpoint classes/methods which are involved in the persistance layer of the application being reviewed.&lt;br /&gt;
 jdbc&lt;br /&gt;
 executeQuery&lt;br /&gt;
 select&lt;br /&gt;
 insert&lt;br /&gt;
 update&lt;br /&gt;
 delete&lt;br /&gt;
 execute&lt;br /&gt;
 executestatement&lt;br /&gt;
====SSL====&lt;br /&gt;
 com.sun.net.ssl&lt;br /&gt;
 SSLContext&lt;br /&gt;
 SSLSocketFactory&lt;br /&gt;
 TrustManagerFactory&lt;br /&gt;
 HttpsURLConnection&lt;br /&gt;
 KeyManagerFactory&lt;br /&gt;
&lt;br /&gt;
====Session Management====&lt;br /&gt;
 getSession&lt;br /&gt;
 invalidate&lt;br /&gt;
 getId &lt;br /&gt;
&lt;br /&gt;
====Data Validation====&lt;br /&gt;
&lt;br /&gt;
====Legacy Interaction====&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
&lt;br /&gt;
====Security Manager====&lt;br /&gt;
&lt;br /&gt;
====System====&lt;br /&gt;
&lt;br /&gt;
====Logging====&lt;br /&gt;
&lt;br /&gt;
====Architectural Analysis====&lt;br /&gt;
If we can identify major architectural components within that application (right away) it can help narrow our search, and we can then look for known vulnerabilities in those components and frameworks:&lt;br /&gt;
&lt;br /&gt;
 ### Ajax&lt;br /&gt;
 XMLHTTP&lt;br /&gt;
 ### Struts&lt;br /&gt;
 org.apache.struts&lt;br /&gt;
 ### Spring&lt;br /&gt;
 org.springframework&lt;br /&gt;
 ### Java Server Faces (JSF)&lt;br /&gt;
 import javax.faces&lt;br /&gt;
 ### Hibernate&lt;br /&gt;
 import org.hibernate&lt;br /&gt;
 ### Castor&lt;br /&gt;
 org.exolab.castor&lt;br /&gt;
 ### JAXB&lt;br /&gt;
 javax.xml&lt;br /&gt;
 ### JMS&lt;br /&gt;
 JMS&lt;br /&gt;
&lt;br /&gt;
===Generic keywords===&lt;br /&gt;
Developers say the darnedest things in their source code.  Look for the following keywords as pointers to possible software vulnerabilities:&lt;br /&gt;
&lt;br /&gt;
 Hack&lt;br /&gt;
 Kludge&lt;br /&gt;
 Bypass&lt;br /&gt;
 Steal&lt;br /&gt;
 Stolen&lt;br /&gt;
 Divert&lt;br /&gt;
 Broke&lt;br /&gt;
 Trick&lt;br /&gt;
 Fix&lt;br /&gt;
 ToDo&lt;br /&gt;
&lt;br /&gt;
===Web 2.0===&lt;br /&gt;
&lt;br /&gt;
====Ajax and JavaScript====&lt;br /&gt;
Look for Ajax usage, and possible JavaScript issues:&lt;br /&gt;
&lt;br /&gt;
 document.write&lt;br /&gt;
 eval(&lt;br /&gt;
 document.cookie&lt;br /&gt;
 window.location&lt;br /&gt;
 document.URL&lt;br /&gt;
 XMLHTTP&lt;br /&gt;
 window.createRequest&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=20292</id>
		<title>Searching for Code in J2EE/Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=20292"/>
				<updated>2007-07-27T17:38:57Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Linked keyword HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Searching for key indicators ==&lt;br /&gt;
The basis of the code review is to locate and analyse areas of code which may have application security implications.&lt;br /&gt;
Assuming the code reviewer has a thorough understanding of the code, what it is intended to do and the context upon which it is to be used, firstly one needs to sweep the code base for areas of interest.&lt;br /&gt;
&lt;br /&gt;
This can be done by performing a text search on the code base looking for keywords relating to API's and functions.&lt;br /&gt;
Below is a guide for .NET framework 1.1 &amp;amp; 2.0&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in .NET ===&lt;br /&gt;
&lt;br /&gt;
Firstly one needs to be familiar with the tools one can use in order to perform text searching following on from this one need to know what to look for.&lt;br /&gt;
 &lt;br /&gt;
In this section we will assume you have a copy of Visual Studio (VS) .NET at hand. VS has two types of search &amp;quot;'''Find in Files'''&amp;quot; and a cmd line tool called '''Findstr'''&lt;br /&gt;
  &lt;br /&gt;
The test search tools in XP is not great in my experience and if one has to use this make sure SP2 in installed as it works better.&lt;br /&gt;
To start off one should scan thorough the code looking for common patterns or keywords such as &amp;quot;User&amp;quot;, &amp;quot;Password&amp;quot;, &amp;quot;Pswd&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Http&amp;quot;, etc...&lt;br /&gt;
This can be done using the &amp;quot;Find in Files&amp;quot; tool in VS or using findstring as follows:&lt;br /&gt;
 &lt;br /&gt;
[Find In Files HERE]&lt;br /&gt;
&lt;br /&gt;
 '''findstr /s /m /i /d:c:\projects\codebase\sec &amp;quot;http&amp;quot; *.*'''&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
====Http Request Strings====&lt;br /&gt;
Requests from external sources are onviously a key area of a secure code review. We need to ensure that all HTTP requests received are datavalidated for composition, max and min length and if the data falls with the relms of the parameter whitelist.&lt;br /&gt;
Bottom-line is this is a key area to look at and ensure security is enabled.&lt;br /&gt;
&lt;br /&gt;
 request.querystring&lt;br /&gt;
 request.form &lt;br /&gt;
 request.cookies&lt;br /&gt;
 request.certificate&lt;br /&gt;
 request.servervariables&lt;br /&gt;
 request.IsSecureConnection&lt;br /&gt;
 request.TotalBytes&lt;br /&gt;
 request.BinaryRead&lt;br /&gt;
&lt;br /&gt;
====HTML Output====&lt;br /&gt;
Here we are looking for responses to the client. Responses which go unvalidated or which echo external input without data validation are key areas to examine. Many client side attacks result from poor response validation. XSS relies on this somewhat.&lt;br /&gt;
&lt;br /&gt;
 response.write&lt;br /&gt;
 &amp;lt;% =&lt;br /&gt;
 HttpUtility&lt;br /&gt;
 HtmlEncode&lt;br /&gt;
 UrlEncode&lt;br /&gt;
 innerText&lt;br /&gt;
 innerHTML&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Locating where a database may be involved in the code is an important aspect of the code review. Looking at the database code will help determine if the application is vulnerable to SQL injection. One aspect of this is to verify that the code uses either ''SqlParameter'', ''OleDbParameter'', or ''OdbcParameter''(System.Data.SqlClient). These are typed and treats parameters as the literal value and not executable code in the database. &lt;br /&gt;
&lt;br /&gt;
 exec sp_executesql&lt;br /&gt;
 execute sp_executesql&lt;br /&gt;
 select from&lt;br /&gt;
 Insert&lt;br /&gt;
 update&lt;br /&gt;
 delete from where&lt;br /&gt;
 delete&lt;br /&gt;
 exec sp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec xp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec @&lt;br /&gt;
 execute @&lt;br /&gt;
 executestatement&lt;br /&gt;
 executeSQL&lt;br /&gt;
 setfilter&lt;br /&gt;
 executeQuery&lt;br /&gt;
 GetQueryResultInXML&lt;br /&gt;
 adodb&lt;br /&gt;
 sqloledb&lt;br /&gt;
 sql server&lt;br /&gt;
 driver&lt;br /&gt;
 Server.CreateObject&lt;br /&gt;
 .Provider&lt;br /&gt;
 .Open&lt;br /&gt;
 ADODB.recordset&lt;br /&gt;
 New OleDbConnection&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 DataSource&lt;br /&gt;
 SqlCommand&lt;br /&gt;
 Microsoft.Jet&lt;br /&gt;
 SqlDataReader&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 GetString&lt;br /&gt;
 SqlDataAdapter &lt;br /&gt;
 CommandType&lt;br /&gt;
 StoredProcedure&lt;br /&gt;
 System.Data.sql&lt;br /&gt;
&lt;br /&gt;
====Cookies====&lt;br /&gt;
Cookie manipulation can be key to various application security exploits such as session hijacking/fixation and parameter manipulation. One should examine any code relating to cookie functionality as this would have a bearing on session security.&lt;br /&gt;
 System.Net.Cookie &lt;br /&gt;
 [[HttpOnly]]&lt;br /&gt;
 document.cookie&lt;br /&gt;
&lt;br /&gt;
==== HTML Tags====&lt;br /&gt;
Many of the HTML tags below can be used for client side attacks such as cross site scritping. It is important to examine the context in which these tags are used and to examine any relevant data validation associated with the display and use of such tags withing a web application.&lt;br /&gt;
&lt;br /&gt;
 HtmlEncode &lt;br /&gt;
 URLEncode&lt;br /&gt;
 &amp;lt;applet&amp;gt; &lt;br /&gt;
 &amp;lt;frameset&amp;gt; &lt;br /&gt;
 &amp;lt;embed&amp;gt; &lt;br /&gt;
 &amp;lt;frame&amp;gt; &lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;iframe&amp;gt; &lt;br /&gt;
 &amp;lt;img&amp;gt; &lt;br /&gt;
 &amp;lt;style&amp;gt; &lt;br /&gt;
 &amp;lt;layer&amp;gt; &lt;br /&gt;
 &amp;lt;ilayer&amp;gt; &lt;br /&gt;
 &amp;lt;meta&amp;gt; &lt;br /&gt;
 &amp;lt;object&amp;gt; &lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &amp;lt;frame security&lt;br /&gt;
 &amp;lt;iframe security&lt;br /&gt;
&lt;br /&gt;
====Input Controls====&lt;br /&gt;
The input controls below are server classes used to produce and display web application form fields. Looking for such references helps locate entry points into the application.&lt;br /&gt;
&lt;br /&gt;
 system.web.ui.htmlcontrols.htmlinputhidden&lt;br /&gt;
 system.web.ui.webcontrols.textbox&lt;br /&gt;
 system.web.ui.webcontrols.listbox&lt;br /&gt;
 system.web.ui.webcontrols.checkboxlist&lt;br /&gt;
 system.web.ui.webcontrols.dropdownlist&lt;br /&gt;
&lt;br /&gt;
====web.config====&lt;br /&gt;
The .NET Framework relies on .config files to define configuration settings. The .config files are text-based XML files. Many .config files can, and typically do, exist on a single system. Web applications refer to a web.config file located in the application’s root directory. For ASP.NET applications, web.config contains information about most aspects of the application’s operation.&lt;br /&gt;
&lt;br /&gt;
 requestEncoding&lt;br /&gt;
 responseEncoding&lt;br /&gt;
 trace&lt;br /&gt;
 authorization&lt;br /&gt;
 CustomErrors&lt;br /&gt;
 httpRuntime &lt;br /&gt;
 maxRequestLength&lt;br /&gt;
 debug&lt;br /&gt;
 forms protection&lt;br /&gt;
 appSettings&lt;br /&gt;
 ConfigurationSettings&lt;br /&gt;
 authentication mode&lt;br /&gt;
 allow&lt;br /&gt;
 deny&lt;br /&gt;
 credentials&lt;br /&gt;
 identity impersonate&lt;br /&gt;
 timeout&lt;br /&gt;
&lt;br /&gt;
====global.asax====&lt;br /&gt;
Each application has its own Global.asax if one is required. Global.asax sets the event code and values for an application using scripts. One must ensure that application variables do not contain sensitive information, as they are accessible to the whole application and to all users within it.&lt;br /&gt;
&lt;br /&gt;
 Application_OnAuthenticateRequest&lt;br /&gt;
 Application_OnAuthorizeRequest&lt;br /&gt;
 Session_OnStart&lt;br /&gt;
 Session_OnEnd&lt;br /&gt;
&lt;br /&gt;
====logging====&lt;br /&gt;
Logging can be a source of information leakage. It is important to examing all calls to the logging subsystem and to determine if any sensitive information is being logged. Common mistakes are logging userID in conjunction with passwords within the authentication functionality or logging database requests which may contains sensitive data.&lt;br /&gt;
&lt;br /&gt;
 log4net&lt;br /&gt;
 Console.WriteLine&lt;br /&gt;
 System.Diagnostics.Debug&lt;br /&gt;
 System.Diagnostics.Trace&lt;br /&gt;
&lt;br /&gt;
====Machine.config====&lt;br /&gt;
Its important that many variables in machine.config can be overridden in the web.config file for a particular application.&lt;br /&gt;
 validateRequest&lt;br /&gt;
 enableViewState&lt;br /&gt;
 enableViewStateMac&lt;br /&gt;
&lt;br /&gt;
====Threads and Concurrancy====&lt;br /&gt;
Locating code that contains multithreaded functions. Concurrancy issues can result in race conditions which may result in security vulnerabilities. The Thread keyword is where new threads objects are created. Code that uses static global variables which hold sensitive security information may cause session issues. Code that uses static constructors may also cause issues between threads. Not synchronizing the Dispose method may cause issues if a number of threads call Dispose at the same time, this may cause resource release issues.&lt;br /&gt;
&lt;br /&gt;
 Thread&lt;br /&gt;
 Dispose&lt;br /&gt;
&lt;br /&gt;
====Class Design====&lt;br /&gt;
Public and Sealed relate to the design at class level. Classes whicch are not intended to be derived from should be sealed. Make sure all class fields are Public for a reason. Dont expose anything you dont need to.&lt;br /&gt;
&lt;br /&gt;
 Public&lt;br /&gt;
 Sealed&lt;br /&gt;
&lt;br /&gt;
====Reflection, Serialization====&lt;br /&gt;
Code may be generated dynamically at runtime. Code that is generated dynamically as a function of external input may give rise to issues. If your code contains sensitive data does it need to be serialized. &lt;br /&gt;
&lt;br /&gt;
 Serializable &lt;br /&gt;
 AllowPartiallyTrustedCallersAttribute&lt;br /&gt;
 GetObjectData &lt;br /&gt;
 StrongNameIdentityPermission&lt;br /&gt;
 StrongNameIdentity&lt;br /&gt;
 System.Reflection&lt;br /&gt;
&lt;br /&gt;
====Exceptions &amp;amp; Errors====&lt;br /&gt;
Ensure that the catch blocks do not leak information to the user in the case of an exception. Ensure when dealing with resources that the finally block is used. Having trace enabled is not great from an information leakage perspective. Ensure custonised errors are properly implemented.&lt;br /&gt;
&lt;br /&gt;
 catch{&lt;br /&gt;
 Finally&lt;br /&gt;
 trace enabled&lt;br /&gt;
 customErrors mode&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
If cryptography is used then is a strong enough cipher used i.e. AES or 3DES. What size key is used, the larger the better. Where is hashing performed. Are passwords that are being persisted hashed, they should be.&lt;br /&gt;
How are random numbers generated? Is the PRNG &amp;quot;random enough&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
 RNGCryptoServiceProvider&lt;br /&gt;
 SHA&lt;br /&gt;
 MD5&lt;br /&gt;
 base64&lt;br /&gt;
 xor&lt;br /&gt;
 DES&lt;br /&gt;
 RC2&lt;br /&gt;
 System.Random&lt;br /&gt;
 Random&lt;br /&gt;
 System.Security.Cryptography&lt;br /&gt;
&lt;br /&gt;
====Storage====&lt;br /&gt;
If storing sensitive data in memory recommend one uses the following. &lt;br /&gt;
 SecureString&lt;br /&gt;
 ProtectedMemory&lt;br /&gt;
&lt;br /&gt;
====Authorization, Assert &amp;amp; Revert====&lt;br /&gt;
Bypassing the code access security permission? Not a good idea. Also below is a list of potentially dangerous permissions such as calling unmanaged code, outside the CLR.&lt;br /&gt;
&lt;br /&gt;
 .RequestMinimum&lt;br /&gt;
 .RequestOptional&lt;br /&gt;
 Assert&lt;br /&gt;
 Debug.Assert&lt;br /&gt;
 CodeAccessPermission&lt;br /&gt;
 ReflectionPermission.MemberAccess&lt;br /&gt;
 SecurityPermission.ControlAppDomain&lt;br /&gt;
 SecurityPermission.UnmanagedCode&lt;br /&gt;
 SecurityPermission.SkipVerification&lt;br /&gt;
 SecurityPermission.ControlEvidence&lt;br /&gt;
 SecurityPermission.SerializationFormatter&lt;br /&gt;
 SecurityPermission.ControlPrincipal&lt;br /&gt;
 SecurityPermission.ControlDomainPolicy&lt;br /&gt;
 SecurityPermission.ControlPolicy&lt;br /&gt;
&lt;br /&gt;
====Leagcy methods====&lt;br /&gt;
 printf&lt;br /&gt;
 strcpy&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in J2EE/Java ===&lt;br /&gt;
&lt;br /&gt;
====Input Streams====&lt;br /&gt;
 Java.io&lt;br /&gt;
 FileInputStream&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 FilterInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 SequenceInputStream&lt;br /&gt;
 StringBufferInputStream&lt;br /&gt;
 BufferedReader&lt;br /&gt;
 ByteArrayInputStream&lt;br /&gt;
 CharArrayReader&lt;br /&gt;
 File&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 StreamTokenizer&lt;br /&gt;
 getResourceAsStream&lt;br /&gt;
&lt;br /&gt;
====Servlets====&lt;br /&gt;
 javax.servlet.&lt;br /&gt;
 getParameterNames&lt;br /&gt;
 getParameterValues&lt;br /&gt;
 getAttribute&lt;br /&gt;
 getAttributeNames&lt;br /&gt;
 isSecure&lt;br /&gt;
 HttpServletRequest&lt;br /&gt;
 getQueryString&lt;br /&gt;
 getHeader&lt;br /&gt;
 getPrincipal&lt;br /&gt;
 isUserInRole&lt;br /&gt;
 getOutputStream&lt;br /&gt;
 getWriter&lt;br /&gt;
 addCookie&lt;br /&gt;
 addHeader&lt;br /&gt;
 setHeader&lt;br /&gt;
 &lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Searching for Java Database related code this list should help you pinpoint classes/methods which are involved in the persistance layer of the application being reviewed.&lt;br /&gt;
 jdbc&lt;br /&gt;
 executeQuery&lt;br /&gt;
 select&lt;br /&gt;
 insert&lt;br /&gt;
 update&lt;br /&gt;
 delete&lt;br /&gt;
 execute&lt;br /&gt;
 executestatement&lt;br /&gt;
====SSL====&lt;br /&gt;
 com.sun.net.ssl&lt;br /&gt;
 SSLContext&lt;br /&gt;
 SSLSocketFactory&lt;br /&gt;
 TrustManagerFactory&lt;br /&gt;
 HttpsURLConnection&lt;br /&gt;
 KeyManagerFactory&lt;br /&gt;
&lt;br /&gt;
====Session Management====&lt;br /&gt;
 getSession&lt;br /&gt;
 invalidate&lt;br /&gt;
 getId &lt;br /&gt;
&lt;br /&gt;
====Data Validation====&lt;br /&gt;
&lt;br /&gt;
====Legacy Interaction====&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
&lt;br /&gt;
====Security Manager====&lt;br /&gt;
&lt;br /&gt;
====System====&lt;br /&gt;
&lt;br /&gt;
====Logging====&lt;br /&gt;
&lt;br /&gt;
====Architectural Analysis====&lt;br /&gt;
If we can identify major architectural components within that application (right away) it can help narrow our search, and we can then look for known vulnerabilities in those components and frameworks:&lt;br /&gt;
&lt;br /&gt;
 ### Ajax&lt;br /&gt;
 XMLHTTP&lt;br /&gt;
 ### Struts&lt;br /&gt;
 org.apache.struts&lt;br /&gt;
 ### Spring&lt;br /&gt;
 org.springframework&lt;br /&gt;
 ### Java Server Faces (JSF)&lt;br /&gt;
 import javax.faces&lt;br /&gt;
 ### Hibernate&lt;br /&gt;
 import org.hibernate&lt;br /&gt;
 ### Castor&lt;br /&gt;
 org.exolab.castor&lt;br /&gt;
 ### JAXB&lt;br /&gt;
 javax.xml&lt;br /&gt;
 ### JMS&lt;br /&gt;
 JMS&lt;br /&gt;
&lt;br /&gt;
===Generic keywords===&lt;br /&gt;
Developers say the darnedest things in their source code.  Look for the following keywords as pointers to possible software vulnerabilities:&lt;br /&gt;
&lt;br /&gt;
 Hack&lt;br /&gt;
 Kludge&lt;br /&gt;
 Bypass&lt;br /&gt;
 Steal&lt;br /&gt;
 Stolen&lt;br /&gt;
 Divert&lt;br /&gt;
 Broke&lt;br /&gt;
 Trick&lt;br /&gt;
 Fix&lt;br /&gt;
 ToDo&lt;br /&gt;
&lt;br /&gt;
===Web 2.0===&lt;br /&gt;
&lt;br /&gt;
====Ajax and JavaScript====&lt;br /&gt;
Look for Ajax usage, and possible JavaScript issues:&lt;br /&gt;
&lt;br /&gt;
 document.write&lt;br /&gt;
 eval(&lt;br /&gt;
 document.cookie&lt;br /&gt;
 window.location&lt;br /&gt;
 document.URL&lt;br /&gt;
 XMLHTTP&lt;br /&gt;
 window.createRequest&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Lesson_Plans&amp;diff=20291</id>
		<title>Lesson Plans</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Lesson_Plans&amp;diff=20291"/>
				<updated>2007-07-27T17:37:39Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Linked keyword: HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WebGoat User Guide Table of Contents]]&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
The lesson plans included WebGoat 5.0 (1/31/07) include:&lt;br /&gt;
{| border=1&lt;br /&gt;
|-&lt;br /&gt;
 || General || HTTP Basics&lt;br /&gt;
|-&lt;br /&gt;
 || || HTTP Splitting and Cache Poisining&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Exploit Thread Safety Problems&lt;br /&gt;
|-&lt;br /&gt;
 || || How to add a new WebGoat lesson&lt;br /&gt;
|-&lt;br /&gt;
 || Code Quality || How to Discover Clues in the HTML&lt;br /&gt;
|-&lt;br /&gt;
 || Unvalidated Parameters || How to Exploit Hidden Fields&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Exploit Unchecked Email&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Bypass Client Side JavaScript Validation&lt;br /&gt;
|-&lt;br /&gt;
 || Broken Access Control || Using an Access Control Matrix&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Bypass a Path Based Access Control Scheme&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform Cross Site Request Forgery (CSRF)&lt;br /&gt;
|-&lt;br /&gt;
 || || LAB: Role based Access Control&lt;br /&gt;
|-&lt;br /&gt;
 || || Remote Admin Access&lt;br /&gt;
|-&lt;br /&gt;
 || Broken Authentication || Forgot Password&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Spoof an Authentication Cookie&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Hijack a Session&lt;br /&gt;
|-&lt;br /&gt;
 || || Basic Authentication&lt;br /&gt;
|-&lt;br /&gt;
 || Cross Site Scripting (Xss) || LAB: Cross Site Scripting&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform Stored Cross Site Scripting (XSS)&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform Reflected Cross Site Scripting (XSS)&lt;br /&gt;
|-&lt;br /&gt;
 || || [[HTTPOnly]] Test&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform Cross Site Tracing (XST) Attacks&lt;br /&gt;
|-&lt;br /&gt;
 || Buffer Overflows || Buffer Overflow&lt;br /&gt;
|-&lt;br /&gt;
 || Injection Flaws || How to Perform Command Injection&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform Blind SQL Injection&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform Numeric SQL Injection &lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform Log Spoofing &lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform XPATH Injection&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Perform String SQL Injection &lt;br /&gt;
|-&lt;br /&gt;
 || || LAB: SQL Injection&lt;br /&gt;
|-&lt;br /&gt;
 || || How to Use Database Backdoors&lt;br /&gt;
|-&lt;br /&gt;
 || Improper Error Handling || How to Bypass a Fail Open Authentication Scheme&lt;br /&gt;
|-&lt;br /&gt;
 || Insecure Storage || Encoding Basics&lt;br /&gt;
|-&lt;br /&gt;
 || Denial of Service || Denial of Service From Multiple Logins&lt;br /&gt;
|-&lt;br /&gt;
 || Insecure Configuration Management || Forced Browsing&lt;br /&gt;
|-&lt;br /&gt;
|| Web Services || How to Create a SOAP Request&lt;br /&gt;
|-&lt;br /&gt;
 || || WSDL Scanning&lt;br /&gt;
|-&lt;br /&gt;
 || || Web Service SAX Injection&lt;br /&gt;
|-&lt;br /&gt;
 || || Web Service SQL Injection&lt;br /&gt;
|-&lt;br /&gt;
 || AJAX Security || DOM Injection&lt;br /&gt;
|-&lt;br /&gt;
|| || XML Injection &lt;br /&gt;
|-&lt;br /&gt;
 || || JSON Injection&lt;br /&gt;
|-&lt;br /&gt;
 || || Silent Transactions Attacks&lt;br /&gt;
|-&lt;br /&gt;
 || Challenge || The Challenge &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For each lesson within WebGoat, an overview and objectives are provided. These are accessed through the ''Show Lesson Plan'' button.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
[[Image:WebGoat Show Lesson Plan.gif|Figure 3: Show Lesson Plan]]&lt;br /&gt;
&lt;br /&gt;
These lesson plans describe the operation of each aspect of the target application, the areas of interest relating to the security assessment and the type of attack that should be attempted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[WebGoat User Guide Table of Contents]]&lt;br /&gt;
[[Category:OWASP WebGoat Project]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=WebGoat_User_Guide_Introduction&amp;diff=20290</id>
		<title>WebGoat User Guide Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=WebGoat_User_Guide_Introduction&amp;diff=20290"/>
				<updated>2007-07-27T17:36:03Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Linked keyword: HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WebGoat User and Install Guide Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
==Overview ==&lt;br /&gt;
The WebGoatv5 application is designed to illustrate typical security flaws within web-applications. It is intended to teach a structured approach to testing for, and exploiting such vulnerabilities within the context of an Application Security Assessment.&lt;br /&gt;
&lt;br /&gt;
A full Application Security Assessment testing methodology is being documented by &amp;lt;u&amp;gt;http://www.owasp.org/index.php/OWASP_Testing_Project&amp;lt;/u&amp;gt; and this will provide a superset of the issues demonstrated within the WebGoat. If may include a formal design and code review, for example. The WebGoat lessons aim to give practical training and examples relating to the ''Implementation'' ''Review'' phase of the OWASP Web Application Security Testing Methodology.&lt;br /&gt;
&lt;br /&gt;
The WebGoatv5 Application provides a testing platform for a typical application security assessment. The assessor is given the same information and rights as a typical customer or client of an on-line application.&lt;br /&gt;
* The application is web based&lt;br /&gt;
* The attack simulations are remote &lt;br /&gt;
All of the described techniques may be performed from any connected location.&lt;br /&gt;
* The testing is black-box&lt;br /&gt;
Source code is not supplied, but it can be viewed and downloaded.&lt;br /&gt;
* Credentials and operational information is provided&lt;br /&gt;
&lt;br /&gt;
Of course, the teaching aspect of WebGoat means that certain information will be revealed that would not typically be available. This makes it possible to guide the tester through an assessment process.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
The current lesson plans provided in WebGoatv5 include:&lt;br /&gt;
&lt;br /&gt;
{| border=1&lt;br /&gt;
 || HTTP Basics&lt;br /&gt;
|-&lt;br /&gt;
 || HTTP Splitting and Cache Poisining&lt;br /&gt;
|-&lt;br /&gt;
 || How to Exploit Thread Safety Problems&lt;br /&gt;
|-&lt;br /&gt;
 || How to Discover Clues in the HTML&lt;br /&gt;
|-&lt;br /&gt;
 || How to Exploit Hidden Fields&lt;br /&gt;
|-&lt;br /&gt;
 || How to Exploit Unchecked Email&lt;br /&gt;
|-&lt;br /&gt;
 || How to Bypass Client Side JavaScript Validation&lt;br /&gt;
|-&lt;br /&gt;
 || How to Force Browser Web Resources&lt;br /&gt;
|-&lt;br /&gt;
 || How to Bypass a Role Based Access Control Scheme&lt;br /&gt;
|-&lt;br /&gt;
 || How to Bypass a Path Based Access Control Scheme&lt;br /&gt;
|-&lt;br /&gt;
 || LAB: Role based Access Control&lt;br /&gt;
|-&lt;br /&gt;
 || Using an Access Control Matrix&lt;br /&gt;
|-&lt;br /&gt;
 || How to Exploit the Forgot Password Page&lt;br /&gt;
|-&lt;br /&gt;
 || How to Spoof an Authentication Cookie&lt;br /&gt;
|-&lt;br /&gt;
 || How to Hijack a Session&lt;br /&gt;
|-&lt;br /&gt;
 || Basic Authentication&lt;br /&gt;
|-&lt;br /&gt;
 || LAB: Cross Site Scripting&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Stored Cross Site Scripting (XSS)&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Reflected Cross Site Scripting (XSS)&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Cross Site Trace Attacks (XSS)&lt;br /&gt;
|-&lt;br /&gt;
 || Buffer Overflow (TBD)&lt;br /&gt;
|-&lt;br /&gt;
 || [[HTTPOnly]] Test&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Command Injection&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Parameter Injection&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Blind SQL Injection&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Numeric SQL Injection &lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform String SQL Injection &lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Log Spoofing &lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform XPATH Injection Attacks&lt;br /&gt;
|-&lt;br /&gt;
 || LAB: SQL Injection&lt;br /&gt;
|-&lt;br /&gt;
 || How to Bypass a Fail Open Authentication Scheme&lt;br /&gt;
|-&lt;br /&gt;
 || How to Peform Basic Encoding&lt;br /&gt;
|-&lt;br /&gt;
 || Denial of Service from Multiple Logins&lt;br /&gt;
|-&lt;br /&gt;
 || How to Create a SOAP Request&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform WSDL Scanning&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Web Service SAX Injection&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Web Service SQL Injection&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform DOM Injection Attack &lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform XML Injection Attacks&lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform JSON Injection Attack &lt;br /&gt;
|-&lt;br /&gt;
 || How to Perform Silent Transactions Attacks&lt;br /&gt;
|-&lt;br /&gt;
 || How to Add a New Lesson&lt;br /&gt;
|-&lt;br /&gt;
 || The Challenge &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Future releases of WebGoat will include more lessons and functionality. Should you have any suggestions for improvement or new lessons please contact [mailto:bill@owasp.org bill@owasp.org] with your ideas.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[WebGoat User and Install Guide Table of Contents]]&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP WebGoat Project]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Session_Management_Schema_(OTG-SESS-001)&amp;diff=20289</id>
		<title>Testing for Session Management Schema (OTG-SESS-001)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Session_Management_Schema_(OTG-SESS-001)&amp;diff=20289"/>
				<updated>2007-07-27T17:32:30Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[http://www.owasp.org/index.php/Web_Application_Penetration_Testing_AoC Up]]&amp;lt;br&amp;gt;&lt;br /&gt;
{{Template:OWASP Testing Guide v2}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
In order to avoid continuous authentication for each page of a website or service, web applications implement various mechanisms to store and validate credentials for a pre-determined timespan.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
These mechanisms are known as Session Management and while they're most important in order to increase the ease of use and user-friendliness of the application, they can be exploited by a pen tester to gain access to a user account without the need to provide correct credentials.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
The session management schema should be considered alongside the authentication and authorization schema, and cover at least the questions below from a non-technical point of view:&lt;br /&gt;
* Will the application be accessed from shared systems? e.g. Internet Café	 &amp;lt;br&amp;gt;&lt;br /&gt;
* Is application security of prime concern to the visiting client/customer?	&amp;lt;br&amp;gt;&lt;br /&gt;
* How many concurrent sessions may a user have?	&amp;lt;br&amp;gt;&lt;br /&gt;
* How long is the inactive timeout on the application?&amp;lt;br&amp;gt;	&lt;br /&gt;
* How long is the active timeout?	&amp;lt;br&amp;gt;&lt;br /&gt;
* Are sessions transferable from one source IP to another?	&amp;lt;br&amp;gt;&lt;br /&gt;
* Is ‘remember my username’ functionality provided?	&amp;lt;br&amp;gt;&lt;br /&gt;
* Is ‘automatic login’ functionality provided?	&amp;lt;br&amp;gt;&lt;br /&gt;
Having identified the schema in place, the application and its logic must be examined to ensure the proper implementation of the schema.&lt;br /&gt;
This phase of testing is intrinsically linked with general application security testing.  Whilst the first Schema questions (is the schema suitable for the site and does the schema meet the application provider’s requirements?) can be analysed in abstract, the final question (does the site implement the specified schema?) must be considered alongside other technical testing. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The identified schema should be analyzed against best practice within the context of the site during our penetration test.&lt;br /&gt;
Where the defined schema deviates from security best practice, the associated risks should be identified and described within the context of the environment.  Security risks and issues should be detailed and quantified, but ultimately the application provider must make decisions based on the security and usability of the application.&lt;br /&gt;
For example, if it is determined that the site has been designed without inactive session timeouts, the application provider should be advised about risks such as replay attacks, long-term attacks based on stolen or compromised Session IDs, and abuse of a shared terminal where the application was not logged out.  They must then consider these against other requirements such as convenience of use for clients and disruption of the application by forced re-authentication.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''' Session Management Implementation'''&amp;lt;br&amp;gt;&lt;br /&gt;
In this Chapter we describe how to analyse a Session Schema and how to test it. Technical security testing of Session Management implementation covers two key areas:&lt;br /&gt;
* Integrity of Session ID creation&lt;br /&gt;
* Secure management of active sessions and Session IDs&lt;br /&gt;
The Session ID should be sufficiently unpredictable and abstracted from any private information, and the Session management should be logically secured to prevent any manipulation or circumvention of application security.&lt;br /&gt;
These two key areas are interdependent, but should be considered separately for a number of reasons.&lt;br /&gt;
Firstly, the choice of underlying technology to provide the sessions is bewildering and can already include a large number of OTS products and an almost unlimited number of bespoke or proprietary implementations.  Whilst the same technical analysis must be performed on each, established vendor solutions may require a slightly different testing approach, and existing security research may exist on the implementation.&lt;br /&gt;
Secondly, even an unpredictable and abstract Session ID may be rendered completely ineffectual should the Session management be flawed.  Similarly, a strong and secure session management implementation may be undermined by a poor Session ID implementation.&lt;br /&gt;
Furthermore, the analyst should closely examine how (and if) the application uses the available Session management.  It is not uncommon to see Microsoft ISS server ASP Session IDs passed religiously back and forth during interaction with an application, only to discover that these are not used by the application logic at all.  It is therefore not correct to say that because an application is built on a ‘proven secure’ platform its Session Management is automatically secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&lt;br /&gt;
''' Session Analysis'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Session Tokens (Cookie, SessionID or Hidden Field) themselves should be examined to ensure their quality from a security perspective.  They should be tested against criteria such as their randomness, uniqueness, resistance to statistical and cryptographic analysis and information leakage.&amp;lt;br&amp;gt;&lt;br /&gt;
* Token Structure &amp;amp; Information Leakage&lt;br /&gt;
The first stage is to examine the structure and content of a Session ID provided by the application.  A common mistake is to include specific data in the Token instead of issuing a generic value and referencing real data at the server side.&lt;br /&gt;
If the Session ID is clear-text, the structure and pertinent data may be immediately obvious as the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.100.1:owaspuser:password:15:58&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If part or the entire Token appears to be encoded or hashed, it should be compared to various techniques to check for obvious obfuscation.&lt;br /&gt;
For example the string “192.168.100.1:owaspuser:password:15:58” is represented in Hex, Base64 and as an MD5 hash:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hex	3139322E3136382E3130302E313A6F77617370757365723A70617373776F72643A31353A3538&lt;br /&gt;
Base64	MTkyLjE2OC4xMDAuMTpvd2FzcHVzZXI6cGFzc3dvcmQ6MTU6NTg=&lt;br /&gt;
MD5	01c2fc4f0a817afd8366689bd29dd40a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Having identified the type of obfuscation, it may be possible to decode back to the original data.  In most cases, however, this is unlikely.  Even so, it may be useful to enumerate the encoding in place from the format of the message.  Furthermore, if both the format and obfuscation technique can be deduced, automated brute-force attacks could be devised.&lt;br /&gt;
Hybrid tokens may include information such as IP address or User ID together with an encoded portion, as the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
owaspuser:192.168.100.1: a7656fafe94dae72b1e1487670148412&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Having analysed a single Session Token, the representative sample should be examined.&lt;br /&gt;
A simple analysis of the Tokens should immediately reveal any obvious patterns.  For example, a 32 bit Token may include 16 bits of static data and 16 bits of variable data.  This may indicate that the first 16 bits represent a fixed attribute of the user – e.g. the username or IP address.&lt;br /&gt;
If the second 16 bit chunk is incrementing at a regular rate, it may indicate a sequential or even time-based element to the Token generation.  See Examples.&lt;br /&gt;
If static elements to the Tokens are identified, further samples should be gathered, varying one potential input element at a time.  For example, login attempts through a different user account or from a different IP address may yield a variance in the previously static portion of the Session Token.&lt;br /&gt;
The following areas should be addressed during the single and multiple Session ID structure testing:&lt;br /&gt;
* What parts of the Session ID are static?	&lt;br /&gt;
* What clear-text proprietary information is stored in the Session ID?  &lt;br /&gt;
e.g. usernames/UID, IP addresses	&lt;br /&gt;
* What easily decoded proprietary information is stored?	&lt;br /&gt;
* What information can be deduced from the structure of the Session ID?	&lt;br /&gt;
* What portions of the Session ID are static for the same login conditions?	&lt;br /&gt;
* What obvious patterns are present in the Session ID as a whole, or individual portions?	&lt;br /&gt;
 &lt;br /&gt;
'''Session ID Predictability and Randomness'''&amp;lt;br&amp;gt;&lt;br /&gt;
Analysis of the variable areas (if any) of the Session ID should be undertaken to establish the existence of any recognizable or predictable patterns.&lt;br /&gt;
These analysis may be performed manually and with bespoke or OTS statistical or cryptanalytic tools in order to deduce any patterns in Session ID content.&lt;br /&gt;
Manual checks should include comparisons of Session IDs issued for the same login conditions – e.g. the same username, password and IP address.  Time is an important factor which must also be controlled.  High numbers of simultaneous connections should be made in order to gather samples in the same time window and keep that variable constant.  Even a quantization of 50ms or less may be too coarse and a sample taken in this way may reveal time-based components that would otherwise be missed.&lt;br /&gt;
Variable elements should be analysed over time to determine whether they are incremental in nature.  Where they are incremental, patterns relating to absolute or elapsed time should be investigated.  Many systems use time as a seed for their pseudo random elements.&lt;br /&gt;
Where the patterns are seemingly random, one-way hashes of time or other environmental variations should be considered as a possibility.  Typically, the result of a cryptographic hash is a decimal or hexadecimal number so should be identifiable.&lt;br /&gt;
In analysing Session IDs sequences, patterns or cycles, static elements and client dependencies should all be considered as possible contributing elements to the structure and function of the application.&lt;br /&gt;
* Are the Session IDs provably random in nature?  e.g. Can the result be reproduced?  &lt;br /&gt;
* Do the same input conditions produce the same ID on a subsequent run?	&lt;br /&gt;
* Are the Session IDs provably resistant to statistical or cryptanalysis?	&lt;br /&gt;
* What elements of the Session IDs are time-linked?	&lt;br /&gt;
* What portions of the Session IDs are predictable?  	&lt;br /&gt;
* Can the next ID be deduced even given full knowledge of the generation algorithm and previous IDs?	&lt;br /&gt;
&lt;br /&gt;
'''Brute Force Attacks'''&amp;lt;br&amp;gt;&lt;br /&gt;
Brute force attacks inevitably lead on from questions relating to predictability and randomness.&lt;br /&gt;
The variance within the Session IDs must be considered together with application session durations and timeouts.  If the variation within the Session IDs is relatively small, and Session ID validity is long, the likelihood of a successful brute-force attack is much higher.&lt;br /&gt;
A long session ID (or rather one with a great deal of variance) and a shorter validity period would make it far harder to succeed in a brute force attack.&lt;br /&gt;
* How long would a brute-force attack on all possible Session IDs take?	&lt;br /&gt;
* Is the Session ID space large enough to prevent brute forcing? e.g. is the length of the key sufficient when compared to the valid life-span	&lt;br /&gt;
* Do delays between connection attempts with different Session IDs mitigate the risk of this attack?&lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example == &lt;br /&gt;
If you can access to session management schema implementation, you can check for the following:&lt;br /&gt;
* Random Session Token&lt;br /&gt;
The sessionID or Cookie issued to the client should not be easily predictable (don't use linear algorithm based on predictable variables or client IPArddr). The use of cryptographic algorithms with key lenght of 256 bits is encouraged (like AES).&lt;br /&gt;
* Token length&lt;br /&gt;
SessionID will be at least 50 characters length.&lt;br /&gt;
* Session Time-out&lt;br /&gt;
Session token should have a defined time-out (it depends on the criticality of the application managed data)&lt;br /&gt;
* Cookie configuration&lt;br /&gt;
** non-persistent: only RAM memory&lt;br /&gt;
** secure (set only on HTTPS channel):  Set Cookie: cookie=data; path=/; domain=.aaa.it; secure&lt;br /&gt;
** [[HTTPOnly]] (not readable by a script):  Set Cookie: cookie=data; path=/; domain=.aaa.it; [[HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Gunter Ollmann: &amp;quot;Web Based Session Management&amp;quot; - http://www.technicalinfo.net&lt;br /&gt;
* RFCs 2109 &amp;amp; 2965: &amp;quot;HTTP State Management Mechanism&amp;quot; - http://www.ietf.org/rfc/rfc2965.txt, http://www.ietf.org/rfc/rfc2109.txt&lt;br /&gt;
* RFC 2616: &amp;quot;Hypertext Transfer Protocol -- HTTP/1.1&amp;quot; - http://www.ietf.org/rfc/rfc2616.txt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Category:OWASP Testing Project AoC}}&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Session_Management_Schema_(OTG-SESS-001)&amp;diff=20288</id>
		<title>Testing for Session Management Schema (OTG-SESS-001)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Session_Management_Schema_(OTG-SESS-001)&amp;diff=20288"/>
				<updated>2007-07-27T17:31:55Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Linked keyword HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[http://www.owasp.org/index.php/Web_Application_Penetration_Testing_AoC Up]]&amp;lt;br&amp;gt;&lt;br /&gt;
{{Template:OWASP Testing Guide v2}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
In order to avoid continuous authentication for each page of a website or service, web applications implement various mechanisms to store and validate credentials for a pre-determined timespan.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
These mechanisms are known as Session Management and while they're most important in order to increase the ease of use and user-friendliness of the application, they can be exploited by a pen tester to gain access to a user account without the need to provide correct credentials.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
The session management schema should be considered alongside the authentication and authorization schema, and cover at least the questions below from a non-technical point of view:&lt;br /&gt;
* Will the application be accessed from shared systems? e.g. Internet Café	 &amp;lt;br&amp;gt;&lt;br /&gt;
* Is application security of prime concern to the visiting client/customer?	&amp;lt;br&amp;gt;&lt;br /&gt;
* How many concurrent sessions may a user have?	&amp;lt;br&amp;gt;&lt;br /&gt;
* How long is the inactive timeout on the application?&amp;lt;br&amp;gt;	&lt;br /&gt;
* How long is the active timeout?	&amp;lt;br&amp;gt;&lt;br /&gt;
* Are sessions transferable from one source IP to another?	&amp;lt;br&amp;gt;&lt;br /&gt;
* Is ‘remember my username’ functionality provided?	&amp;lt;br&amp;gt;&lt;br /&gt;
* Is ‘automatic login’ functionality provided?	&amp;lt;br&amp;gt;&lt;br /&gt;
Having identified the schema in place, the application and its logic must be examined to ensure the proper implementation of the schema.&lt;br /&gt;
This phase of testing is intrinsically linked with general application security testing.  Whilst the first Schema questions (is the schema suitable for the site and does the schema meet the application provider’s requirements?) can be analysed in abstract, the final question (does the site implement the specified schema?) must be considered alongside other technical testing. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The identified schema should be analyzed against best practice within the context of the site during our penetration test.&lt;br /&gt;
Where the defined schema deviates from security best practice, the associated risks should be identified and described within the context of the environment.  Security risks and issues should be detailed and quantified, but ultimately the application provider must make decisions based on the security and usability of the application.&lt;br /&gt;
For example, if it is determined that the site has been designed without inactive session timeouts, the application provider should be advised about risks such as replay attacks, long-term attacks based on stolen or compromised Session IDs, and abuse of a shared terminal where the application was not logged out.  They must then consider these against other requirements such as convenience of use for clients and disruption of the application by forced re-authentication.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''' Session Management Implementation'''&amp;lt;br&amp;gt;&lt;br /&gt;
In this Chapter we describe how to analyse a Session Schema and how to test it. Technical security testing of Session Management implementation covers two key areas:&lt;br /&gt;
* Integrity of Session ID creation&lt;br /&gt;
* Secure management of active sessions and Session IDs&lt;br /&gt;
The Session ID should be sufficiently unpredictable and abstracted from any private information, and the Session management should be logically secured to prevent any manipulation or circumvention of application security.&lt;br /&gt;
These two key areas are interdependent, but should be considered separately for a number of reasons.&lt;br /&gt;
Firstly, the choice of underlying technology to provide the sessions is bewildering and can already include a large number of OTS products and an almost unlimited number of bespoke or proprietary implementations.  Whilst the same technical analysis must be performed on each, established vendor solutions may require a slightly different testing approach, and existing security research may exist on the implementation.&lt;br /&gt;
Secondly, even an unpredictable and abstract Session ID may be rendered completely ineffectual should the Session management be flawed.  Similarly, a strong and secure session management implementation may be undermined by a poor Session ID implementation.&lt;br /&gt;
Furthermore, the analyst should closely examine how (and if) the application uses the available Session management.  It is not uncommon to see Microsoft ISS server ASP Session IDs passed religiously back and forth during interaction with an application, only to discover that these are not used by the application logic at all.  It is therefore not correct to say that because an application is built on a ‘proven secure’ platform its Session Management is automatically secure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&lt;br /&gt;
''' Session Analysis'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Session Tokens (Cookie, SessionID or Hidden Field) themselves should be examined to ensure their quality from a security perspective.  They should be tested against criteria such as their randomness, uniqueness, resistance to statistical and cryptographic analysis and information leakage.&amp;lt;br&amp;gt;&lt;br /&gt;
* Token Structure &amp;amp; Information Leakage&lt;br /&gt;
The first stage is to examine the structure and content of a Session ID provided by the application.  A common mistake is to include specific data in the Token instead of issuing a generic value and referencing real data at the server side.&lt;br /&gt;
If the Session ID is clear-text, the structure and pertinent data may be immediately obvious as the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.100.1:owaspuser:password:15:58&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If part or the entire Token appears to be encoded or hashed, it should be compared to various techniques to check for obvious obfuscation.&lt;br /&gt;
For example the string “192.168.100.1:owaspuser:password:15:58” is represented in Hex, Base64 and as an MD5 hash:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hex	3139322E3136382E3130302E313A6F77617370757365723A70617373776F72643A31353A3538&lt;br /&gt;
Base64	MTkyLjE2OC4xMDAuMTpvd2FzcHVzZXI6cGFzc3dvcmQ6MTU6NTg=&lt;br /&gt;
MD5	01c2fc4f0a817afd8366689bd29dd40a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Having identified the type of obfuscation, it may be possible to decode back to the original data.  In most cases, however, this is unlikely.  Even so, it may be useful to enumerate the encoding in place from the format of the message.  Furthermore, if both the format and obfuscation technique can be deduced, automated brute-force attacks could be devised.&lt;br /&gt;
Hybrid tokens may include information such as IP address or User ID together with an encoded portion, as the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
owaspuser:192.168.100.1: a7656fafe94dae72b1e1487670148412&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Having analysed a single Session Token, the representative sample should be examined.&lt;br /&gt;
A simple analysis of the Tokens should immediately reveal any obvious patterns.  For example, a 32 bit Token may include 16 bits of static data and 16 bits of variable data.  This may indicate that the first 16 bits represent a fixed attribute of the user – e.g. the username or IP address.&lt;br /&gt;
If the second 16 bit chunk is incrementing at a regular rate, it may indicate a sequential or even time-based element to the Token generation.  See Examples.&lt;br /&gt;
If static elements to the Tokens are identified, further samples should be gathered, varying one potential input element at a time.  For example, login attempts through a different user account or from a different IP address may yield a variance in the previously static portion of the Session Token.&lt;br /&gt;
The following areas should be addressed during the single and multiple Session ID structure testing:&lt;br /&gt;
* What parts of the Session ID are static?	&lt;br /&gt;
* What clear-text proprietary information is stored in the Session ID?  &lt;br /&gt;
e.g. usernames/UID, IP addresses	&lt;br /&gt;
* What easily decoded proprietary information is stored?	&lt;br /&gt;
* What information can be deduced from the structure of the Session ID?	&lt;br /&gt;
* What portions of the Session ID are static for the same login conditions?	&lt;br /&gt;
* What obvious patterns are present in the Session ID as a whole, or individual portions?	&lt;br /&gt;
 &lt;br /&gt;
'''Session ID Predictability and Randomness'''&amp;lt;br&amp;gt;&lt;br /&gt;
Analysis of the variable areas (if any) of the Session ID should be undertaken to establish the existence of any recognizable or predictable patterns.&lt;br /&gt;
These analysis may be performed manually and with bespoke or OTS statistical or cryptanalytic tools in order to deduce any patterns in Session ID content.&lt;br /&gt;
Manual checks should include comparisons of Session IDs issued for the same login conditions – e.g. the same username, password and IP address.  Time is an important factor which must also be controlled.  High numbers of simultaneous connections should be made in order to gather samples in the same time window and keep that variable constant.  Even a quantization of 50ms or less may be too coarse and a sample taken in this way may reveal time-based components that would otherwise be missed.&lt;br /&gt;
Variable elements should be analysed over time to determine whether they are incremental in nature.  Where they are incremental, patterns relating to absolute or elapsed time should be investigated.  Many systems use time as a seed for their pseudo random elements.&lt;br /&gt;
Where the patterns are seemingly random, one-way hashes of time or other environmental variations should be considered as a possibility.  Typically, the result of a cryptographic hash is a decimal or hexadecimal number so should be identifiable.&lt;br /&gt;
In analysing Session IDs sequences, patterns or cycles, static elements and client dependencies should all be considered as possible contributing elements to the structure and function of the application.&lt;br /&gt;
* Are the Session IDs provably random in nature?  e.g. Can the result be reproduced?  &lt;br /&gt;
* Do the same input conditions produce the same ID on a subsequent run?	&lt;br /&gt;
* Are the Session IDs provably resistant to statistical or cryptanalysis?	&lt;br /&gt;
* What elements of the Session IDs are time-linked?	&lt;br /&gt;
* What portions of the Session IDs are predictable?  	&lt;br /&gt;
* Can the next ID be deduced even given full knowledge of the generation algorithm and previous IDs?	&lt;br /&gt;
&lt;br /&gt;
'''Brute Force Attacks'''&amp;lt;br&amp;gt;&lt;br /&gt;
Brute force attacks inevitably lead on from questions relating to predictability and randomness.&lt;br /&gt;
The variance within the Session IDs must be considered together with application session durations and timeouts.  If the variation within the Session IDs is relatively small, and Session ID validity is long, the likelihood of a successful brute-force attack is much higher.&lt;br /&gt;
A long session ID (or rather one with a great deal of variance) and a shorter validity period would make it far harder to succeed in a brute force attack.&lt;br /&gt;
* How long would a brute-force attack on all possible Session IDs take?	&lt;br /&gt;
* Is the Session ID space large enough to prevent brute forcing? e.g. is the length of the key sufficient when compared to the valid life-span	&lt;br /&gt;
* Do delays between connection attempts with different Session IDs mitigate the risk of this attack?&lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example == &lt;br /&gt;
If you can access to session management schema implementation, you can check for the following:&lt;br /&gt;
* Random Session Token&lt;br /&gt;
The sessionID or Cookie issued to the client should not be easily predictable (don't use linear algorithm based on predictable variables or client IPArddr). The use of cryptographic algorithms with key lenght of 256 bits is encouraged (like AES).&lt;br /&gt;
* Token length&lt;br /&gt;
SessionID will be at least 50 characters length.&lt;br /&gt;
* Session Time-out&lt;br /&gt;
Session token should have a defined time-out (it depends on the criticality of the application managed data)&lt;br /&gt;
* Cookie configuration&lt;br /&gt;
** non-persistent: only RAM memory&lt;br /&gt;
** secure (set only on HTTPS channel):  Set Cookie: cookie=data; path=/; domain=.aaa.it; secure&lt;br /&gt;
** [[HTTPOnly]] (not readable by a script):  Set Cookie: cookie=data; path=/; domain=.aaa.it; [[HttpOnly]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Gunter Ollmann: &amp;quot;Web Based Session Management&amp;quot; - http://www.technicalinfo.net&lt;br /&gt;
* RFCs 2109 &amp;amp; 2965: &amp;quot;HTTP State Management Mechanism&amp;quot; - http://www.ietf.org/rfc/rfc2965.txt, http://www.ietf.org/rfc/rfc2109.txt&lt;br /&gt;
* RFC 2616: &amp;quot;Hypertext Transfer Protocol -- HTTP/1.1&amp;quot; - http://www.ietf.org/rfc/rfc2616.txt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Category:OWASP Testing Project AoC}}&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Test_HTTP_Methods_(OTG-CONFIG-006)&amp;diff=20287</id>
		<title>Test HTTP Methods (OTG-CONFIG-006)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Test_HTTP_Methods_(OTG-CONFIG-006)&amp;diff=20287"/>
				<updated>2007-07-27T17:26:48Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Linked keyword HTTPOnly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[http://www.owasp.org/index.php/Web_Application_Penetration_Testing_AoC Up]]&amp;lt;br&amp;gt;&lt;br /&gt;
{{Template:OWASP Testing Guide v2}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
In this test we check that the web server is not configured to allow potentially dangerous HTTP commands (methods) and that Cross Site Tracing (XST) is not possible&amp;lt;br&amp;gt;&lt;br /&gt;
== Short Description of the Issue (Topic and Explanation) == &lt;br /&gt;
While GET and POST are by far the most common methods that are used to access information provided by a web server, the Hypertext Transfer Protocol (HTTP) allows several other (and somewhat less known) methods. RFC  2616 (which describes HTTP version 1.1 which is the today standard) defines the following eight methods:&lt;br /&gt;
&lt;br /&gt;
* HEAD&lt;br /&gt;
* GET&lt;br /&gt;
* POST&lt;br /&gt;
* PUT&lt;br /&gt;
* DELETE&lt;br /&gt;
* TRACE&lt;br /&gt;
* OPTIONS&lt;br /&gt;
* CONNECT&lt;br /&gt;
&lt;br /&gt;
Some of these methods can potentially pose a security risk for a web application, as they allow an attacker to modify the files stored on the web server and, in some scenarios, steal the credentials of legitimate users. More specifically, the methods that should be disabled are the following:&lt;br /&gt;
&lt;br /&gt;
* PUT: This method allows a client to upload new files on the web server. An attacker can exploit it by uploading malicious files (e.g.: an asp file that executes commands by invoking cmd.exe), or by simply using the victim server as a file repository&lt;br /&gt;
* DELETE: This method allows a client to delete a file on the web server. An attacker can exploit it as a very simple and direct way to deface a web site or to mount a DoS attack&lt;br /&gt;
* CONNECT:  This method could allow a client to use the web server as a proxy&lt;br /&gt;
* TRACE: This method simply echoes back to the client whatever string has been sent to the server, and it is used mainly for debugging purposes. This method, apparently harmless, can be used to mount an attack known as Cross Site Tracing, which has been discovered by Jeremiah Grossman (see links at the bottom of the page)&lt;br /&gt;
&lt;br /&gt;
If an application needs one or more of these methods, it is important to check that their use is properly limited to trusted users and safe conditions.&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Discover the Supported Methods''' &amp;lt;br&amp;gt;&lt;br /&gt;
To perform this test, we need some way to figure out which HTTP methods are supported by the web server we are examining. The OPTIONS HTTP method provides us with the most direct and effective way to do that. RFC 2616 states that “The OPTIONS method represents a request for information about the  communication options available on the request/response chain identified by the Request-URI”. &lt;br /&gt;
&lt;br /&gt;
The testing method is extremely straightforward and we only need to fire up netcat (or telnet):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
icesurfer@nightblade ~ $ nc www.victim.com 80 &lt;br /&gt;
OPTIONS / HTTP/1.1&lt;br /&gt;
Host: www.victim.com&lt;br /&gt;
&lt;br /&gt;
HTTP/1.1 200 OK&lt;br /&gt;
Server: Microsoft-IIS/5.0&lt;br /&gt;
Date: Tue, 31 Oct 2006 08:00:29 GMT&lt;br /&gt;
Connection: close&lt;br /&gt;
Allow: GET, HEAD, POST, TRACE, OPTIONS&lt;br /&gt;
Content-Length: 0&lt;br /&gt;
&lt;br /&gt;
icesurfer@nightblade ~ $ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can see in the example, OPTIONS provides a list of the methods that are supported by the web server, and in this case we can see, for instance, that TRACE method is enabled. The danger that is posed by this method is illustrated in the following section&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
'''Test XST Potential'''&amp;lt;br&amp;gt;&lt;br /&gt;
Note: in order to understand the logic and the goals of this attack you need to be familiar with [[Cross_site_scripting_AoC | Cross Site Scripting attacks]].&lt;br /&gt;
&lt;br /&gt;
The TRACE method, while apparently harmless, can be successfully leveraged in some scenarios to steal legitimate users' credentials. This attack technique was discovered by Jeremiah Grossman in 2003, in an attempt to bypass the [[HTTPOnly]] tag that Microsoft introduced in Internet Explorer 6 sp1 to protect cookies from being accessed by JavaScript. As a matter of fact, one of the most recurring attack patterns in Cross Site Scripting is to access the document.cookie object and send it to a web server controlled by the attacker so that he/she can hijack the victim's session. Tagging a cookie as httpOnly forbids JavaScript to access it, protecting it from being sent to a third party. However, the TRACE method can be used to bypass this protection and access the cookie even in this scenario.&lt;br /&gt;
&lt;br /&gt;
As mentioned before, TRACE simply returns any string that is sent to the web server. In order to verify its presence (or to double-check the results of the OPTIONS request shown above), we can proceed as shown in the following example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
icesurfer@nightblade ~ $ nc www.victim.com 80&lt;br /&gt;
TRACE / HTTP/1.1&lt;br /&gt;
Host: www.victim.com&lt;br /&gt;
&lt;br /&gt;
HTTP/1.1 200 OK&lt;br /&gt;
Server: Microsoft-IIS/5.0&lt;br /&gt;
Date: Tue, 31 Oct 2006 08:01:48 GMT&lt;br /&gt;
Connection: close&lt;br /&gt;
Content-Type: message/http&lt;br /&gt;
Content-Length: 39&lt;br /&gt;
&lt;br /&gt;
TRACE / HTTP/1.1&lt;br /&gt;
Host: www.victim.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can see, the response body is exactly a copy of our original request, meaning that our target allows this method. Now, where is the danger lurking? If we instruct a browser to issue a TRACE request to the web server, and this browser has a cookie for that domain, the cookie will be automatically included in the request headers, and will therefore echoed back in the resulting response. At that point, the cookie string will be accessible by JavaScript and it will be finally possible to send it to a third party even when the cookie is tagged as httpOnly.&lt;br /&gt;
&lt;br /&gt;
There are multiple ways to make a browser issue a TRACE request, as the XMLHTTP ActiveX control in Internet Explorer and XMLDOM in Mozilla and Netscape. However, for security reasons the browser is allowed to start a connection only to the domain where the hostile script resides. This is a mitigating factor, as the attacker needs to combine the TRACE method with another vulnerability in order to mount the attack. Basically, an attacker has two ways to successfully launch a Cross Site Tracing attack:&lt;br /&gt;
&lt;br /&gt;
* 1.Leveraging another server-side vulnerability: the attacker injects the hostile JavaScript snippet, that contains the TRACE request, in the vulnerable application, as in a normal Cross Site Scripting attack&lt;br /&gt;
* 2.Leveraging a client-side vulnerability: the attacker creates a malicious website that contains the hostile JavaScript snippet and exploits some cross-domain vulnerability of the browser of the victim, in order to make the JavaScript code successfully perform a connection to the site that supports the TRACE method and that originated the cookie that the attacker is trying to steal.&lt;br /&gt;
&lt;br /&gt;
More detailed information, together with code samples, can be found in the original whitepaper written by Jeremiah Grossman.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example == &lt;br /&gt;
The testing in a Gray Box scenario follows the same steps of a Black Box scenario&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* RFC 2616: “Hypertext Transfer Protocol -- HTTP/1.1” &lt;br /&gt;
* RFC 2109 and RFC 2965: “HTTP State Management Mechanism” &lt;br /&gt;
* Jeremiah Grossman: &amp;quot;Cross Site Tracing (XST)&amp;quot; - http://www.cgisecurity.com/whitehat-mirror/WH-WhitePaper_XST_ebook.pdf&amp;lt;br&amp;gt;&lt;br /&gt;
* Amit Klein: &amp;quot;XS(T) attack variants which can, in some cases, eliminate the need for TRACE&amp;quot; - http://www.securityfocus.com/archive/107/308433&lt;br /&gt;
'''Tools'''&lt;br /&gt;
* NetCat - http://www.vulnwatch.org/netcat&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Category:OWASP Testing Project AoC}}&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20282</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20282"/>
				<updated>2007-07-27T16:04:47Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Updated 'overview' and 'references' section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce and explain the need for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an ''additional flag'' set on the client using a HTTP response header. Using the HTTPOnly flag helps mitigate the risk of client side script accessing the session cookie.&lt;br /&gt;
&lt;br /&gt;
*The figure below shows the syntax used within the '''HTTP response header''':&lt;br /&gt;
&lt;br /&gt;
 Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
 [; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
 [; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script or the web site that originally set the cookie. As a result, even if a cross-site scripting '''(XSS)''' flaw exists, and a user accidentally accesses a link that exploits this flaw, Internet Explorer will not reveal the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a website attempts to set an HTTPOnly cookie, the cookie will be either ignored or demoted to a traditional, scriptable cookie. Unfortunately, this makes your session cookie vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Mitigating XSS using HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Michael Howard], Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks succeed because a session cookie has been leaked. A server could help mitigate this issue by setting a flag within a ''HTTP response header,'' indicating a session cookie should never be accessed by the client.&lt;br /&gt;
&lt;br /&gt;
If Internet Explorer detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, Internet Explorer ''returns an empty string''. As a result, the attack fails by preventing the malicious XSS code from sending the data to an attacker's website. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Howard], [http://msdn2.microsoft.com/en-us/library/ms972826.aspx]&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
[2] [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Mitigating Cross-site Scripting with HTTP-Only Cookies]&lt;br /&gt;
&lt;br /&gt;
[3] Howard, Michael. [http://msdn2.microsoft.com/en-us/library/ms972826.aspx Some Bad News and Some Good News]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20277</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20277"/>
				<updated>2007-07-27T15:31:59Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Added references and two headings including text within overview section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
The goal of this section is to introduce and explain the need for HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Who developed HTTPOnly? When? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to Jordan Wiens' daily blog article, “No cookie for you!,” in 2002, HTTPOnly cookies were first implemented in Internet Explorer 6 SP1 by Microsoft Internet Explorer developers. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html Wiens],&lt;br /&gt;
[http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; What is HTTPOnly? &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to the [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft Developer Network], an HTTPOnly cookie is an additional flag set on the client using a HTTP response header to help mitigate the risk of client side script accessing the session cookie.  &lt;br /&gt;
&lt;br /&gt;
*The figure below shows the syntax used within the HTTP response header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set-Cookie: &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;[; &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;]&lt;br /&gt;
[; expires=&amp;lt;date&amp;gt;][; domain=&amp;lt;domain_name&amp;gt;]&lt;br /&gt;
[; path=&amp;lt;some_path&amp;gt;][; secure][; HttpOnly]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script, even by the Web site that originally set the cookie. As a result, even if a cross-site scripting flaw exists, and a user accidently accesses a link that exploits this flaw, Internet Explorer will not send the cookie to a third party.&lt;br /&gt;
&lt;br /&gt;
If a browser does not support HTTPOnly and a web site attempts to set an HTTPOnly-cookie, the cookie is either ignored or demoted to a traditional, scriptable cookie. Unfortunately, this makes your session cookie vulnerable. [http://msdn2.microsoft.com/en-us/library/ms533046.aspx Microsoft], [http://msdn2.microsoft.com/en-us/library/ms533046.aspx]&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
[1] Wiens, Jordan. [http://www.networkcomputing.com/blog/dailyblog/archives/2007/03/no_cookie_for_y.html No cookie for you!&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20260</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20260"/>
				<updated>2007-07-27T13:09:57Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 8 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20244</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20244"/>
				<updated>2007-07-26T20:41:34Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Disabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; Enabling HTTPOnly &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display on the screen only containing the session ID, not the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 7 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20243</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20243"/>
				<updated>2007-07-26T20:39:34Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Added h5 headings for ease of scanning&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; HTTPOnly Disabled &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;h5 style=color:#2E8B57&amp;gt; &amp;lt;u&amp;gt; HTTPOnly Enabled &amp;lt;/u&amp;gt; &amp;lt;/h5&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display on the screen only containing the session ID, not the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 7 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20242</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20242"/>
				<updated>2007-07-26T20:32:48Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;2&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ '''Table 1:''' Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that since HTTPOnly was not enabled, the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display on the screen only containing the session ID, not the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 7 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20241</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20241"/>
				<updated>2007-07-26T20:20:27Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Step 6 Completed with images implemented&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1: Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that since HTTPOnly was not enabled, the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display on the screen only containing the session ID, not the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 7 - Enforced Cookie Write Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig9-No_Cookie_Write_Protection.PNG|frame|center|Figure 9 - Unenforced Cookie Write Protection]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:Fig9-No_Cookie_Write_Protection.PNG&amp;diff=20240</id>
		<title>File:Fig9-No Cookie Write Protection.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:Fig9-No_Cookie_Write_Protection.PNG&amp;diff=20240"/>
				<updated>2007-07-26T20:17:47Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Screen shot of unenforced cookie write protection for WebGoat's HTTPOnly lesson.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Screen shot of unenforced cookie write protection for WebGoat's HTTPOnly lesson.&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20239</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20239"/>
				<updated>2007-07-26T20:13:42Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Updated: Step 6&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1: Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that since HTTPOnly was not enabled, the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display on the screen only containing the session ID, not the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*Finally, we will test if the browser allows '''write access''' to the cookie with HTTPOnly enabled.&lt;br /&gt;
&lt;br /&gt;
 6) Select the '''&amp;quot;Write Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, client side modification will be unsuccessful in writing to the '''‘unique2u’ cookie''' and an alert dialog box will display only containing the session ID as shown below in '''figure 8'''. &lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the write protection property of HTTPOnly flag for the '''‘unique2u’ cookie''', the cookie will be successfully modified to ''HACKED'' on the client side as shown below in '''figure 9'''.&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20236</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20236"/>
				<updated>2007-07-26T20:08:46Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Updated: Text as well as implemented figures 6 &amp;amp; 7&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1: Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that since HTTPOnly was not enabled, the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig5-Turning_HTTPOnly_On.PNG|frame|center|Figure 5 - Enabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 5) After enabling HTTPOnly, select the '''&amp;quot;Read Cookie&amp;quot;''' button.&lt;br /&gt;
&lt;br /&gt;
*If the browser enforces the HTTPOnly flag properly, an alert dialog box will display on the screen only containing the session ID, not the contents of the '''‘unique2u’ cookie''' as shown below in '''figure 6'''. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig6-Cookie_Read_Protection.PNG|frame|center|Figure 6 - Enforced Cookie Read Protection]]&lt;br /&gt;
&lt;br /&gt;
*However, if the browser does not enforce the HTTPOnly flag properly, an alert dialog box will display both the '''‘unique2u’ cookie''' and session ID as shown below in '''figure 7'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig7-No_Cookie_Read_Protection.PNG|frame|center|Figure 7 - Unenforced Cookie Read Protection]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:Fig7-No_Cookie_Read_Protection.PNG&amp;diff=20235</id>
		<title>File:Fig7-No Cookie Read Protection.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:Fig7-No_Cookie_Read_Protection.PNG&amp;diff=20235"/>
				<updated>2007-07-26T20:01:07Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Screen shot of no cookie read protection for WebGoat HTTPOnly Lesson.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Screen shot of no cookie read protection for WebGoat HTTPOnly Lesson.&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:Fig6-Cookie_Read_Protection.PNG&amp;diff=20234</id>
		<title>File:Fig6-Cookie Read Protection.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:Fig6-Cookie_Read_Protection.PNG&amp;diff=20234"/>
				<updated>2007-07-26T20:00:25Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Screen shot of cookie read protection for WebGoat HTTPOnly Lesson.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Screen shot of cookie read protection for WebGoat HTTPOnly Lesson.&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:Fig5-Turning_HTTPOnly_On.PNG&amp;diff=20233</id>
		<title>File:Fig5-Turning HTTPOnly On.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:Fig5-Turning_HTTPOnly_On.PNG&amp;diff=20233"/>
				<updated>2007-07-26T19:59:38Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Screen shot of enabling HTTPOnly within WebGoat HTTPOnly lesson&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Screen shot of enabling HTTPOnly within WebGoat HTTPOnly lesson&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20232</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20232"/>
				<updated>2007-07-26T19:52:50Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1: Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that since HTTPOnly was not enabled, the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
*As you have seen thus far, '''browsing without HTTPOnly''' on is a potential '''''threat'''''. Next, we will '''enable HTTPOnly''' to demonstrate how this flag protects the cookie. &lt;br /&gt;
&lt;br /&gt;
 4) Select the ''radio button'' to enable HTTPOnly as shown below in '''figure 5'''.&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20231</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20231"/>
				<updated>2007-07-26T19:48:43Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Text and figures 3 &amp;amp; 4 implemented&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1: Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
 1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
 2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
*An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the '''‘unique2u’ cookie''' was successfully read as shown below in '''figure 3'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig3-Read_HTTPOnly_Off.PNG|frame|center|Figure 3 - Cookie Successfully Read with HTTPOnly Off]]&lt;br /&gt;
&lt;br /&gt;
 3) With HTTPOnly remaining disabled, select the '''“Write Cookie” ''' button.&lt;br /&gt;
&lt;br /&gt;
*An alert dialog box will display on the screen notifying you that since HTTPOnly was not enabled, the '''‘unique2u’ cookie''' was successfully modified on the client side as shown below in '''figure 4'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig4-Write_HTTPOnly_Off.PNG|frame|center|Figure 4 - Cookie Successfully Written with HTTPOnly Off]]&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:Fig4-Write_HTTPOnly_Off.PNG&amp;diff=20230</id>
		<title>File:Fig4-Write HTTPOnly Off.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:Fig4-Write_HTTPOnly_Off.PNG&amp;diff=20230"/>
				<updated>2007-07-26T19:39:16Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Screen shot of WebGoat HTTPOnly Lesson&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Screen shot of WebGoat HTTPOnly Lesson&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:Fig3-Read_HTTPOnly_Off.PNG&amp;diff=20229</id>
		<title>File:Fig3-Read HTTPOnly Off.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:Fig3-Read_HTTPOnly_Off.PNG&amp;diff=20229"/>
				<updated>2007-07-26T19:38:11Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: WebGoat HTTPOnly lesson screenshot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;WebGoat HTTPOnly lesson screenshot&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20228</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20228"/>
				<updated>2007-07-26T19:32:42Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: Changed Figure 1 to a thumbnail&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1: Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|thumb|175px|right|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
   1) Select the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
   2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the ‘'''unique2u'''’ cookie was successfully read as shown below in '''figure 3'''.&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20226</id>
		<title>HttpOnly</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HttpOnly&amp;diff=20226"/>
				<updated>2007-07-26T19:13:58Z</updated>
		
		<summary type="html">&lt;p&gt;Rknell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
== Browsers Supporting HTTPOnly ==&lt;br /&gt;
&lt;br /&gt;
Using WebGoat's HTTPOnly lesson, the following web browsers have been tested for HTTPOnly capabilities. The results are listed below in '''table 1'''.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot; width=&amp;quot;100%&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1: Browsers Supporting HTTPOnly&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Browser'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Version'''&lt;br /&gt;
! style=&amp;quot;background:black; color:white&amp;quot; | '''Supports HTTPOnly?'''&lt;br /&gt;
|-&lt;br /&gt;
| Microsoft Internet Explorer&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 6 (SP1) - 7&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Mozilla Firefox&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 2.0.0.5&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | Partially*&lt;br /&gt;
|-&lt;br /&gt;
| Netscape Navigator&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.0b2&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|-&lt;br /&gt;
| Opera&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | 9.22&lt;br /&gt;
| align=&amp;quot;center&amp;quot; | No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*An attacker could still access the session identifier cookie using a '''[http://ha.ckers.org/blog/20070719/firefox-implements-httponly-and-is-vulnerable-to-xmlhttprequest/ XmlHttpRequest]'''.&lt;br /&gt;
&lt;br /&gt;
== Using WebGoat to Test for HTTPOnly Capabilities ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Getting Started &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming you have already installed and launched WebGoat, begin by navigating to the ‘HTTPOnly Test’ lesson located within the Cross-Site Scripting ('''XSS''') category. After selecting the ‘HTTPOnly Test’ link, as shown below in '''figure 1''', you are now able to begin testing web browsers that support HTTPOnly.&lt;br /&gt;
&lt;br /&gt;
[[Image:Click_link.JPG|frame|center|Figure 1 - Accessing WebGoat's HTTPOnly Test Lesson]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Lesson Goal &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the HTTPOnly flag is set, then your browser should not allow client-side script to access the cookie. Unfortunately, since the attribute is relatively new, several browsers neglect to handle the new attribute properly.&lt;br /&gt;
&lt;br /&gt;
The '''purpose''' of this lesson is to test whether your browser supports the '''HTTPOnly cookie flag'''. ''Note the value of the'' '''''unique2u cookie'''''. If your browser supports HTTPOnly and you enable it for a cookie, client side code should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h3 style=color:#4682B4&amp;gt; &amp;lt;u&amp;gt; Testing Web Browsers for HTTPOnly Support &amp;lt;/u&amp;gt; &amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following test was performed on two browsers, '''Internet Explorer 7''' and '''Opera 9.22''', to demonstrate the results when the HTTPOnly flag is enforced properly. As you will see, IE7 properly enforces the HTTPOnly flag, whereas Opera does not properly enforce the HTTPOnly flag.&lt;br /&gt;
&lt;br /&gt;
   1) Begin by selection the option to '''turn HTTPOnly off''' as shown below in '''figure 2'''.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig2-Disabling_HTTPOnly.PNG|frame|center|Figure 2 - Disabling HTTPOnly]]&lt;br /&gt;
&lt;br /&gt;
   2) After turning HTTPOnly off, select the '''“Read Cookie”''' button. &lt;br /&gt;
An alert dialog box will display on the screen notifying you that ''since HTTPOnly was not enabled'', the ‘'''unique2u'''’ cookie was successfully read as shown below in '''figure 3'''.&lt;/div&gt;</summary>
		<author><name>Rknell</name></author>	</entry>

	</feed>