-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] Java: add CSRF query #18288
base: main
Are you sure you want to change the base?
[DRAFT] Java: add CSRF query #18288
Conversation
java/ql/lib/semmle/code/java/security/CsrfUnprotectedRequestTypeQuery.qll
Fixed
Show fixed
Hide fixed
java/ql/lib/semmle/code/java/security/CsrfUnprotectedRequestTypeQuery.qll
Fixed
Show fixed
Hide fixed
java/ql/lib/semmle/code/java/security/CsrfUnprotectedRequestTypeQuery.qll
Fixed
Show fixed
Hide fixed
java/ql/src/experimental/Security/CWE/CWE-089/MyBatisMapperXmlSqlInjection.ql
Fixed
Show fixed
Hide fixed
java/ql/test/query-tests/security/CWE-352/CsrfUnprotectedRequestTypeTest.ql
Fixed
Show fixed
Hide fixed
java/ql/test/query-tests/security/CWE-352/CsrfUnprotectedRequestTypeTest.ql
Fixed
Show fixed
Hide fixed
java/ql/test/query-tests/security/CWE-352/CsrfUnprotectedRequestTypeTest.ql
Fixed
Show fixed
Hide fixed
java/ql/test/query-tests/security/CWE-352/CsrfUnprotectedRequestTypeTest.ql
Fixed
Show fixed
Hide fixed
java/ql/test/query-tests/security/CWE-352/CsrfUnprotectedRequestTypeTest.ql
Fixed
Show fixed
Hide fixed
749e24a
to
e112226
Compare
…lt-protected from CSRF
…lib so importable, and fix experimental files broken by the move
… sql-injection nodes)
ff0477c
to
13753dd
Compare
QHelp previews: java/ql/src/Security/CWE/CWE-352/CsrfUnprotectedRequestType.qhelpHTTP request type unprotected from CSRFWhen you set up a web server to receive a request from a client without any mechanism for verifying that it was intentionally sent, then it is vulnerable to attack. An attacker can trick a client into making an unintended request to the web server that will be treated as an authentic request. This can be done via a URL, image load, XMLHttpRequest, etc. and can result in exposure of data or unintended code execution. RecommendationWhen handling requests, make sure that any requests which change application state are protected from Cross-Site Request Forgery (CSRF). Some application frameworks, such as Spring, provide default CSRF protection for HTTP request types that may change application state, such as POST. Other HTTP request types, such as GET, should not be used for actions that change the state of the application, since these request types are not default-protected from CSRF by the framework. ExampleThe following example shows a Spring request handler using a GET request for a state-changing action. Since a GET request does not have default CSRF protection in Spring, this type of request should not be used when modifying application state. Instead use one of Spring's default-protected request types, such as POST. // BAD - a GET request should not be used for a state-changing action like transfer
@RequestMapping(value="transfer", method=RequestMethod.GET)
public boolean transfer(HttpServletRequest request, HttpServletResponse response){
return sendMoney(request, response);
} // GOOD - use a POST request for a state-changing action
@RequestMapping(value="transfer", method=RequestMethod.POST)
public boolean transfer(HttpServletRequest request, HttpServletResponse response){
return sendMoney(request, response);
} References
|
…pdate queries like select
13753dd
to
c217d7f
Compare
DRAFT
Pull Request checklist
All query authors
.qhelp
. See the documentation in this repository.Internal query authors only
.ql
,.qll
, or.qhelp
files. See the documentation (internal access required).