Replies: 2 comments 2 replies
-
I like this idea very much that The only thing I’m wondering is: what if you have next to your web part a mobile app that’s using the same endpoints? How would the mobile app get a valid CSRF token? |
Beta Was this translation helpful? Give feedback.
-
Since this doesn't seem super controversial, I figure a straw-man PR is a good next step (but no rush, happy to keep discussing it). Anyone is welcome to open a PR for this, but my plan so far is:
On the topic of what "options" folks might be able to set for their CSRF protection - I'd suggest none 😊 IMO, this should be something that Remix just does, and if its not tuned to exactly what the developer needs (ex: wrong cookie name) they can just disable it and roll their own. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! Was just chatting with @kentcdodds about CSRF protection in Remix - it's a lightweight feature that some frameworks (like Rails) have built-in to protect against "Cross-Site Request Forgery":
Would definitely recommend reading up on it, but the basic concept is that on a GET that returns some HTML, the server generates a random token and stores it on the requester's cookie (or sometimes just a
meta
tag). That token is included in every subsequent POST (usually via an<input type="hidden" name="csrf" value="<generated_token>">
or as a request header). If that token is not present or isn't valid, the request is denied.That's a level of protection that Remix can include without any additional work from the developer! There's already a great approach from @sergiodxa in
remix-utils
: https://github.com/sergiodxa/remix-utils#csrf.But, it'd be great if Remix just included the token in every POST by default. This would make Remix more secure by default, making all Remix apps "just more secure" 🎉 There could potentially be a way to disable CSRF entirely (maybe via
remix.config.js
?) - but that's an implementation detail.Happy to chat through it more!
Beta Was this translation helpful? Give feedback.
All reactions