Classification and variants
- CWE-79 Cross-site Scripting; OWASP Top 10 2021 A03 Injection.
- Reflected: input in the request is echoed into the response.
- Stored: input is saved and served to other users later, such as comments or profile fields.
- DOM-based: client-side JavaScript writes attacker-controlled data (often from the URL) into a dangerous sink without the server being involved.
How XSS is found
Send a unique marker string to every parameter and field, then find where it appears in responses and in the DOM. For each reflection, identify the context: HTML body, attribute, JavaScript string, URL or CSS. The context determines which characters must survive for execution. For DOM XSS, trace sources such as location.hash into sinks such as innerHTML or eval in the client code. Stored XSS needs checking wherever the data is later displayed, including admin panels and emails.
What counts as proof
A reflected string is not proof. Proof is execution: a harmless payload such as an alert or a console marker running in a real browser, shown in a recording or headless-browser log, with the exact URL or stored input that triggered it. Note whether a Content Security Policy blocks execution, since that changes severity.
Remediation
Encode output for its context, using a framework that escapes by default, and avoid raw-HTML APIs (innerHTML, dangerouslySetInnerHTML, v-html). Where HTML input is genuinely required, sanitise with a maintained library such as DOMPurify. Add a strict Content Security Policy as defence in depth, and keep session cookies HttpOnly so script cannot read them.
How Pentest-Swarm tests for XSS
XSS is one of the classes Pentest-Swarm reports, using specialist XSS tooling from its arsenal.
- dalfox and gxss find reflected parameters and test context-aware payloads, including DOM-based cases.
- katana crawling and arjun parameter discovery widen the set of inputs tested.
- Findings include the request, the reflection context and the payload, with severity and CVSS.
- Practise on OWASP Juice Shop, a bundled lab with several XSS challenges.
Where it falls short
Pentest-Swarm has no headless-browser oracle for XSS today, so its XSS findings are not badged VERIFIED by execution; confirm them in a browser before treating them as proven. Stored XSS that surfaces only in another role's view, or in emails and PDFs, is easy for any automated tool to miss. A manual tester is better for complex client-side frameworks and CSP bypass analysis.
Questions
Do React and Angular prevent XSS?
They escape output by default, which prevents most cases. XSS still appears through raw-HTML APIs, unsafe URL schemes in links and third-party components.
Is self-XSS a vulnerability?
Usually not on its own, since the user attacks only themselves. It can matter if combined with CSRF or login CSRF.
Does a Content Security Policy fix XSS?
No. A strict CSP limits what injected script can do or whether it runs, but the injection should still be fixed.