Cross-Site Request Forgery
Subject: Computer and Technology noun /ˈkrɔːsˌsaɪt rɪˈkwɛst ˈfɔːr.dʒər.i/ 1 definition
- web-security
- application-security
- session-management
- browser-security
-
Definition (noun)
Entry #30 · UpdatedCross-Site Request Forgery (CSRF) is a web security attack that forces an authenticated user's browser to execute unintended, state-changing HTTP requests against a trusted web application. It exploits the browser's automatic inclusion of ambient credentials—such as session cookies or HTTP authentication headers—on cross-origin requests, abusing the server's trust in the user's active session rather than stealing credentials directly. Because the Same-Origin Policy normally prevents the attacker from reading cross-origin responses, CSRF focuses on triggering unauthorized state changes—such as password resets, privilege changes, or fund transfers—unless blocked by anti-CSRF tokens, restrictive
SameSitecookie attributes, or strict origin validation.Common Forms
GET-Based CSRF: Exploits endpoints that improperly perform state-changing actions via HTTP
GETrequests, allowing an attacker to trigger operations through a crafted URL inside an<img>tag, hyperlink, or redirect.POST-Based CSRF: Targets endpoints expecting
POSTsubmissions by embedding hidden HTML<form>elements on a third-party page that auto-submit with JavaScript or deceive the user into clicking a button.JSON and Plaintext API CSRF: Delivers forged payloads via
text/plainform encoding or simplefetchcalls to backend APIs that parse request bodies without enforcing strictContent-Typevalidation or CORS preflight checks.Login CSRF: Forces an unauthenticated victim's browser to sign in to an application using attacker-controlled credentials, allowing the attacker to observe or capture sensitive activity linked to that session.
Example
While signed into a web banking portal at
bank.examplethat relies onSameSite=Nonesession cookies without anti-CSRF tokens, a user visits a third-party blog containing a hidden HTML form targetinghttps://bank.example/api/transfer. When the page loads, an inline script auto-submits the form and the browser attaches the active session cookie, executing an unauthorized $2,500 wire transfer under the user's account.