GRC Careers

HomeResourcesCross-Site Request Forgery (CSRF)

CS-060 · Application Security

Cross-Site Request Forgery (CSRF)

An attack that tricks a logged-in user's browser into making unintended requests.

Executive Summary

Cross-site request forgery, or CSRF, is an attack that causes a logged-in user's browser to send a request the user did not intend, using the trust the application places in that user's session. If the application accepts the request as legitimate, the attacker can perform actions such as changing settings or moving funds. The core defense is requiring an unpredictable anti-CSRF token and using SameSite cookies.

What It Is

CSRF exploits the way browsers automatically attach a user's cookies to requests sent to a site. If a user is logged in to an application and then visits a malicious page, that page can quietly instruct the browser to send a request to the application. Because the browser includes the user's session cookie, the application may treat the forged request as a genuine action by the user. CSRF targets state-changing actions such as updating an account, making a purchase, or changing a password. It does not let the attacker read the response, but it can cause real changes on the user's behalf without their knowledge.

Why It Matters

CSRF turns a user's own authenticated session into a weapon against them. A successful attack can change account details, transfer money, alter permissions, or perform any state-changing action the user is allowed to take, all without the user realizing it. Because the request looks like it came from the legitimate user, basic logging may not reveal anything unusual. The good news is that CSRF is well understood and reliably preventable, so an exploitable CSRF flaw on a sensitive action is treated as a clear gap in application security practice.

How It Works

At a conceptual level, CSRF works because the application cannot tell whether a valid-looking request was actually initiated by the user or forged by another site. The main defense breaks that ambiguity with an anti-CSRF token: the server issues a secret, unpredictable value tied to the user's session and requires it on every state-changing request. A malicious site cannot read or guess this token, so its forged requests are rejected. SameSite cookie settings add a strong layer by telling the browser not to send session cookies on cross-site requests, which blocks the mechanism CSRF relies on. Requiring a valid custom header for API requests and checking the request origin provide additional defense. Read-only requests should never cause state changes, since that removes a whole avenue of abuse.

Architecture Diagram

User is logged in to the applicationUser visits a malicious pagePage triggers a request with the user's cookiesAnti-CSRF token check fails on the forged requestSameSite cookie is not sent cross-site, request rejected
CSRF rides a logged-in session from another site; an unpredictable token and SameSite cookies break the forged request.

Visual Workflow

Identify every state-changing action, since those are what CSRF targets.Issue an unpredictable anti-CSRF token bound to the user's session.Require and verify the token on every state-changing request.Set session cookies with an appropriate SameSite attribute.For APIs, require a custom header and validate the request origin.Ensure read-only requests never change state, then test and re-test the defenses.

Common Attacks

Common Mistakes

Best Practices

Quick Checklist

Recommended Tools

Framework CSRF protection
Built-in token generation and validation applied consistently
Dynamic application security testing (DAST)
Tests whether state-changing actions accept forged cross-site requests
SameSite cookie configuration
Instructs the browser not to send session cookies cross-site
Manual test proxy
Lets a reviewer replay and modify requests to verify token enforcement

Industry Standards

OWASP Top 10
CSRF risk relates to broken access control and session handling categories
OWASP Application Security Verification Standard (ASVS)
Testable requirements for anti-forgery protections on state changes
CWE-352
The Common Weakness Enumeration entry for cross-site request forgery

Career Relevance

CSRF is standard knowledge for application security engineers, penetration testers, and secure code reviewers, who verify token enforcement on every sensitive action. Developers are expected to enable framework CSRF protection correctly and to set SameSite cookies, and GRC and audit teams flag missing protections on state-changing endpoints. For the AI-Governance-Jobs.com audience, explaining CSRF and its defenses clearly is a common interview task.

Interview Questions

Related Certifications

GIAC Web Application Penetration Tester (GWAPT) Offensive Security Web Assessor (OSWA) CompTIA Security+

Further Reading

Key Takeaways

Download PDFDownload PNG

FAQ

How is CSRF different from XSS?

XSS runs attacker-controlled script in the victim's browser and can read data, while CSRF forces the browser to send a request the user did not intend and cannot read the response. They are distinct flaws with distinct defenses.

Do SameSite cookies remove the need for tokens?

SameSite cookies are a strong layer, but relying on them alone is risky because of edge cases and browser differences. The recommended approach is an anti-CSRF token combined with appropriate SameSite settings.

Which requests need CSRF protection?

State-changing actions such as updates, deletions, purchases, and settings changes. Read-only requests should never change state, which is why they generally do not require the same protection.

Get all 116 reference sheets
The complete AGJ Cybersecurity Professional Reference Library, print-ready PDFs and PNGs.
Browse the library

Related Careers

Related certifications

GIAC Web Application Penetration Tester (GWAPT)Offensive Security Web Assessor (OSWA)CompTIA Security+

Current openings

Live openings appear on the web version. Browse the job board for current GRC and security roles.
Browse all jobs

Suggested learning path

  1. Ground the basics with CS-001 Cybersecurity
  2. Study this sheet: Cross-Site Request Forgery (CSRF)
  3. Go deeper: OWASP Top 10
  4. Go deeper: Cross-Site Scripting (XSS)
  5. Validate it: work toward GIAC Web Application Penetration Tester (GWAPT)
  6. Find the role: browse current openings

Related sheets

More in Application Security

Share this LinkedIn Facebook X Email