July 22, 2026
XSS vs CSRF vs SSRF: Why Do So Many People Get Confused?
As a Computer Science student specializing in Cybersecurity & AI, I’ve been spending a lot of time learning and practicing web security…

By Prashant Tripathi
3 min read
As a Computer Science student specializing in Cybersecurity & AI, I've been spending a lot of time learning and practicing web security. While doing that, one thing I kept running into was XSS, CSRF, and SSRF. I understood each one individually, but whenever someone mentioned them together, I'd have to stop and think for a second. After finally getting the difference straight in my head, I decided to write the explanation I wish I'd had when I first learned them.
If you've recently started learning web security, you've probably come across XSS, CSRF, and SSRF.
And if you got confused between them… you're definitely not the only one.
The names are just so similar. XSS, CSRF, SSRF… when someone says them, they almost sound like different versions of the same thing. And when you first read about them, the explanations can feel similar too because all of them involve websites, requests, or browsers in one way or another. That's usually where the confusion starts. You know they're different, but it's hard to remember what each one actually does.
At first, I honestly thought they were somehow related because of the names. Turns out, they aren't.
One targets a user's browser, another tricks a user into sending a request, and the third abuses the server itself to make requests. Completely different attacks, just very similar-looking names.
Once I started thinking about who each attack is targeting instead of just memorizing the names, it finally clicked.
So instead of giving textbook definitions, let's understand each one in simple terms with examples. By the end, you'll not only know the difference between XSS, CSRF, and SSRF, but you'll also have an easy way to remember which is which.
1. XSS (Cross-Site Scripting)
Think of XSS as injecting JavaScript into someone else's browser.
The attacker finds a place on a website where they can insert malicious JavaScript. When another user visits that page, their browser executes the attacker's code as if the website itself sent it.
Imagine a website that lets users post comments.
Normally someone writes:
Nice article! (in user input field)
But an attacker posts:
<script>alert("You got hacked!")</script><script>alert("You got hacked!")</script>Instead of displaying normal text, the browser runs the JavaScript.
Of course, real attackers don't just show alert boxes. They usually try to:
- Steal session cookies
- Read sensitive page data
- Perform actions as the logged-in user
- Redirect users to phishing pages
Easy way to remember
XSS = Your browser gets tricked into running someone else's JavaScript.
The target is the user's browser.
2. CSRF (Cross-Site Request Forgery)
CSRF is completely different.
Here, the attacker doesn't inject code.
Instead, they trick you into sending a request that you never intended to send.
Imagine you're logged into your online banking account.
Without logging out, you visit a malicious website.
Hidden in that page is something like:
<img src="https://bank.com/transfer?amount=5000&to=attacker"><img src="https://bank.com/transfer?amount=5000&to=attacker">Your browser automatically sends the request.
Since you're already logged into the bank, your browser also sends your session cookie.
The bank thinks,
"Oh, this request came from the real user."
So it processes the request.
You never clicked "Transfer."
The attacker simply took advantage of the fact that your browser was already authenticated.
Easy way to remember
CSRF = The attacker tricks YOU into sending a legitimate request.
The target is the authenticated user.
3. SSRF (Server-Side Request Forgery)
Now let's move to SSRF.
This time, the attacker isn't using your browser at all.
They're making the server send requests on their behalf.
Imagine a website where users can submit an image URL.
The server downloads the image.
Normally you'd enter:
https://example.com/image.jpghttps://example.com/image.jpgBut what if an attacker enters:
http://127.0.0.1:8080/adminhttp://127.0.0.1:8080/adminInstead of downloading an image, the server tries to access its own internal admin panel.
Since the request comes from inside the server, it might have access to resources that outsiders can't reach.
Attackers often use SSRF to:
- Access internal services
- Scan internal networks
- Read cloud metadata
- Reach admin panels that aren't publicly exposed
Easy way to remember
SSRF = The attacker tricks the SERVER into making requests.
The target is the server itself.
Putting Them Side by Side
The Trick I Use to Remember Them
Whenever I forget, I don't think about the full names first.
I ask one simple question:
Who is being tricked?
- XSS → Browser
- CSRF → User
- SSRF → Server
That's it.
Once you know who's being fooled, the rest becomes much easier to remember.
Remember This
XSS, CSRF, and SSRF look confusing at first because their names are so similar, and they're all discussed under web security. But the attacks themselves are very different.
If you remember just one thing from this article, remember this:
- XSS → Browser executes malicious JavaScript.
- CSRF → User unknowingly sends a request.
- SSRF → Server unknowingly sends a request.
That's probably the simplest way I've found to separate them in my head.
If this article helped clear up the confusion, Hopefully, the next time you see XSS, CSRF, or SSRF, you won't have to stop and think which one is which.