What Are the Two Primary Classifications of Cross Site Scripting?


Scott Campbell

What Are the Two Primary Classifications of Cross Site Scripting?

Cross-Site Scripting (XSS) is a common security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. This can lead to various attacks, such as session hijacking, data theft, and defacement. XSS attacks are classified into two primary types: Stored XSS and Reflected XSS.

Stored XSS

In Stored XSS attacks, the attacker injects malicious scripts into a vulnerable website’s database or server. These scripts are then served to users who visit the affected page.

The injected code is permanently stored on the server, hence the name “Stored XSS.” When a user loads the infected page, their browser executes the injected script, allowing the attacker to steal sensitive information or perform unauthorized actions on behalf of the victim.

Stored XSS vulnerabilities commonly occur in user-generated content areas such as comment sections, forums, or message boards. If proper input sanitization and validation measures are not in place, attackers can exploit these areas to insert their malicious code.


An e-commerce website allows users to post product reviews. A user named “Alice” posts a review containing JavaScript code that steals user login credentials when viewed by other users.

The website fails to sanitize Alice’s input properly and stores her review as-is in their database. When other users read her review, their browsers execute the injected script unknowingly.

Reflected XSS

In Reflected XSS attacks, the malicious script is embedded within a URL or form input value. When a victim clicks on a specially crafted link or submits a vulnerable form, their browser sends a request to the server with the injected script included as part of the request parameters. The server then reflects the input back to the user’s browser, which executes the script.

Reflected XSS vulnerabilities often occur in search queries, error messages, or any other situation where user input is directly displayed without proper sanitization or encoding. Attackers can trick victims into clicking on a malicious link or lure them into submitting a form with injected code.

A banking website has a search feature that displays the search query in the URL. An attacker crafts a URL with a malicious script as part of the search parameter.

When an unsuspecting user clicks on this URL, their browser sends a request to the server, which includes the malicious script. The server then reflects this input back to the user’s browser, executing the script and potentially compromising their account.

In conclusion, Stored XSS and Reflected XSS are two primary classifications of Cross-Site Scripting attacks. Understanding these types of vulnerabilities can help developers implement appropriate security measures to protect against such attacks.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy