SSRF vs CSRF
People think SSRF and CSRF are the same trick because the names sound alike, and they are not. In CSRF, the attacker gets your browser to send a request to a site you are logged in to. In SSRF, the attacker gets the server itself to send the request. Often it goes to a private address inside the server's own network.
Server-Side Request Forgery (SSRF)
Making a server fetch a link of the attacker's choice. Often it is a private one.
SSRF tricks a server into making a web request for the attacker. The app fetches a link the user gives, say to show a preview. The attacker gives a link to an inside address instead. The server can reach places the attacker cannot, like private admin pages or cloud settings. So the reply leaks secrets. The fix is to fetch only from a fixed list of places.
Cross-Site Request Forgery (CSRF)
An attack that tricks your browser. It sends a request you never meant to send.
Cross-site request forgery tricks your browser into sending a request. You are logged in to your bank in one tab. A bad page in another tab quietly sends a form to the bank. Your browser adds your login cookie, so the bank thinks it was you. The fix is a secret token on every form, plus cookies marked SameSite.
In one line
- Server-Side Request Forgery (SSRF)
- Making a server fetch a link of the attacker's choice. Often it is a private one.
- Cross-Site Request Forgery (CSRF)
- An attack that tricks your browser. It sends a request you never meant to send.