<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Nette Framework forum : Development of Nette Framework : RFC – Request for Comments : Forms protected against CSRF by default</title>
<link>https://forum.nette.org/en</link>
<description>Nette Framework forum</description>
<language>en</language>
<docs>http://backend.userland.com/rss</docs>
<item>
	<title>Forms protected against CSRF by default (RFC – Request for Comments)</title>
	<dc:creator>David Grudl</dc:creator>
	<link>https://forum.nette.org/en/18898#p130070</link>
	<guid isPermaLink="false">130070@http://forum.nette.org/en</guid>
	<description>&lt;p&gt;What do you think about the following (implementation-easy) way?&lt;/p&gt;

&lt;p&gt;Nette will automatically send token in cookie named &lt;code&gt;__csrfs&lt;/code&gt; with
expiration &lt;code&gt;0&lt;/code&gt; (end of session) and&lt;br&gt;
all POST forms will always send a hidden field &lt;code&gt;__csrf&lt;/code&gt; with the same
token (masked against breach attack). On very low level (RequestFactory?) tokens
will be checked, whether they exist and are the same, and if not, error
403 will be thrown.&lt;/p&gt;

&lt;p&gt;Advantages:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;provides automatic protection for all forms, without the need to call
	addProtection()&lt;/li&gt;

	&lt;li&gt;does not depend on session&lt;/li&gt;

	&lt;li&gt;current error message (Please submit this form again) is actually
	antipattern :-(&lt;/li&gt;

	&lt;li&gt;tokens in a cookie (unlike in HTML) do not requires to change templates and
	are resistant to breach attack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cons:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;manually rendered forms without Latte will not work (note that
	&lt;code&gt;&amp;lt;/form n:name&amp;gt;&lt;/code&gt; and &lt;code&gt;{/form}&lt;/code&gt; in Latte
	automatically renders all HiddenFields, so I am talking about very special kind
	of rendering.)&lt;/li&gt;

	&lt;li&gt;disclosure of cookie token via XSS is a little bit easier, because is
	available on all pages. (It can be protected via HttpOnly but still exists
	problem with session hijacking, see below.)&lt;/li&gt;
&lt;/ul&gt;
</description>
	<pubDate>Thu, 13 Feb 2014 19:52:28 +0100</pubDate>
</item>
</channel>
</rss>
