To test cross-site scripting manually, map every place user input enters the application and where it appears in responses. Submit a unique marker string, find its output contexts, then send harmless proof payloads matched to each context and confirm whether the browser executes them. Test reflected, stored, and DOM-based XSS separately, and only ever test systems you own or have written permission to test.
Key takeaways
- Manual XSS testing beats scanners on context: the payload must match exactly where your input lands in the page.
- Map inputs first with a unique marker string, then test reflected, stored, and DOM-based XSS separately.
- Use harmless proof payloads, test only with written permission, and report the full attack path with evidence.
Automated scanners find the easy cross-site scripting flaws — the ones where a generic payload bounces straight back. The interesting ones hide in a specific context: a name shown only to admins, a value inside a JavaScript string, a field that needs a second click. Finding those takes a human, a method, and about an hour.
What is cross-site scripting?
Cross-site scripting (XSS) is a vulnerability in which an attacker injects code — usually JavaScript — into a web page, and the victim's browser runs it as if the site itself had written it.
Because the script runs in the victim's browser session, it can do what the victim can do: read cookies, steal session tokens, log keystrokes, change page content, or make requests as the victim. Attackers typically use XSS to steal victim cookies, perform clipboard theft, and change page content such as download links, according to the OWASP Web Security Testing Guide.
XSS is a client-side vulnerability: the attack executes in the victim's browser, not on the server. It appears in the OWASP Top 10 under A03 (Injection) and remains one of the most frequently reported vulnerability types in bug bounty programs.
What are the three types of XSS?
XSS comes in three types, and you must test each one differently. A test that only checks search boxes will miss stored and DOM-based flaws entirely.
| Reflected XSS | Stored XSS | DOM-based XSS | |
|---|---|---|---|
| Also called | Non-persistent, type 1 | Persistent, type 2 | Type 0 |
| Where input lives | In a single response | In a database, shown later | In the browser only |
| Victim needs | To open a crafted link | To view the infected page | To load a crafted URL or interact |
| Who is affected | One victim per link | Everyone who views the page | Whoever loads the page |
| Danger | High, but needs social engineering | Highest — self-spreading to viewers | High — invisible to the server |
| OWASP guide | WSTG-INPV-01 | WSTG-INPV-02 | WSTG-INPV-01 (DOM section) |
Reflected XSS is the most frequently found type in the wild, according to OWASP. Stored XSS is the most dangerous, because one submission can attack every user — including administrators — who later views the page. DOM XSS is the hardest to find, because the server never sees the payload: JavaScript on the page itself writes attacker-controlled data into the document. The OWASP guide to reflected XSS covers the first type in detail.
What do you need before you start testing XSS?
Manual XSS testing needs little equipment, but it needs a safe environment and a repeatable method. Set these up first.
- Written permission. Scope, target, and rules of engagement in writing — the same discipline as any vulnerability assessment and penetration test.
- A test environment. A staging copy of the application, or a deliberately vulnerable training app. Never test against production data or real users.
- A browser with developer tools. You will use View Source and the Elements panel constantly to see exactly where your input lands.
- A web proxy (optional but recommended). A proxy lets you see hidden form fields, modify requests, and repeat a request with different payloads. OWASP recommends using an in-browser HTML editor or web proxy to view hidden variables.
- A notebook. Record every input point, every marker result, and every payload you tried. A finding without a reproduction path is not a finding.
Keep your payloads harmless. A proof payload should demonstrate execution — an alert box, a changed page title — and nothing else. Never exfiltrate cookies or session data during a test.
Step 1: map every input and output point
Before you send a single payload, map the application: find every place user input enters, and every place it comes back out.
Input sources include form fields, URL parameters, cookies, HTTP headers, and data stored earlier, such as a profile name, comment text, or uploaded file name. Hidden inputs matter too: check hidden form fields, predefined radio and selection values, and POST data, as OWASP's reflected XSS guide instructs.
Submit a unique, identifiable marker string — something like xsstest12345 — through each input, then search for it in the response HTML. Use your browser's developer tools to find every location where the string appears, and document the exact context: inside a paragraph, inside an attribute value, inside a script block, or inside a URL.
Check both the immediate response (reflected XSS) and every page where stored data is displayed (stored XSS). For stored input, check admin pages too — OWASP notes that all areas accessible to administrators should be tested, since stored data often surfaces there.
Step 2: determine the output context
The output context decides which payload can execute. The same payload that works in one context fails silently in another, which is why scanners miss so much.
HTML body context: your input appears between tags, such as inside a paragraph. You need to inject an HTML tag that executes JavaScript, such as a script element or an element with an event handler.
HTML attribute context: your input appears inside an attribute value, such as value="...". You need to close the attribute with a quote, optionally close the tag, and inject a new element or event handler.
JavaScript context: your input appears inside a script block, such as var name = '...';. You need to close the string with a quote and break out of the statement to inject executable code.
URL context: your input appears in a link or image source. Test whether a javascript: URL is accepted and whether quotes pass through unencoded.
CSS context: your input appears inside a style block or style attribute. Breaking out usually means closing the style block first, then injecting markup.
Step 3: send context-matched proof payloads
Now send payloads matched to each context you found. Start simple, then escalate only if the simple payload is blocked.
HTML body context
Try a basic script tag first, using a harmless alert with a unique number so you can tell your payload apart from others: <script>alert(1337)</script>. If script tags are filtered, try an image tag with an event handler: <img src=x onerror=alert(1337)>.
HTML attribute context
Close the attribute and inject a handler: " onmouseover=alert(1337) x=". If the attribute is already an event handler, such as onmouseover, your input is already in a JavaScript execution context and needs no breakout tag.
JavaScript context
Close the string and the statement: ';alert(1337);//. The trailing comment marker stops the rest of the original line from breaking your payload.
If a payload is blocked, test the filter
Filters are often incomplete. OWASP notes that an application might filter out <script> but not its encoded form %3cscript%3e. Test case variations, double encoding, and alternative event handlers — but only to prove the bypass, and document exactly what worked.
Confirm every finding in a clean browser session. A payload that fires only because of a cached page or a browser extension is not a real finding. Record the exact request, the exact response location, and a screenshot of the alert.
Step 4: test stored XSS separately
Stored XSS needs a different workflow, because the payload and the victim's page load are separate events. Follow the same mapping, but through stored data.
First, identify every place user input is stored: profile fields, comments, reviews, shopping cart items, file uploads, and application settings. Submit your marker string through each one.
Then view every page where that data is displayed — as a normal user and as an administrator — and search for the marker. OWASP's stored XSS guide gives an example where an email value is stored and later rendered inside an input tag; breaking out of that tag needs a payload that closes the attribute first. The full method is in the OWASP guide to stored XSS.
Test the same injection with both GET and POST requests, and consider disabling JavaScript or using a proxy if client-side controls interfere with submission. Stored payloads can also arrive through out-of-band channels, such as data imported from another system, so ask what feeds the database besides the web form.
When you find stored XSS, prove it with a second account: submit from one user, trigger it from another. That is the evidence that makes the finding undeniable — and it is also why stored XSS is the most dangerous type.
Step 5: test DOM-based XSS
DOM XSS lives in the browser. The server never sees the payload, so server-side logs and scanners will not help you find it.
Look for JavaScript that reads attacker-controlled data — from the URL fragment, document.location, document.referrer, or stored values — and writes it into the page with a dangerous sink such as innerHTML, document.write, or eval.
Test by putting a marker in the URL fragment and watching whether it appears in the page. Then try a payload in the same spot. Because DOM XSS depends on client-side code paths, you may need to interact with the page — click a tab, submit a form, or change a filter — before the payload runs.
Browser developer tools are your best friend here: set breakpoints on the sink, trace the data flow from source to sink, and confirm that your input reaches executable code without encoding.
How do you report an XSS finding?
A good XSS report lets a developer reproduce the flaw in minutes and understand its impact. Include these five things.
- Reproduction steps: the exact URL, parameter, payload, and browser.
- Context: where the input lands in the page, with the surrounding HTML.
- Proof: a screenshot or recording of the harmless alert firing.
- Impact: what an attacker could do — session theft, account takeover, defacement, or phishing from a trusted domain.
- Fix: context-appropriate output encoding, input validation, and a Content Security Policy as defense in depth.
After the fix, retest with the same payload. A fix that blocks your original payload but not a case variation is not a fix — test the filter again before you close the finding.
Common manual XSS testing mistakes
Manual testing fails in predictable ways. Avoid these five mistakes and your tests will find far more.
- Testing only search boxes. Search is the obvious input, but profiles, comments, file names, and headers are where the interesting flaws live.
- Using one payload everywhere. A script tag that works in body context fails in attribute context. Match the payload to the context every time.
- Stopping at reflection. Input appearing in a response is not a vulnerability — execution is. Always prove it with a harmless alert.
- Forgetting stored and DOM XSS. If you only test reflected input, you miss the most dangerous type and the hardest to find.
- Testing production. A stored payload on a live site can attack real users. Use staging or a training application.
For a broader testing program, read our guide to vulnerability assessment and penetration testing, which covers how manual testing fits into a full security program.
You can also check your site's basic defenses with our free security headers checker.
The bottom line
Manual XSS testing is a method, not a talent: map the inputs, find where they land, match the payload to the context, and prove execution with a harmless alert. Do that for reflected, stored, and DOM XSS, and you will find flaws that scanners walk straight past.
Start on a test application, keep your payloads harmless, and report every finding with reproduction steps and impact. Then check your site's defenses with the security headers checker — and retest after every fix.
Frequently asked questions
What is cross-site scripting (XSS)?
Cross-site scripting is a vulnerability where an attacker injects browser-executable code, usually JavaScript, into a web page that other users then load. The victim's browser runs the attacker's script, which can steal cookies, log keystrokes, or change page content.
What is the difference between reflected, stored, and DOM XSS?
Reflected XSS returns your input in a single response, such as a search result, and needs a victim to open a crafted link. Stored XSS saves your input in a database and runs it for everyone who later views the page. DOM XSS happens entirely in the browser, when JavaScript unsafely writes attacker-controlled data into the page.
Is it legal to test a website for XSS?
Only with permission. Testing a site you do not own, or without written authorization, can be illegal even if you mean well. Test your own applications, a staging environment, or a bug bounty program that explicitly allows it.
What is a safe payload for testing XSS?
A harmless proof payload is one that shows execution without stealing anything, such as a script that shows an alert box with a test number, or an image tag with an onerror handler that changes the page title. Never use payloads that exfiltrate cookies or session data on a live system.
Why do scanners miss XSS that manual testing finds?
Scanners send generic payloads and check for reflection, but they often miss context-specific cases: input inside a JavaScript string, a stored value shown only to admins, or DOM XSS that needs specific user interaction. A human tester maps the context and crafts a matching payload.
What does XSS look like in a response?
Your marker string appears in the page source unencoded, for example inside a paragraph, an attribute value, or a script block. If angle brackets and quotes survive unencoded, the application is probably not encoding output — the next step is a proof payload.
How do you test stored XSS?
Submit a marker string through every field that saves data — profiles, comments, cart items, file names — then view every page where that data is displayed, including admin pages. Check both the immediate response and the stored display, and test with both GET and POST requests.
What is the best way to prevent XSS?
Encode output for its context, validate input, and add defense in depth with a Content Security Policy. Frameworks that auto-escape output help, but manual testing is still needed because encoding can be bypassed in the wrong context.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the OWASP Web Security Testing Guide chapters on reflected and stored XSS (WSTG-INPV-01 and WSTG-INPV-02).
How we write and fact-check →