WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 67915eb

Browse files
committed
Merge branch '6.4' into 7.3
* 6.4: Minor reword Enhance CSRF documentation with OWASP best practices and guidelines
2 parents 7874502 + 1b0ff1e commit 67915eb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

security/csrf.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ CSRF Protection in Symfony Forms
117117
checks them automatically for you. So, when using Symfony Forms, you don't have
118118
to do anything to be protected against CSRF attacks.
119119

120+
.. note::
121+
122+
According to `OWASP best practices`_, CSRF protection is only required for
123+
**state-changing operations**, which must not use ``GET`` requests (as per the
124+
HTTP specification). Moreover, including CSRF tokens in ``GET`` request
125+
parameters can cause them to leak through browser history, log files, network
126+
utilities, and Referer headers.
127+
128+
If one of your forms uses GET (for example, a read-only search form), you
129+
can :ref:`configure the form to disable CSRF protection <form-csrf-configuration>`.
130+
120131
.. _form-csrf-customization:
121132

122133
By default Symfony adds the CSRF token in a hidden field called ``_token``, but
@@ -166,6 +177,8 @@ Globally, you can configure it under the ``framework.form`` option:
166177
;
167178
};
168179
180+
.. _form-csrf-configuration:
181+
169182
On a form-by-form basis, you can configure the CSRF protection in the ``setDefaults()``
170183
method of each form::
171184

@@ -504,6 +517,7 @@ validation has been proven effective, it remains enforced for that session.
504517
fall back to ``Origin`` / ``Referer`` checks when JavaScript is unavailable.
505518

506519
.. _`Cross-site request forgery`: https://en.wikipedia.org/wiki/Cross-site_request_forgery
520+
.. _`OWASP best practices`: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
507521
.. _`BREACH`: https://en.wikipedia.org/wiki/BREACH
508522
.. _`CRIME`: https://en.wikipedia.org/wiki/CRIME
509523
.. _`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)