Skip to content

Commit

Permalink
doc: csrf double cookie defense should enabled on all method (#3881)
Browse files Browse the repository at this point in the history
  • Loading branch information
denghongcai committed Sep 22, 2020
1 parent 504e4be commit 1d32771
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/en/core/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ In general, there are some common [precautions](https://www.owasp.org/index.php/

- Synchronizer Tokens:When the response page is rendered, token is rendered in the page, which will be submitted through a hidden input when a form is submitted.

- Double Cookie Defense:The token will be stored in client Cookie, Cookie will be submitted when you submit a post request, then you can get the token, and submit the token through header or body, service side will compare and check it.
- Double Cookie Defense:The token will be stored in client Cookie, Cookie will be submitted when you submit a POST/PUT/PATCH/DELETE request, then you can get the token, and submit the token through header or body, service side will compare and check it.

- Custom Header:Trust request with specific header(like `X-Requested-With: XMLHttpRequest`). This can be bypassed, so frameworks like rails and django [give up the guard](https://www.djangoproject.com/weblog/2011/feb/08/security/).

Expand Down
2 changes: 1 addition & 1 deletion docs/source/zh-cn/core/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ CSRF 攻击会对网站发起恶意伪造的请求,严重影响网站的安全
通常来说,对于 CSRF 攻击有一些通用的[防范方案](https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29_Prevention_Cheat_Sheet#CSRF_Specific_Defense),简单的介绍几种常用的防范方案:

- Synchronizer Tokens:通过响应页面时将 token 渲染到页面上,在 form 表单提交的时候通过隐藏域提交上来。
- Double Cookie Defense:将 token 设置在 Cookie 中,在提交 post 请求的时候提交 Cookie,并通过 header 或者 body 带上 Cookie 中的 token,服务端进行对比校验。
- Double Cookie Defense:将 token 设置在 Cookie 中,在提交(POST、PUT、PATCH、DELETE 等)请求时提交 Cookie,并通过 header 或者 body 带上 Cookie 中的 token,服务端进行对比校验。
- Custom Header:信任带有特定的 header(例如 `X-Requested-With: XMLHttpRequest`)的请求。这个方案可以被绕过,所以 rails 和 django 等框架都[放弃了该防范方式](https://www.djangoproject.com/weblog/2011/feb/08/security/)

框架结合了上述几种防范方式,提供了一个可配置的 CSRF 防范策略。
Expand Down

0 comments on commit 1d32771

Please sign in to comment.