Skip to content

Commit d2a6fb9

Browse files
Jami CogswellJami Cogswell
Jami Cogswell
authored and
Jami Cogswell
committed
Java: minor qhelp update
1 parent f4bb1ec commit d2a6fb9

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

java/ql/src/Security/CWE/CWE-352/CsrfUnprotectedRequestType.qhelp

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ result in exposure of data or unintended code execution.</p>
1111

1212
<recommendation>
1313
<p>Make sure any requests that change application state are protected from Cross Site Request Forgery (CSRF).
14-
Some application frameworks provide default CSRF protection for unsafe HTTP request methods (<code>POST</code>,
15-
<code>PUT</code>, <code>DELETE</code>, <code>PATCH</code>, <code>CONNECT</code>) which may change the state of
16-
the application. Safe HTTP request methods (<code>GET</code>, <code>HEAD</code>, <code>OPTIONS</code>,
17-
<code>TRACE</code>) should be read-only and should not be used for actions that change application state.</p>
14+
Some application frameworks provide default CSRF protection for unsafe HTTP request methods (such as
15+
<code>POST</code>) which may change the state of the application. Safe HTTP request methods (such as
16+
<code>GET</code>) should be read-only and should not be used for actions that change application state.</p>
1817

1918
<p>This query currently supports the Spring and Stapler web frameworks. Spring provides default CSRF protection
2019
for all unsafe HTTP methods. Stapler provides default CSRF protection for the <code>POST</code> method.</p>

java/ql/src/Security/CWE/CWE-352/CsrfUnprotectedRequestTypeBadStapler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ public HttpRedirect doTransfer() {
77
}
88

99
// BAD - no HTTP request type is specified, so safe HTTP requests are allowed
10-
public HttpRedirect doDelete() {
11-
return delete();
10+
public HttpRedirect doPost() {
11+
return post();
1212
}

java/ql/src/Security/CWE/CWE-352/CsrfUnprotectedRequestTypeGoodStapler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public HttpRedirect doTransfer() {
88

99
// GOOD - use POST
1010
@POST
11-
public HttpRedirect doDelete() {
12-
return delete();
11+
public HttpRedirect doPost() {
12+
return post();
1313
}

0 commit comments

Comments
 (0)