Skip to content

Commit 8fd466c

Browse files
committed
Enhance CSRF documentation with OWASP best practices and guidelines
1 parent d4e3b11 commit 8fd466c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

security/csrf.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ CSRF, or `Cross-site request forgery`_, is a type of attack where a malicious ac
55
tricks a user into performing actions on a web application without their knowledge
66
or consent.
77

8+
.. note::
9+
10+
According to `OWASP best practices`_, CSRF protection is only required for
11+
**state-changing operations**. Do not use GET requests for state-changing
12+
operations, as recommended by the HTTP specification. CSRF tokens must not be
13+
transmitted in GET request parameters, as they can leak through browser history,
14+
log files, network utilities, and Referer headers.
15+
16+
If you need to disable CSRF protection for specific forms (for example, forms
17+
that only perform read operations), see :ref:`form-csrf-customization`.
18+
819
The attack is based on the trust that a web application has in a user's browser
920
(e.g. on session cookies). Here's a real example of a CSRF attack: a malicious
1021
actor could create the following website:
@@ -529,6 +540,7 @@ validation has been proven effective, it remains enforced for that session.
529540
fall back to ``Origin`` / ``Referer`` checks when JavaScript is unavailable.
530541

531542
.. _`Cross-site request forgery`: https://en.wikipedia.org/wiki/Cross-site_request_forgery
543+
.. _`OWASP best practices`: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
532544
.. _`BREACH`: https://en.wikipedia.org/wiki/BREACH
533545
.. _`CRIME`: https://en.wikipedia.org/wiki/CRIME
534546
.. _`some JavaScript`: https://github.com/symfony/recipes/blob/main/symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js

0 commit comments

Comments
 (0)