-
Notifications
You must be signed in to change notification settings - Fork 73
Remove XSRF Cookie #192
Comments
cc @jkarni |
I don't think it's a misfeature; though it is annoying how it's implemented, and how much it affects. To quote OWASP about SameSite:
Regarding "cookie is always present, which makes things like caching harder" - won't this be the case with any protected endpoint? I think it's pretty normal to have this enabled by default (both Django and Rails do, for example). |
It's possible to have a protected endpoint where auth is optional. In that case servant-auth always issues a dummy cookie for XSRF, while session cookie just doesn't exist. |
There are two differences that make a difference for the user:
|
Fair points. So in summary:
Then we'd be okay? I defaulted to not excluding GET because the number of times I see GET endpoints doing actual state-changing things is enormous, but if it's annoying we can remove it. There are other approaches that OWASP suggests, which might also be alternatives. All of them seem to have problems, or involve at least as much input from the users as sending the token back. I myself don't feel super comfortable removing the XSRF token and doing nothing else. |
Yeah, if we resolve those two and align with Django/Rails that would be fine. I agree about stateful GETs, but hopefully with Cloudflare and other CDN services those are making them less common. |
I've writte the following middleware for those wanting to improve their cache-ability of servant responses: module Cachix.Server.RemoveXSRFHeaderMiddleware where
import Network.HTTP.Types (Header)
import Network.Wai (Middleware, modifyResponse, mapResponseHeaders)
import Data.ByteString (take)
import Protolude
middleware :: Middleware
middleware = modifyResponse $ mapResponseHeaders deleteXsrfCookie
deleteXsrfCookie :: [Header] -> [Header]
deleteXsrfCookie [] = []
deleteXsrfCookie (header : headers) =
let
isXSRF ("set-cookie", value) = Data.ByteString.take 13 value == "NO-XSRF-TOKEN"
isXSRF _ = False
in if isXSRF header then headers else header : deleteXsrfCookie headers |
I'd like to argue that it's a misfeature at this point due to:
Are there any users of XSRF cookie that would miss it?
The text was updated successfully, but these errors were encountered: