ReasonJun

XSS 본문

Frontend/Network

XSS

ReasonJun 2023. 6. 16. 00:49
728x90

XSS, short for Cross-Site Scripting, is a type of security vulnerability that occurs when untrusted data is injected into a web application and subsequently rendered on a user's browser. It allows attackers to execute malicious scripts in the victim's browser, potentially compromising their data, stealing sensitive information, or performing unauthorized actions on their behalf.

 

The XSS vulnerability arises when a web application fails to properly validate, sanitize, or encode user-generated input before displaying it to other users. This can happen in various parts of a web application, such as input fields, comments sections, forums, or even URLs.

 

There are three main types of XSS attacks:

  1. Reflected XSS: In a reflected XSS attack, the injected malicious script is included in a URL parameter or form input, and then reflected back to the user in the web application's response. For example, an attacker could construct a URL containing a script, tricking a user into clicking it, and executing the script within the victim's browser.
  2. Stored XSS: In a stored XSS attack, the malicious script is permanently stored on the web server and then served to users when they access a specific page or view content. This can happen, for instance, if a user posts a malicious script as part of a comment or message, which is then stored on the server and displayed to other users who view the content.
  3. DOM-based XSS: DOM-based XSS occurs when the vulnerability is present in the client-side JavaScript code of a web application. The attack exploits the Document Object Model (DOM) of the web page, manipulating it to execute malicious scripts in the user's browser.

The impact of an XSS attack can range from simple annoyances like pop-up messages to severe consequences such as theft of login credentials, session hijacking, or unauthorized control over the victim's account.

 

Preventing XSS attacks requires a combination of security measures, including:

  1. Input validation and filtering: Web applications should validate and sanitize user input to remove or encode any potentially malicious scripts or HTML tags. Input validation should be done on the server-side to ensure that only expected and safe data is accepted.
  2. Output encoding: All user-generated or untrusted data should be properly encoded before it is rendered in HTML pages. This prevents browsers from interpreting the data as executable code.
  3. Content Security Policy (CSP): CSP is a security mechanism that allows website owners to define and enforce a set of policies that restrict which resources (such as scripts, stylesheets, or images) a browser can load. It helps mitigate XSS attacks by limiting the sources from which scripts can be executed.
  4. Contextual output encoding: Different parts of a web page may require different encoding techniques. For example, URL parameters should be encoded using URL encoding, while data embedded within HTML attributes should be encoded using HTML attribute encoding.

By implementing these security practices, developers can significantly reduce the risk of XSS vulnerabilities in their web applications, protecting users' data and maintaining the integrity of their systems. Additionally, keeping software up to date and regularly scanning for vulnerabilities can help identify and address potential XSS vulnerabilities.

 

https://4rgos.tistory.com/1

 

XSS(Cross Site Scripting) 공격이란?

XSS 란? 웹 해킹 공격 중 XSS라는 공격 기법이 있다. Cross Site Scripting의 약자로 CSS라고 하는 것이 맞지만 이미 CSS가 Cascading Style Sheets의 약어로 사용되고 있어 XSS라 한다. XSS는 게시판이나 웹 메일 등

4rgos.tistory.com

https://portswigger.net/web-security/cross-site-scripting

 

What is cross-site scripting (XSS) and how to prevent it? | Web Security Academy

In this section, we'll explain what cross-site scripting is, describe the different varieties of cross-site scripting vulnerabilities, and spell out how to ...

portswigger.net

 

728x90

'Frontend > Network' 카테고리의 다른 글

REST (Representational State Transfer) API (Application Programming Interface)  (0) 2023.06.16
CSRF (Cross-Site Request Forgery)  (0) 2023.06.16
CORS (Cross-Origin Resource Sharing)  (0) 2023.06.16
SSL / TLS / HTTPS  (0) 2023.06.15
Middleware  (0) 2023.06.13
Comments