CSRF
Definition
Cross-Site Request Forgery. A malicious exploit where unauthorized commands are transmitted from a user that the web application trusts, typically by exploiting the browser's automatic inclusion of session cookies.
Explain Like I'm New
You log into your Bank. The bank gives you a cookie. You open a new tab and visit `Evilsite.com`. EvilSite contains a hidden form that secretly submits a request to `Bank.com/transfer`. Because you are still logged in, your browser automatically attaches the cookie, and the bank processes the fake transfer.
Real World Example
An attacker posting an invisible 1-pixel image on a forum. The image URL is actually `src="http://bank.com/transfer?amount=1000&to=hacker"`. When users load the forum, their browser tries to 'fetch' the image, accidentally transferring money.
Common Use Cases
- •Security
- •Cookie management
Terminal Output
Interview Questions
basic
- What browser setting on a Cookie is the modern, built-in defense against CSRF attacks?
intermediate
- Why are APIs that strictly use JWTs in the `Authorization` header immune to CSRF?