Cross-Site Request Forgery (CSRF)
State-changing requests are accepted on the strength of the browser's cookies alone, so another site can make a logged-in user's browser perform actions without their knowledge.
| Severity | Medium |
| CVSS 3.1 | 6.5 CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N Open in the calculator |
| CVSS 4.0 | 7.1 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-352: Cross-Site Request Forgery (CSRF) |
| OWASP Top 10 | A01:2025 Broken Access Control |
| Category | Insecure Design |
Description
The application relies only on credentials that the browser sends automatically, usually the session cookie, to authenticate requests that change state, such as updating account details, changing settings, making payments or performing administrative actions. It does not require a value that another site cannot know, such as an anti-CSRF token, and does not check where the request came from.
A page on any other site can therefore make a logged-in user's browser submit such a request, through an automatically submitted form, an image or a link, and the application processes it as the user's own action. By luring victims to such a page while they are logged in, an attacker can make them perform any unprotected state-changing action, with their privileges. Typical results include changing the account's email address or password, which can lead to account takeover, changing settings, making purchases or transfers and, where the victim is an administrator, creating accounts or changing configuration. The attacker cannot read the responses, and the impact depends on which functions are affected.
Browser defaults now reduce the exposure: cookies marked SameSite=Lax or Strict are not sent with cross-site form submissions, and some browsers apply Lax when no attribute is set. Requests that change state through GET, cookies set with SameSite=None, browsers without that default, and attacks from a sibling subdomain, which counts as the same site, remain exploitable.
The weakness typically shows itself on a test when a state-changing request still succeeds after its token is removed, emptied or replaced with one from another session, when its method can be changed from POST to GET, or when a JSON endpoint accepts a cross-site form submission. Burp Suite can generate a proof-of-concept page, and OWASP ZAP reports forms without anti-CSRF tokens.
Remediation
Require proof that each state-changing request was made by the application's own pages:
- Protect every state-changing request with the framework's built-in CSRF protection, which uses a token tied to the session and checked on the server, or a signed double-submit cookie where the application is stateless.
- Alternatively, or as well, reject state-changing requests whose
Sec-Fetch-Siteheader iscross-site, falling back to checking theOriginheader against the application's own origins for browsers that do not send it. - Never change state in response to GET requests.
- Set
SameSite=LaxorStricton session cookies as an extra layer, not as the only defence. - For APIs, require a custom request header or a JSON content type, which a cross-site form cannot send without a CORS preflight, and keep the CORS policy strict.
- Require re-authentication for the most sensitive changes, such as a new email address or password.
Confirm the fix by replaying each affected request from a page on another origin, and with the token removed or altered, and checking that it is rejected.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.