일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- web
- Ethereum
- CSS
- blockchain
- Redux
- API
- middleware
- graphQL
- 삶
- concept
- built in object
- CLASS
- HTML
- express.js
- nextJS
- bitcoin
- evm
- Interface
- 기준
- useState
- SSR
- tailwindcss
- REACT
- error
- Props
- solidity
- typeScript
- hardhat
- node.js
- JavaScript
- Today
- Total
ReasonJun
XSS 본문
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:
- 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.
- 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.
- 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:
- 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.
- 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.
- 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.
- 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://portswigger.net/web-security/cross-site-scripting
'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 |