Github user rnewson commented on a diff in the pull request:
https://github.com/apache/couchdb-couch/pull/80#discussion_r35986890
--- Diff: src/couch_httpd_auth.erl ---
@@ -495,3 +508,11 @@ integer_to_binary(Int, Len) when is_integer(Int),
is_integer(Len) ->
Padding = binary:copy(<<"0">>, Len),
Padded = <<Padding/binary, Unpadded/binary>>,
binary:part(Padded, byte_size(Padded), -Len).
+
+csrf_cookie(Req) ->
+ Secret = ?l2b(ensure_csrf_secret()),
+ <<Token:8/binary, _/binary>> = couch_uuids:random(),
+ Hmac = crypto:sha_mac(Secret, Token),
+ mochiweb_cookies:cookie("Csrf-token",
+ couch_util:encodeBase64Url(<<Token/binary,":",Hmac/binary>>),
+ [{path, "/"}] ++ max_age()).
--- End diff --
Some CSRF mitigation patterns do that but it's not the only method. We're
doing this;
https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29_Prevention_Cheat_Sheet#Double_Submit_Cookies
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---