<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>danielmiessler.com - Latest Comments in RESTful Programming and CSRF</title><link>http://drm.disqus.com/</link><description>https://danielmiessler.com/about/</description><atom:link href="https://drm.disqus.com/restful_programming_and_csrf/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sat, 29 Mar 2008 22:27:16 -0000</lastBuildDate><item><title>Re: RESTful Programming and CSRF</title><link>https://danielmiessler.com/blog/restful-programming-and-csrf#comment-11183641</link><description>&lt;p&gt;It's a dirty little secret of rails apps that many of them are susceptible to csrf attacks.  However, if you designed your rails app correctly (i.e. GET actions only show data, to delete you have to post with DELETE) it makes it a little more difficult, because you need a POST to change any data.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;There was a twitter 'virus' a few months that we discovered and destroyed that essentially created a form which created a tweet and POSTed the form automatically with javascript.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;My colleague Rick Olson wrote CSRF_killer plugin which automatically puts some hidden form variables into all of your forms, and effectively squashes any such attacks.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">court3nay</dc:creator><pubDate>Sat, 29 Mar 2008 22:27:16 -0000</pubDate></item><item><title>Re: RESTful Programming and CSRF</title><link>https://danielmiessler.com/blog/restful-programming-and-csrf#comment-11183638</link><description>&lt;p&gt;Ah, yes, I remember this now. Well, as I said, I wasn't claiming expertise, and I did in fact get a crucial piece wrong in this flash of "insight". The URLs were right, up until the action piece - the point of REST is to have the HTTP verb be the action. Not for the URL to indicate the action.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Right.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Thanks for the reminder, guys. That'll teach me to make 5 minute posts on a whim.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Miessler</dc:creator><pubDate>Sat, 29 Mar 2008 22:26:13 -0000</pubDate></item><item><title>Re: RESTful Programming and CSRF</title><link>https://danielmiessler.com/blog/restful-programming-and-csrf#comment-11183635</link><description>&lt;p&gt;RESTful URIs are associated with resources, not actions. URIs specifying actions are not RESTful. For RESTful web applications, HTTP verbs -- GET, PUT, POST, DELETE -- provide the actions.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steve Vinoski</dc:creator><pubDate>Sat, 29 Mar 2008 21:27:37 -0000</pubDate></item><item><title>Re: RESTful Programming and CSRF</title><link>https://danielmiessler.com/blog/restful-programming-and-csrf#comment-11183632</link><description>&lt;p&gt;Your examples don't look like REST to me.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;My understanding as as follows:&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://acme.com/products/cart/display" rel="nofollow noopener" target="_blank" title="http://acme.com/products/cart/display"&gt;http://acme.com/products/ca...&lt;/a&gt; isn't RESTful&lt;br&gt;but &lt;a href="http://acme.com/products/cart/" rel="nofollow noopener" target="_blank" title="http://acme.com/products/cart/"&gt;http://acme.com/products/cart/&lt;/a&gt; with a action of GET is&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://acme.com/account/delete" rel="nofollow noopener" target="_blank" title="http://acme.com/account/delete"&gt;http://acme.com/account/delete&lt;/a&gt; isn't RESTful&lt;br&gt;but &lt;a href="http://acme.com/account/" rel="nofollow noopener" target="_blank" title="http://acme.com/account/"&gt;http://acme.com/account/&lt;/a&gt; with an action of DELETE is&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Your other examples seem wrong too&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;You wouldn't have &lt;a href="http://somesite.com/product/1234/purchase" rel="nofollow noopener" target="_blank" title="http://somesite.com/product/1234/purchase"&gt;http://somesite.com/product...&lt;/a&gt;&lt;br&gt;You'd have &lt;a href="http://somesite.com/basket/" rel="nofollow noopener" target="_blank" title="http://somesite.com/basket/"&gt;http://somesite.com/basket/&lt;/a&gt; and to purchase a product you'd access it with POST and the product id&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://somecause.com/campaign/donate" rel="nofollow noopener" target="_blank" title="http://somecause.com/campaign/donate"&gt;http://somecause.com/campai...&lt;/a&gt; is the same deal, you'd do a POST on &lt;a href="http://somecause.com/campaign/" rel="nofollow noopener" target="_blank" title="http://somecause.com/campaign/"&gt;http://somecause.com/campaign/&lt;/a&gt; to update it with a new donation&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Any RESTful URL should be completely harmless when accessed via GET.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Andrew Ingram</dc:creator><pubDate>Sat, 29 Mar 2008 16:16:23 -0000</pubDate></item><item><title>Re: RESTful Programming and CSRF</title><link>https://danielmiessler.com/blog/restful-programming-and-csrf#comment-11183630</link><description>&lt;p&gt;Actions are still actions regardless of whether they are performed via RESTful URLs or not.  &lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Your example:&lt;br&gt;&lt;a href="http://somesite.com/product/1234/purchase" rel="nofollow noopener" target="_blank" title="http://somesite.com/product/1234/purchase"&gt;http://somesite.com/product...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;is no easier/harder to abuse with CSRF than something like:&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://somesite.com/cgi-bin/purchase.cgi?product=1234" rel="nofollow noopener" target="_blank" title="http://somesite.com/cgi-bin/purchase.cgi?product=1234"&gt;http://somesite.com/cgi-bin...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;When dealing with CSRF, you just need to remember that any major actions need to be verified by making the user re-login (or equivalent).  Use of timeouts can also be helpful: "Hey, this user last visited 5 days ago and now the first page he/she is hitting is a checkout page?"&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Joe Schmoe</dc:creator><pubDate>Sat, 29 Mar 2008 15:25:06 -0000</pubDate></item></channel></rss>