Glossary
Cross-site request forgery (CSRF)
Definition
Cross-site request forgery (CSRF): An attack that makes a signed-in user's browser send an unwanted request to a web application, which accepts it because the browser automatically attaches the user's session cookie (OWASP).
Also known asCSRFXSRFsession ridingone-click attack
In short
Cross-site request forgery (CSRF) is an attack in which a page on another site makes your browser send a request to a site where you're signed in. The browser attaches your session cookie, so the site carries out the action as you. Anti-CSRF tokens and Fetch Metadata checks are the main defenses; SameSite cookies add a second layer.
Key takeaways
- CSRF works because browsers attach a site's cookies to requests automatically.
- The attacker can trigger actions but can't read the responses.
- Synchronizer tokens or signed double-submit cookies are the primary defenses.
- SameSite=Lax still sends cookies on top-level GET navigations, so never change data on a GET.
- Cross-site scripting defeats every CSRF defense, so fix XSS first.
Last reviewed 4 December 2026 by Foxcolab Team
Cross-site request forgery (CSRF) is an attack in which a page on another site makes your browser send a request to a site where you're signed in, and the site carries it out as you. OWASP defines it as "an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated." It works because "browser requests automatically include any credentials associated with the site," such as your session cookie.
A worked example#
You're signed in to your bank at bank.example.com. Later you open a forum post that contains this:
<img src="https://bank.example.com/transfer?to=attacker&amount=100000" width="0" height="0">Your browser fetches the "image," attaches your bank cookie, and the bank sees a valid, signed-in request. If transfers work over a simple link, the money moves. The POST version uses a hidden form that submits itself the moment the page loads.
The attacker never sees the bank's reply. The same-origin policy stops the forum page from reading it, so CSRF can change things in your account but can't read them.
How sites stop it#
OWASP's prevention cheat sheet recommends:
| Defense | How it works |
|---|---|
| Synchronizer token | The server puts a secret, per-session value in each form and rejects requests without it. For stateful apps |
| Signed double-submit cookie | A signed token in a cookie and in the request must match. For stateless apps |
| Fetch Metadata | The browser's Sec-Fetch-Site header shows whether a request came from another site, so the server can refuse it |
| SameSite cookies | The browser leaves the cookie off cross-site requests. OWASP calls it "a defense-in-depth control" that "does not replace a proper CSRF defense" |
Two mistakes undo the rest. SameSite=Lax still sends cookies on "cross-site top-level navigations that use safe HTTP methods," so an action reachable with a GET link stays exposed. And as OWASP warns, "Cross-Site Scripting (XSS) can defeat all CSRF mitigation techniques," so fix XSS first.
In Foxcolab#
Foxcolab's web apps send your sign-in token in a request header that a page on another site can't fill in, because it can't read your token. Foxcolab's sign-in cookies are marked SameSite=Lax, so browsers leave them off form posts and background requests that other sites start. If something in your account ever looks changed without you, open Your devices, sign out anything you don't recognize and change your password. See review active sessions and session cookie.
Keep exploring
Related terms
- Session cookieA session cookie is either a cookie that disappears when the browser session ends or the cookie that keeps you signed in. Here's what each attribute does and why stolen ones matter.
- Same-origin policyThe same-origin policy stops a web page from reading data that belongs to another origin. Here's what counts as an origin, what the rule blocks, and where cookies differ.
- Cross-site scripting (XSS)Cross-site scripting lets an attacker run their own script inside a trusted website, in other people's browsers. Here are the three types, an example and the defenses that work.
- ClickjackingClickjacking hides a real website inside an invisible frame and lines up its buttons under your clicks. Here's how it works and the headers that stop it.
- Session hijackingSession hijacking is taking over someone's signed-in session by stealing or guessing the token that keeps them logged in. It skips the password and two-step verification entirely.

Foxcolab
Private work tools, without the ads.
Mail, files, documents, spreadsheets and meetings in one account. Files, documents and spreadsheets are end-to-end encrypted.