Skip to main content
Definition Website Computer and Technology

Cross-Site Request Forgery

Subject: Computer and Technology noun /ˈkrɔːsˌsaɪt rɪˈkwɛst ˈfɔːr.dʒər.i/ 1 definition

  1. Definition (noun)

    Entry #30 · Updated

    Cross-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 SameSite cookie attributes, or strict origin validation.

    Common Forms

    • GET-Based CSRF: Exploits endpoints that improperly perform state-changing actions via HTTP GET requests, allowing an attacker to trigger operations through a crafted URL inside an <img> tag, hyperlink, or redirect.

    • POST-Based CSRF: Targets endpoints expecting POST submissions 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/plain form encoding or simple fetch calls to backend APIs that parse request bodies without enforcing strict Content-Type validation 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.example that relies on SameSite=None session cookies without anti-CSRF tokens, a user visits a third-party blog containing a hidden HTML form targeting https://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.