Skip to content
SoftwareSolutions.net
Glossary

Cross-site scripting (XSS)

Cross-site scripting is an attack that injects malicious script into a web page so it runs in other visitors' browsers.

Definition

Cross-site scripting, or XSS, occurs when a site displays untrusted input without proper encoding, allowing an attacker to insert script that runs in a visitor's browser. The script can steal session cookies, change page content or redirect users.

Prevention relies on escaping output, validating input, and using a Content Security Policy that restricts which scripts can run. Modern frameworks escape output automatically, but raw HTML rendering must be handled with care.

Sanitising rich text before showing it to other users is essential for comment systems and content editors.