Cross-Site Request Forgery (CSRF)
Jump to:
Summary
Cross-Site Request Forgery (CSRF) is a web security vulnerability that tricks a user’s browser into executing unwanted actions on a trusted site where the user is authenticated, potentially leading to unauthorized transactions or data changes.
Key Characteristics
- Exploits the trust a web application has in the user’s browser.
- Requires the victim to be authenticated on the target site.
- Uses social engineering to lure users into submitting malicious requests.
- Often targets state-changing requests such as form submissions or account modifications.
- Does not steal data directly but forces actions on behalf of the user.
Defensive Controls
- Implement anti-CSRF tokens in forms and state-changing requests.
- Use SameSite cookie attributes to restrict cross-origin requests.
- Validate the HTTP Referer or Origin headers to verify request sources.
- Require re-authentication or multi-factor authentication for sensitive actions.
- Employ Content Security Policy (CSP) to limit the execution of untrusted scripts.
Related Security Solutions
Web Application Firewalls (WAFs) can detect and block suspicious CSRF attempts. Secure coding practices and frameworks with built-in CSRF protection help mitigate risks. Browser security features like SameSite cookies and security headers complement these defenses.
More in Application Attacks