This article was automatically translated from the original Turkish version.
XSS (Cross-Site Scripting) is a type of security vulnerability that occurs when user input is included in web page content without sufficient validation or filtering, allowing malicious scripts—typically JavaScript—to execute in the user’s browser. This vulnerability enables attackers to run commands in the browsers of other users. XSS can lead to various security issues such as theft of user information, hijacking of session cookies, and redirection of users to different pages.
XSS attacks are categorized into several subtypes based on where the malicious script is processed. In current classifications, these attacks are generally examined under two main categories: server-side and client-side. Server-side attacks occur when malicious data is inserted into page content by the server, while in client-side XSS, the script is executed due to improper handling by client-side code running in the browser.
Reflected XSS arises when an attacker embeds a malicious script into a specially crafted URL. When a user visits this URL, the submitted data is included by the server into the page content, and the browser treats it as part of the page. As a result, the malicious script executes momentarily. This type of attack commonly appears in content that is directly taken from the user and immediately returned as a response, such as search boxes, error messages, or URL parameters.
Reflected XSS affects only the user who is targeted by the attack. When the victim clicks on the link sent by the attacker, JavaScript commands execute, typically targeting sensitive information such as session cookies.
Stored XSS is a persistent form of XSS that occurs when a malicious script is saved in a database, file system, or another permanent storage medium. The attacker injects harmful code into persistent data input fields such as comment sections, profile information, or forum posts. This code is then automatically executed whenever any user visits the affected page.
Because this type of attack can affect all users of the application rather than just a single individual, it is considered the most dangerous form of XSS. Social media platforms and content sharing systems with large user bases are particularly vulnerable to this type of attack.
DOM-based XSS occurs when a script is executed directly on the client side by the browser. In this case, the malicious content is processed by client-side JavaScript code without ever reaching the server. For example, if user input is directly inserted into the HTML structure via JavaScript without proper security checks, DOM XSS can occur.
This type of XSS may not be detectable by the server and is triggered solely by scripts running in the browser. While its detection is difficult and its impact may be limited, it remains an effective method for targeted attacks.
In current literature, XSS attacks are divided into two main groups based on the layer where processing occurs:
This distinction is crucial for developing effective security measures against XSS attacks.
To prevent XSS attacks, user input must be handled securely. To this end:
These measures provide effective protection against both client-side and server-side XSS attacks.
XSS Attack Types
Reflected XSS
Stored XSS
DOM-Based XSS
Classification of Attacks
Protection Methods