You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/features/exploits/csrf.adoc
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,13 +97,13 @@ Spring provides two mechanisms to protect against CSRF attacks:
97
97
98
98
[NOTE]
99
99
====
100
-
Both protections require that <<csrf-protection-idempotent,Safe Methods be Idempotent>>.
100
+
Both protections require that <<csrf-protection-read-only,Safe Methods be Read-only>>.
101
101
====
102
102
103
-
[[csrf-protection-idempotent]]
104
-
=== Safe Methods Must be Idempotent
103
+
[[csrf-protection-read-only]]
104
+
=== Safe Methods Must be Read-only
105
105
106
-
For <<csrf-protection,either protection>> against CSRF to work, the application must ensure that https://tools.ietf.org/html/rfc7231#section-4.2.1["safe" HTTP methods are idempotent].
106
+
For <<csrf-protection,either protection>> against CSRF to work, the application must ensure that https://tools.ietf.org/html/rfc7231#section-4.2.1["safe" HTTP methods are read-only].
107
107
This means that requests with the HTTP `GET`, `HEAD`, `OPTIONS`, and `TRACE` methods should not change the state of the application.
108
108
109
109
[[csrf-protection-stp]]
@@ -119,7 +119,7 @@ For example, requiring the actual CSRF token in an HTTP parameter or an HTTP hea
119
119
Requiring the actual CSRF token in a cookie does not work because cookies are automatically included in the HTTP request by the browser.
120
120
121
121
We can relax the expectations to require only the actual CSRF token for each HTTP request that updates the state of the application.
122
-
For that to work, our application must ensure that <<csrf-protection-idempotent,safe HTTP methods are idempotent>>.
122
+
For that to work, our application must ensure that <<csrf-protection-read-only,safe HTTP methods are read-only>>.
123
123
This improves usability, since we want to allow linking to our website from external sites.
124
124
Additionally, we do not want to include the random token in HTTP GET, as this can cause the tokens to be leaked.
125
125
@@ -190,7 +190,7 @@ Valid values for the `SameSite` attribute are:
190
190
191
191
* `Strict`: When specified, any request coming from the https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-2.1[same-site] includes the cookie.
192
192
Otherwise, the cookie is not included in the HTTP request.
193
-
* `Lax`: When specified, cookies are sent when coming from the https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-2.1[same-site] or when the request comes from top-level navigations and the <<Safe Methods Must be Idempotent,method is idempotent>>.
193
+
* `Lax`: When specified, cookies are sent when coming from the https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-2.1[same-site] or when the request comes from top-level navigations and the <<Safe Methods Must be Read-only,method is read-only>>.
194
194
Otherwise, the cookie is not included in the HTTP request.
195
195
196
196
Consider how <<csrf-explained,our example>> could be protected using the `SameSite` attribute.
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/servlet/exploits/csrf.adoc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
In an application where end users can xref:servlet/authentication/index.adoc[log in], it is important to consider how to protect against xref:features/exploits/csrf.adoc#csrf[Cross Site Request Forgery (CSRF)].
6
6
7
-
Spring Security protects against CSRF attacks by default for xref:features/exploits/csrf.adoc#csrf-protection-idempotent[unsafe HTTP methods], such as a POST request, so no additional code is necessary.
7
+
Spring Security protects against CSRF attacks by default for xref:features/exploits/csrf.adoc#csrf-protection-read-only[unsafe HTTP methods], such as a POST request, so no additional code is necessary.
8
8
You can specify the default configuration explicitly using the following:
9
9
10
10
[[csrf-configuration]]
@@ -592,7 +592,7 @@ By default, Spring Security defers loading of the `CsrfToken` until it is needed
592
592
593
593
[NOTE]
594
594
====
595
-
The `CsrfToken` is needed whenever a request is made with an xref:features/exploits/csrf.adoc#csrf-protection-idempotent[unsafe HTTP method], such as a POST.
595
+
The `CsrfToken` is needed whenever a request is made with an xref:features/exploits/csrf.adoc#csrf-protection-read-only[unsafe HTTP method], such as a POST.
596
596
Additionally, it is needed by any request that renders the token to the response, such as a web page with a `<form>` tag that includes a hidden `<input>` for the CSRF token.
0 commit comments