Skip to content
Computing Medium #csrf#web-security#owasp

CSRF: Cross-Site Request Forgery

Attacker tricks browser into sending a state-changing request with the victim's cookies.

A free, animated csrf: cross-site request forgery you can read here or embed on any website, from Scrollchart.

CSRF: Cross-Site Request Forgery

CSRF: Cross-Site Request ForgeryBrowser auto-attaches cookies: attacker weaponises that trust without touching your JSFix hierarchy: SameSite=Lax (default Chrome/Firefox) stops most attacks. Add a CSRF token for full defense-in-depth on state-changing endpoints.

Victim is logged into bank.com. Attacker page submits a hidden form to bank.com. Browser attaches the cookie, the request runs. SameSite cookies and CSRF tokens shown blocking the attack on the second pass.

Good for

  • Web security training for backend developers
  • OWASP Top 10 explainer content
  • Auth blog posts on SameSite cookie behaviour

Source & accuracy

This csrf: cross-site request forgery is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

The attack mechanism and browser trust

Cross-Site Request Forgery (CSRF) exploits a browser's automatic credential sending. A user logs into their bank at bank.com, and the browser stores a session cookie. The user then visits attacker.com in another tab. The attacker's site contains a form or image tag pointing to bank.com/transfer?amount=1000&to=attacker (a state-changing request). The browser, seeing a request to bank.com, automatically includes the session cookie. The bank receives the request with valid credentials and thinks the user initiated the transfer. The attacker has forged a request on the user's behalf.

Defenses through token validation

The primary defense is a CSRF token: a per-session, unpredictable value that the server requires for state-changing requests. The form or API request includes the token, and only the legitimate site (not the attacker's site) can read it from the page source. The attacker's site cannot guess or retrieve the token, so its forged request fails. Tokens are single-use or long-lived per-session. Same-site cookies (Set-Cookie: SameSite=Strict) prevent the browser from including cookies on cross-site requests, but browser support varies. Checking the Referer header (which origin initiated the request) helps, but is less reliable than tokens.

Vulnerability in modern applications

APIs that accept CORS (cross-origin requests) or rely on Authorization headers rather than cookies are less vulnerable, since browsers do not auto-include custom headers. APIs with state-changing GET requests (instead of POST) are more vulnerable: any image or link tag can trigger them. Session fixation (attacker forces the user to use the attacker's session token) is a related attack. Proper mitigation requires CSRF tokens on all forms, SameSite cookie attributes, and POST/PUT/DELETE for mutations.

Embed this diagram

Add this animated csrf: cross-site request forgery to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated csrf: cross-site request forgery for any website.
Who uses it
Security blogs, Developer blogs.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="csrf-attack" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "CSRF: Cross-Site Request Forgery" for my website?
Scrollchart provides "CSRF: Cross-Site Request Forgery" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a csrf: cross-site request forgery in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.