Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
Cross-site request forgery (CSRF) tricks a logged-in user’s browser into sending an unwanted, authenticated request to a web application, such as changing an email address or making a transfer.

What Is Cross-Site Request Forgery (CSRF)?
Cross-site request forgery (CSRF) is a web vulnerability that lets an attacker make a victim’s browser send an authenticated request to an application without the victim meaning to. If you are logged in to a site and visit a malicious page, that page can quietly submit a form to the site, and your browser attaches your session cookie as usual. The application sees a valid session and carries out the action—changing your email address, adding a payee, or granting admin rights.
CSRF exploits a simple browser behaviour: cookies are sent with every request to the domain that set them, regardless of which site triggered the request. The attacker never sees the cookie and does not need to steal it. They only need to predict what a legitimate request looks like.
A classic example is a hidden form on an attacker’s page that auto-submits to https://bank.example/transfer with the attacker’s account number in a field. If the bank relies on the session cookie alone to decide whether the request is genuine, the transfer goes through. A simpler variant uses an image tag pointing at a state-changing GET URL, which is one reason why GET requests should never change data.
This differs from session hijacking, where the attacker takes over the session itself. With CSRF, the victim’s own browser does the work, and the attacker usually cannot read the response.
The impact depends entirely on which actions are unprotected. Read-only pages are rarely interesting. State-changing functions are:
A 2008 Princeton study by William Zeller and Edward Felten showed CSRF flaws in several major sites, including one that allowed money to be moved from customers’ bank accounts. The vulnerability class is now mapped under A01 Broken Access Control in the OWASP Top 10 2021 as CWE-352, which reflects how closely it is tied to authorisation logic.
The synchroniser token pattern is still the primary defence. The server generates an unpredictable token, ties it to the user’s session, embeds it in every form, and rejects any state-changing request without the correct value. An attacker on another origin cannot read the token, so cannot forge a valid request. Most frameworks do this for you: Django’s CSRF middleware, Rails’ protect_from_forgery, Spring Security, and ASP.NET Core’s antiforgery system. Problems usually appear where developers turn protection off for an awkward endpoint and forget about it.
Setting session cookies to SameSite=Lax or SameSite=Strict tells the browser not to send them on most cross-site requests. Chrome began treating cookies without the attribute as Lax by default in 2020, which removed a large share of exploitable CSRF. It is not a complete answer: Lax still allows top-level GET navigations, subdomains count as the same site, and not every client behaves identically.
Servers can reject state-changing requests whose Origin header does not match the application, or use the Sec-Fetch-Site Fetch Metadata header to refuse cross-site requests outright. For high-risk actions such as payments or password changes, asking the user to re-authenticate or confirm with a second factor adds a final layer.
APIs that authenticate with a bearer token in the Authorization header are generally not exposed, because browsers do not attach that header automatically. The risk returns as soon as an API falls back to cookie authentication, accepts form-encoded bodies, or has an overly permissive CORS policy that allows credentials from any origin. CSRF also combines badly with cross-site scripting: script running on the same origin can read the token and defeat the protection entirely.
Testers map every state-changing function, remove or tamper with the token, switch request methods, change content types, and check how cookies and CORS headers are configured. Burp Suite can generate proof-of-concept pages to confirm exploitability. If your applications handle payments, personal data, or admin functions, a manual review through our web application security services will show whether these defences hold up in practice.
Not entirely. SameSite cookies block many cross-site requests and have made CSRF much harder to exploit, but they have gaps. Lax mode still permits top-level GET navigations, sibling subdomains are treated as the same site, and some older clients ignore the attribute. OWASP recommends treating SameSite as defence in depth alongside anti-CSRF tokens or strict origin checks, not as a replacement for them.
It depends on how the application authenticates. If the front end sends a bearer token in the Authorization header, the browser will not add it to forged requests, so classic CSRF does not apply. If the application relies on session cookies, it is just as exposed as a traditional site and needs tokens, SameSite settings, or custom request headers that cross-site forms cannot set.
Cross-site scripting runs the attacker’s code inside the vulnerable site, so it can read data and perform any action the user can. CSRF only causes the victim’s browser to send a request; the attacker cannot normally see the response. XSS is therefore more powerful, and an XSS flaw on the same origin will usually defeat CSRF protection by reading the token.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.