Skip to content
XSS Write-up Beginner

Cross-Site Scripting

The text describes nine PortSwigger Web Security Academy labs where user input is reflected or stored without proper encoding, allowing script execution. An attacker could inject JavaScript that runs in a victim's browser, potentially stealing cookies or performing actions on their behalf.

medium.com

Published on medium.com

If the text appears italic, it confirms that the input is rendered directly as HTML a clear sign of vulnerability.

Nisithwalpola, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application inserts user-controlled input into HTML, attributes, JavaScript strings, or DOM sinks without proper encoding or validation.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser, potentially stealing cookies or performing actions on their behalf; stored XSS can affect multiple users over time.

What the attacker needed

Victim visits a crafted URL or page; victim interacts with a link or element; none for stored XSS beyond viewing the page

How it was found

  1. Open the lab and identify the input field, such as a search bar or comment form.
  2. Submit a basic string and check if it is reflected or stored on the page.
  3. Inject an HTML tag to see if it is rendered as HTML.
  4. Inject a JavaScript payload and check if an alert box appears.
  5. For DOM XSS, inspect the page source or developer tools to find the sink (document.write, innerHTML, jQuery selector, href attribute).
  6. Modify the URL or input with a payload that breaks out of the context and executes JavaScript.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Cross-site scripting (XSS) is when a website takes text you type and puts it into the page without cleaning it first. If that text contains code, the browser runs it as if the website itself wrote it. This lets an attacker run their own code in other people's browsers, which can steal login details or do things as the victim.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.