arrow_backAll termssecurity

XSS

XSS (Cross-Site Scripting) is a web security vulnerability that allows attackers to inject malicious client-side scripts into web pages viewed by other users,…

Also available: Auf Deutsch

XSS, or Cross-Site Scripting, is a prevalent and dangerous web security vulnerability that allows attackers to inject malicious client-side scripts (typically JavaScript) into web pages viewed by other users. These injected scripts can then execute in the victim's browser, potentially leading to a wide range of attacks, from stealing cookies and session tokens to defacing websites or redirecting users to malicious sites.

XSS attacks generally fall into three categories:

  • Stored XSS (Persistent XSS): The malicious script is permanently stored on the target server (e.g., in a database, comment section, or forum post) and delivered to users who visit the affected page.
  • Reflected XSS (Non-Persistent XSS): The malicious script is reflected off a web server, such as in an error message, search result, or any other response that includes data sent by the user as part of the request. The script is not stored on the server.
  • DOM-based XSS: The vulnerability lies in the client-side code itself, where the malicious payload is executed as a result of modifying the DOM environment in the victim's browser rather than being directly injected into the server's response.

A common example involves an attacker submitting a comment like <script>alert('You are hacked!');</script> to a vulnerable forum. If the forum doesn't properly sanitize user input, this script will execute in the browsers of anyone viewing that comment. To prevent XSS, developers must always sanitize and validate all user-supplied input before rendering it on a web page, using techniques like output encoding, input validation, and implementing a robust Content Security Policy (CSP).

Related terms

Audit your site on all of these?

Pantra scans you in 8 seconds. Free, no signup.

Scan my sitearrow_forward