<?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=Gladwin</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=Gladwin"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Gladwin"/>
		<updated>2026-05-06T13:00:01Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SecureFlag&amp;diff=142091</id>
		<title>SecureFlag</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SecureFlag&amp;diff=142091"/>
				<updated>2013-01-09T20:13:05Z</updated>
		
		<summary type="html">&lt;p&gt;Gladwin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
&lt;br /&gt;
= Overview&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The secure flag is an option that can be set by the application server when sending a new cookie to the user within an HTTP&amp;amp;nbsp;Response. The purpose of the secure flag is to prevent cookies from being observed by unauthorized parties due to the transmission of a the cookie in clear text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To accomplish this goal, browsers which support the secure flag will only send cookies with the secure flag when the request is going to a HTTPS page. Said in another way, the browser will not send a cookie with the secure flag set over an unencrypted HTTP&amp;amp;nbsp;request.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting the secure flag, the browser will prevent the transmission of a cookie over an unencrypted channel.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Setting the Secure Flag =&lt;br /&gt;
&lt;br /&gt;
Following sections describes setting the Secure Flag in respective technologies.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java ==&lt;br /&gt;
&lt;br /&gt;
=== Servlet 3.0 (Java EE 6) ===&lt;br /&gt;
Sun Java EE supports secure flag in Cookie interface since version 6 (Servlet class version 3)[http://java.sun.com/javaee/6/docs/api/javax/servlet/http/Cookie.html#setSecure%28boolean%29], also for session cookies (JSESSIONID)[http://java.sun.com/javaee/6/docs/api/javax/servlet/SessionCookieConfig.html#setSecure%28boolean%29]. Methods ''setSecure'' and ''isSecure'' can be used to set and check for secure value in cookies.&lt;br /&gt;
&lt;br /&gt;
==== web.xml ====&lt;br /&gt;
Servlet 3.0 (Java EE 6) introduced a standard way to configure secure attribute for the session cookie, this can be done by applying the following configuration in web.xml&lt;br /&gt;
 &amp;amp;lt;session-config&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;cookie-config&amp;amp;gt;&lt;br /&gt;
   &amp;amp;lt;secure&amp;amp;gt;true&amp;amp;lt;/secure&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;/cookie-config&amp;gt;&lt;br /&gt;
 &amp;amp;lt;session-config&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tomcat ===&lt;br /&gt;
In '''Tomcat 6''' if the first request for session is using ''https'' then it automatically sets secure attribute on session cookie.&lt;br /&gt;
&lt;br /&gt;
=== Setting it as a custom header ===&lt;br /&gt;
For '''older versions''' the workaround is to rewrite JSESSIONID value using and setting it as a custom header. The drawback is that servers can be configured to use a different session identifier than JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
 String sessionid = request.getSession().getId();&lt;br /&gt;
 response.setHeader(&amp;quot;SET-COOKIE&amp;quot;, &amp;quot;JSESSIONID=&amp;quot; + sessionid + &amp;quot;; secure&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
=== Environment consideration ===&lt;br /&gt;
&lt;br /&gt;
With this flag always set, sessions won't work in environments(development/test/etc.) that may use http. SessionCookieConfig [http://java.sun.com/javaee/6/docs/api/javax/servlet/SessionCookieConfig.html#setSecure%28boolean%29] interface or setting custom header[https://www.owasp.org/index.php/SecureFlag#Setting_it_as_a_custom_header] trick can be leveraged to configure setting of this flag differently for each environment and can be driven by application configuration. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ASP.NET ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;httpCookies requireSSL=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Testing for the Secure Flag&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
= Related Articles&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/Testing_for_cookies_attributes_(OWASP-SM-002) Testing for Cookie Attributes]&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.troyhunt.com/2011/11/owasp-top-10-for-net-developers-part-9.html&lt;/div&gt;</summary>
		<author><name>Gladwin</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SecureFlag&amp;diff=142090</id>
		<title>SecureFlag</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SecureFlag&amp;diff=142090"/>
				<updated>2013-01-09T20:12:30Z</updated>
		
		<summary type="html">&lt;p&gt;Gladwin: Java - Environment consideration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
&lt;br /&gt;
= Overview&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The secure flag is an option that can be set by the application server when sending a new cookie to the user within an HTTP&amp;amp;nbsp;Response. The purpose of the secure flag is to prevent cookies from being observed by unauthorized parties due to the transmission of a the cookie in clear text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To accomplish this goal, browsers which support the secure flag will only send cookies with the secure flag when the request is going to a HTTPS page. Said in another way, the browser will not send a cookie with the secure flag set over an unencrypted HTTP&amp;amp;nbsp;request.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting the secure flag, the browser will prevent the transmission of a cookie over an unencrypted channel.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Setting the Secure Flag =&lt;br /&gt;
&lt;br /&gt;
Following sections describes setting the Secure Flag in respective technologies.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java ==&lt;br /&gt;
&lt;br /&gt;
=== Servlet 3.0 (Java EE 6) ===&lt;br /&gt;
Sun Java EE supports secure flag in Cookie interface since version 6 (Servlet class version 3)[http://java.sun.com/javaee/6/docs/api/javax/servlet/http/Cookie.html#setSecure%28boolean%29], also for session cookies (JSESSIONID)[http://java.sun.com/javaee/6/docs/api/javax/servlet/SessionCookieConfig.html#setSecure%28boolean%29]. Methods ''setSecure'' and ''isSecure'' can be used to set and check for secure value in cookies.&lt;br /&gt;
&lt;br /&gt;
==== web.xml ====&lt;br /&gt;
Servlet 3.0 (Java EE 6) introduced a standard way to configure secure attribute for the session cookie, this can be done by applying the following configuration in web.xml&lt;br /&gt;
 &amp;amp;lt;session-config&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;cookie-config&amp;amp;gt;&lt;br /&gt;
   &amp;amp;lt;secure&amp;amp;gt;true&amp;amp;lt;/secure&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;/cookie-config&amp;gt;&lt;br /&gt;
 &amp;amp;lt;session-config&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tomcat ===&lt;br /&gt;
In '''Tomcat 6''' if the first request for session is using ''https'' then it automatically sets secure attribute on session cookie.&lt;br /&gt;
&lt;br /&gt;
=== Setting it as a custom header ===&lt;br /&gt;
For '''older versions''' the workaround is to rewrite JSESSIONID value using and setting it as a custom header. The drawback is that servers can be configured to use a different session identifier than JSESSIONID.&lt;br /&gt;
&lt;br /&gt;
 String sessionid = request.getSession().getId();&lt;br /&gt;
 response.setHeader(&amp;quot;SET-COOKIE&amp;quot;, &amp;quot;JSESSIONID=&amp;quot; + sessionid + &amp;quot;; secure&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Environment consideration ===&lt;br /&gt;
&lt;br /&gt;
With this flag always set, sessions won't work in environments(development/test/etc.) that may use http. SessionCookieConfig [http://java.sun.com/javaee/6/docs/api/javax/servlet/SessionCookieConfig.html#setSecure%28boolean%29] interface or setting custom header[https://www.owasp.org/index.php/SecureFlag#Setting_it_as_a_custom_header] trick can be leveraged to configure setting of this flag differently for each environment and can be driven by application configuration. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ASP.NET ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;httpCookies requireSSL=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Testing for the Secure Flag&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
= Related Articles&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/Testing_for_cookies_attributes_(OWASP-SM-002) Testing for Cookie Attributes]&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.troyhunt.com/2011/11/owasp-top-10-for-net-developers-part-9.html&lt;/div&gt;</summary>
		<author><name>Gladwin</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SecureFlag&amp;diff=142089</id>
		<title>SecureFlag</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SecureFlag&amp;diff=142089"/>
				<updated>2013-01-09T19:54:27Z</updated>
		
		<summary type="html">&lt;p&gt;Gladwin: Added section for Java&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
&lt;br /&gt;
= Overview&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The secure flag is an option that can be set by the application server when sending a new cookie to the user within an HTTP&amp;amp;nbsp;Response. The purpose of the secure flag is to prevent cookies from being observed by unauthorized parties due to the transmission of a the cookie in clear text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To accomplish this goal, browsers which support the secure flag will only send cookies with the secure flag when the request is going to a HTTPS page. Said in another way, the browser will not send a cookie with the secure flag set over an unencrypted HTTP&amp;amp;nbsp;request.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting the secure flag, the browser will prevent the transmission of a cookie over an unencrypted channel.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Setting the Secure Flag =&lt;br /&gt;
&lt;br /&gt;
Following sections describes setting the Secure Flag in respective technologies.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java ==&lt;br /&gt;
&lt;br /&gt;
=== Servlet 3.0 (Java EE 6) ===&lt;br /&gt;
Sun Java EE supports secure flag in Cookie interface since version 6 (Servlet class version 3)[http://java.sun.com/javaee/6/docs/api/javax/servlet/http/Cookie.html#setSecure%28boolean%29], also for session cookies (JSESSIONID)[http://java.sun.com/javaee/6/docs/api/javax/servlet/SessionCookieConfig.html#setSecure%28boolean%29]. Methods ''setSecure'' and ''isSecure'' can be used to set and check for secure value in cookies.&lt;br /&gt;
&lt;br /&gt;
==== web.xml ====&lt;br /&gt;
Servlet 3.0 (Java EE 6) introduced a standard way to configure secure attribute for the session cookie, this can be done by applying the following configuration in web.xml&lt;br /&gt;
 &amp;amp;lt;session-config&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;cookie-config&amp;amp;gt;&lt;br /&gt;
   &amp;amp;lt;secure&amp;amp;gt;true&amp;amp;lt;/secure&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;/cookie-config&amp;gt;&lt;br /&gt;
 &amp;amp;lt;session-config&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tomcat ===&lt;br /&gt;
In '''Tomcat 6''' if the first request for session is using ''https'' then it automatically sets secure attribute on session cookie.&lt;br /&gt;
&lt;br /&gt;
=== Setting it as a custom header ===&lt;br /&gt;
For '''older versions''' the workaround is to rewrite JSESSIONID value using and setting it as a custom header.&lt;br /&gt;
&lt;br /&gt;
Advantage of using custom rewrite trick is that we can configure it differently for each environment driven by application  configuration as most local development or test environments may use ''http''. &lt;br /&gt;
&lt;br /&gt;
The drawback is that servers can be configured to use a &amp;lt;b&amp;gt;different session identifier than JSESSIONID&amp;lt;/b&amp;gt;. It will be best if configuring this attribute could be a feature supported by Servlet containers.&lt;br /&gt;
&lt;br /&gt;
 String sessionid = request.getSession().getId();&lt;br /&gt;
 response.setHeader(&amp;quot;SET-COOKIE&amp;quot;, &amp;quot;JSESSIONID=&amp;quot; + sessionid + &amp;quot;; secure&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ASP.NET ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;httpCookies requireSSL=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Testing for the Secure Flag&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
= Related Articles&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/Testing_for_cookies_attributes_(OWASP-SM-002) Testing for Cookie Attributes]&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.troyhunt.com/2011/11/owasp-top-10-for-net-developers-part-9.html&lt;/div&gt;</summary>
		<author><name>Gladwin</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SecureFlag&amp;diff=142086</id>
		<title>SecureFlag</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SecureFlag&amp;diff=142086"/>
				<updated>2013-01-09T19:10:10Z</updated>
		
		<summary type="html">&lt;p&gt;Gladwin: Made ASP.NET as sub section of Setting the Secure Flag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
&lt;br /&gt;
= Overview&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The secure flag is an option that can be set by the application server when sending a new cookie to the user within an HTTP&amp;amp;nbsp;Response. The purpose of the secure flag is to prevent cookies from being observed by unauthorized parties due to the transmission of a the cookie in clear text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To accomplish this goal, browsers which support the secure flag will only send cookies with the secure flag when the request is going to a HTTPS page. Said in another way, the browser will not send a cookie with the secure flag set over an unencrypted HTTP&amp;amp;nbsp;request.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By setting the secure flag, the browser will prevent the transmission of a cookie over an unencrypted channel.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Setting the Secure Flag&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
==ASP.NET==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;httpCookies requireSSL=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Testing for the Secure Flag&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
= Related Articles&amp;lt;br&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/Testing_for_cookies_attributes_(OWASP-SM-002) Testing for Cookie Attributes]&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.troyhunt.com/2011/11/owasp-top-10-for-net-developers-part-9.html&lt;/div&gt;</summary>
		<author><name>Gladwin</name></author>	</entry>

	</feed>