|
|
| Line 1: |
Line 1: |
| − | {{Top_10_2013:TopTemplate
| + | #REDIRECT [[Top 10-2017 A8-Insecure Deserialization]] |
| − | |usenext=2013NextLink
| + | <!--- 'Top 10 2017-A8-Cross-Site Request Forgery (CSRF)' has been retired ---> |
| − | |next=A9-{{Top_10_2010:ByTheNumbers
| |
| − | |9
| |
| − | |year=2017
| |
| − | |language=en}}
| |
| − | |useprev=2013PrevLink
| |
| − | |prev=A7-{{Top_10_2010:ByTheNumbers
| |
| − | |7
| |
| − | |year=2017
| |
| − | |language=en}}
| |
| − | |year=2017
| |
| − | |language=en
| |
| − | }}
| |
| − | | |
| − | {{Top_10_2010:SummaryTableHeaderBeginTemplate|year=2017|language=en}}
| |
| − | {{Top_10:SummaryTableTemplate|exploitability=2|prevalence=3|detectability=1|impact=2|year=2017|language=en}}
| |
| − | {{Top_10_2010:SummaryTableHeaderEndTemplate|year=2017}}
| |
| − | <td {{Template:Top 10 2010:SummaryTableRowStyleTemplate|year=2017}}>
| |
| − | <!--- Threat Agents: --->Consider anyone who can load content into your users’ browsers, and thus force them to submit a request to your website, including any website or other HTML feed that your users visit.
| |
| − | </td>
| |
| − | <td {{Template:Top 10 2010:SummaryTableRowStyleTemplate|year=2017}}>
| |
| − | <!--- Attack Vectors --->Attackers create forged HTTP requests and trick a victim into submitting them via image tags, iframes, XSS, or various other techniques. <u>If the user is authenticated</u>, the attack succeeds.
| |
| − | </td>
| |
| − | <td colspan=2 {{Template:Top 10 2010:SummaryTableRowStyleTemplate|year=2017}}>
| |
| − | <!--- Security Weakness ---><u>[[CSRF|CSRF]]</u> takes advantage of the fact that most web apps allow attackers to predict all the details of a particular action.
| |
| − | | |
| − | Because browsers send credentials like session cookies automatically, attackers can create malicious web pages which generate forged requests that are indistinguishable from legitimate ones.
| |
| − | | |
| − | Detection of CSRF flaws is fairly easy via penetration testing or code analysis.
| |
| − | </td>
| |
| − | <td {{Template:Top 10 2010:SummaryTableRowStyleTemplate|year=2017}}>
| |
| − | <!--- Technical Impacts --->Attackers can trick victims into performing any state changing operation the victim is authorized to perform (e.g., updating account details, making purchases, modifying data). | |
| − | </td>
| |
| − | <td {{Template:Top 10 2010:SummaryTableRowStyleTemplate|year=2017}}>
| |
| − | <!--- Business Impacts --->Consider the business value of the affected data or application functions. Imagine not being sure if users intended to take these actions.
| |
| − | | |
| − | Consider the impact to your reputation.
| |
| − | </td>
| |
| − | {{Top_10_2010:SummaryTableEndTemplate|year=2017}}
| |
| − | | |
| − | {{Top_10:SubsectionTableBeginTemplate|type=main}} {{Top_10_2010:SubsectionAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|subsection=vulnerableTo|position=firstLeft|risk=8|year=2017|language=en}}
| |
| − | To check whether an application is vulnerable, see if any links and forms lack an unpredictable CSRF token. Without such a token, attackers can forge malicious requests. An alternate defense is to require the user to prove they intended to submit the request, such as through reauthentication.
| |
| − | | |
| − | Focus on the links and forms that invoke state-changing functions, since those are the most important CSRF targets. Multistep transactions are not inherently immune. Also be aware that Server-Side Request Forgery (SSRF) is also possible by tricking apps and APIs into generating arbitrary HTTP requests.
| |
| − | | |
| − | Note that session cookies, source IP addresses, and other information automatically sent by the browser don’t defend against CSRF since they are included in the forged requests.
| |
| − | | |
| − | OWASP’s <u>[[CSRFTester|CSRF Tester]]</u> tool can help generate test cases to demonstrate the dangers of CSRF flaws.
| |
| − | {{Top_10_2010:SubsectionAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|subsection=howPrevent|position=right|risk=8|year=2017|language=en}}
| |
| − | The preferred option is to use an existing CSRF defense. Many frameworks now include built in CSRF defenses, such as <u>[https://docs.spring.io/spring-security/site/docs/current/reference/html/csrf.html Spring]</u>, <u>[https://www.playframework.com/documentation/2.5.x/JavaCsrf Play]</u>, <u>[https://docs.djangoproject.com/en/1.10/topics/security/ Django]</u>, and <u>[https://angular.io/docs/ts/latest/guide/security.html AngularJS]</u>. Some web development languages, such as <u>[http://www.dotnetcurry.com/aspnet/1343/aspnet-core-csrf-antiforgery-token .NET]</u> do so as well. OWASP’s <u>[[CSRFGuard|CSRF Guard]]</u> can automatically add CSRF defenses to Java apps. OWASP’s <u>[[CSRFProtector_Project|CSRFProtector]]</u> does the same for PHP or as an Apache filter.
| |
| − | | |
| − | Otherwise, preventing CSRF usually requires the inclusion of an unpredictable token in each HTTP request. Such tokens should, at a minimum, be unique per user session.
| |
| − | # The preferred option is to include the unique token in a hidden field. This includes the value in the body of the HTTP request, avoiding its exposure in the URL.
| |
| − | # The unique token can also be included in the URL or a parameter. However, this runs the risk that the token will be exposed to an attacker.
| |
| − | # Consider <u>[https://scotthelme.co.uk/csrf-is-dead/ using]</u> the “SameSite=strict” flag on all cookies, which is increasingly <u>[http://caniuse.com/#feat=same-site-cookie-attribute supported]</u> in browsers.
| |
| − | {{Top_10_2010:SubsectionAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|subsection=example|position=left|risk=8|year=2017|language=en}}
| |
| − | The application allows a user to submit a state changing request that does not include anything secret. For example:
| |
| − | {{Top_10_2010:ExampleBeginTemplate|year=2017}}<b>
| |
| − | <nowiki>http://</nowiki>example.com/app/transferFunds?amount=1500&destinationAccount=4673243243
| |
| − | </b>{{Top_10_2010:ExampleEndTemplate}}
| |
| − | So, the attacker constructs a request that will transfer money from the victim’s account to the attacker’s account, and then embeds this attack in an image request or iframe stored on various sites under the attacker’s control:
| |
| − | {{Top_10_2010:ExampleBeginTemplate|year=2017}}<b>
| |
| − | <img src="<span style="color: red;"><b><nowiki>http://</nowiki>example.com/app/transferFunds?amount=1500&destinationAccount=attackersAcct#</b></span>" width="0" height="0" />
| |
| − | </b>{{Top_10_2010:ExampleEndTemplate}}
| |
| − | If the victim visits any of the attacker’s sites while already authenticated to example.com, these forged requests will automatically include the user’s session info, authorizing the attacker’s request.
| |
| − | | |
| − | {{Top_10_2010:SubsectionAdvancedTemplate|type={{Top_10_2010:StyleTemplate}}|subsection=references|position=right|risk=8|year=2017|language=en}}
| |
| − | {{Top_10_2010:SubSubsectionOWASPReferencesTemplate|year=2017}}
| |
| − | * <u>[[CSRF|OWASP CSRF Article]]</u>
| |
| − | * <u>[[Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet|OWASP CSRF Prevention Cheat Sheet]]</u>
| |
| − | * <u>[[CSRFGuard|OWASP CSRFGuard - Java CSRF Defense Tool]]</u>
| |
| − | * <u>[[CSRFProtector_Project|OWASP CSRFProtector - PHP and Apache CSRF Defense Tool]]</u>
| |
| − | * <u>[https://static.javadoc.io/org.owasp.esapi/esapi/2.0.1/org/owasp/esapi/HTTPUtilities.html ESAPI HTTPUtilities Class with AntiCSRF Tokens]</u>
| |
| − | * <u>[[Testing_for_CSRF_(OWASP-SM-005)|OWASP Testing Guide: Chapter on CSRF Testing]]</u>
| |
| − | * <u>[[CSRFTester|OWASP CSRFTester - CSRF Testing Tool]]</u>
| |
| − | | |
| − | {{Top_10_2010:SubSubsectionExternalReferencesTemplate|language=en}}
| |
| − | * <u>[http://cwe.mitre.org/data/definitions/352.html CWE Entry 352 on CSRF]</u>
| |
| − | * <u>[https://en.wikipedia.org/wiki/Cross-site_request_forgery Wikipedia article on CSRF]</u>
| |
| − | | |
| − | {{Top_10_2013:BottomAdvancedTemplate
| |
| − | |type={{Top_10_2010:StyleTemplate}}
| |
| − | |usenext=2013NextLink
| |
| − | |next=A9-{{Top_10_2010:ByTheNumbers
| |
| − | |9
| |
| − | |year=2017
| |
| − | |language=en}}
| |
| − | |useprev=2013PrevLink
| |
| − | |prev=A7-{{Top_10_2010:ByTheNumbers
| |
| − | |7
| |
| − | |year=2017
| |
| − | |language=en}}
| |
| − | |year=2017
| |
| − | |language=en
| |
| − | }}
| |