Concept
What Is XSS?
XSS (Cross-Site Scripting) is a vulnerability where an attacker makes a website run attacker-controlled JavaScript in victim user's browser.
Please see below steps for better understanding:
1. A website accepts input from a user.
2. The website puts that input into a webpage without properly escaping or sanitizing it.
3. The attacker puts JavaScript instead of normal text.
4. The website sends that JavaScript to another user.
5. The victim's browser executes it as if it came from the trusted website.
Example:
Suppose a website displays: Welcome, <username>
Normally someone enters John
But an attacker enters malicious HTML/JavaScript
If the application doesn't properly handle it, the browser may interpret the input as code instead of text.