What is XSS?

what is XSS cross-site scripting

XSS, short for cross-site scripting, is a vulnerability that lets an attacker run their own JavaScript inside your visitors’ browsers. It is one of the most common and damaging flaws on the web, because a successful XSS attack executes with the full trust of your site. That means it can read cookies, hijack logged-in sessions, capture what users type, rewrite the page, or quietly redirect people to a malicious destination, all while the address bar still shows your genuine domain.

What is XSS and why is it dangerous?

Browsers trust the code a website sends them. XSS abuses that trust by tricking your site into delivering attacker-controlled script as if it were your own. Because the malicious code runs in the context of your domain, the usual boundaries that keep sites apart do not protect the victim. A single XSS hole on a login page can be enough to steal credentials at scale, which is why it consistently ranks among the most serious web application risks.

How XSS works

XSS happens when a site takes input from a user and includes it in a page without properly neutralising it. If a comment box, search field or URL parameter accepts text and that text is written straight into the HTML, an attacker can supply script instead of ordinary words. When another visitor loads the page, their browser cannot tell the injected script from your legitimate code, so it runs it. The root cause is almost always untrusted data being treated as trusted markup.

The main types of XSS

How to prevent XSS

Preventing XSS comes down to never trusting input and always controlling output. The core defences are:

XSS on WordPress sites

On WordPress, most XSS vulnerabilities arrive through plugins and themes rather than the core software, which is well hardened. A poorly written plugin that echoes a URL parameter or form field without escaping it can expose your whole site. Keeping everything updated closes known holes, as covered in our article on WordPress plugin and theme vulnerabilities, and a Content Security Policy adds a valuable second line of defence.

What can an attacker actually do with XSS?

It helps to make the risk concrete, because XSS can sound abstract until you see what it enables. Once an attacker can run script in your visitors’ browsers, they can steal session cookies and log in as those users, effectively bypassing passwords and even some two-factor setups. They can silently submit forms on the victim’s behalf, changing account details or making purchases. They can inject a fake login prompt over your real page to harvest credentials, log every keystroke a visitor types, or swap your links for ones that lead to malware. On an admin account, stored XSS can be escalated into full control of the site, planting backdoors that survive the original flaw being patched. The damage is not limited to the individual either: because stored XSS is served to everyone who views the affected content, a single injection can compromise thousands of visitors before anyone notices. That combination of stealth and reach is why XSS is treated as a high-severity issue rather than a cosmetic bug.

How to check your site for XSS risk

XSS holes are easy to introduce and hard to spot by eye, especially across many plugins. Run a security scan with EzyAudit AI and we check for the conditions that lead to cross-site scripting, including missing security headers that would otherwise contain it, and explain each finding in plain language. Review the full list of checks we run. For deep technical guidance, the OWASP cross-site scripting resource is the definitive reference.

XSS turns your own trusted pages into a weapon against your visitors, but it is preventable with the right defences. Scan your website now to see whether your site is protected.

Scroll to Top