Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0068a48

Browse filesBrowse files
committed
Merge branch '8.0' into 8.1
* 8.0: Minor reword Enhance CSRF documentation with OWASP best practices and guidelines
2 parents 2778336 + 4039686 commit 0068a48
Copy full SHA for 0068a48

File tree

Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Open diff view settings
Collapse file

‎security/csrf.rst‎

Copy file name to clipboardExpand all lines: security/csrf.rst
+14Lines changed: 14 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ CSRF Protection in Symfony Forms
100100
checks them automatically for you. So, when using Symfony Forms, you don't have
101101
to do anything to be protected against CSRF attacks.
102102

103+
.. note::
104+
105+
According to `OWASP best practices`_, CSRF protection is only required for
106+
**state-changing operations**, which must not use ``GET`` requests (as per the
107+
HTTP specification). Moreover, including CSRF tokens in ``GET`` request
108+
parameters can cause them to leak through browser history, log files, network
109+
utilities, and Referer headers.
110+
111+
If one of your forms uses GET (for example, a read-only search form), you
112+
can :ref:`configure the form to disable CSRF protection <form-csrf-configuration>`.
113+
103114
.. _form-csrf-customization:
104115

105116
By default Symfony adds the CSRF token in a hidden field called ``_token``, but
@@ -130,6 +141,8 @@ Globally, you can configure it under the ``framework.form`` option:
130141
;
131142
};
132143
144+
.. _form-csrf-configuration:
145+
133146
On a form-by-form basis, you can configure the CSRF protection in the ``setDefaults()``
134147
method of each form::
135148

@@ -436,6 +449,7 @@ validation has been proven effective, it remains enforced for that session.
436449
fall back to ``Origin`` / ``Referer`` checks when JavaScript is unavailable.
437450

438451
.. _`Cross-site request forgery`: https://en.wikipedia.org/wiki/Cross-site_request_forgery
452+
.. _`OWASP best practices`: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
439453
.. _`BREACH`: https://en.wikipedia.org/wiki/BREACH
440454
.. _`CRIME`: https://en.wikipedia.org/wiki/CRIME
441455
.. _`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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.