1/63
Cross-Site Scripting (XSS)
Cross-Site Scripting.
The end user and their browser.
XSS runs code in a user's browser; command injection targets server-side execution.
Improper input validation or output encoding.
The browser treats the delivered content as part of the trusted site.
JavaScript.
Yes. Attacker-controlled HTML or CSS can also be involved.
T1190, Exploit Public-Facing Application.
Maintaining an authenticated browsing session.
An accessible authentication cookie or session token.
The vulnerable website sends it to the browser as part of its response.
Stored XSS and reflected XSS.
Malicious content saved by a server and served to later visitors.
A database, flat file, or other persistent data source.
An author biography, username, review, or comment.
Any visitor who opens the affected page.
No. It can affect any visitor to the stored-content page.
The malicious code can execute silently.
Attacker input immediately returned unsafely in a response and run by the browser.
GET.
The application embeds the term into its response as executable content.
A crafted link in email, messaging, or a malicious advertisement.
The vulnerable site reflects and serves the malicious input to the browser.
Reflected XSS.
Stored persists on the server; reflected appears in an immediate response.
A trusted site may still reflect malicious script from the URL.
Alter content, redirect users, or access browser-session data.
That attacker-supplied JavaScript can execute in the browser.
Demonstrate script execution, not the full risk of XSS.
A JavaScript property exposing cookies accessible to the page's scripts.
Redirecting the browser to another URL.
It may allow misuse of an authenticated session.
A feedback or comment field.
A website administrator.
The embedded JavaScript executes in the administrator's browser.
User-controlled input that is stored or reflected without safe handling.
Reject or restrict dangerous input.
On the server side.
Converting special characters to safe representations for their output context.
It prevents special characters from being interpreted as executable markup.
&
An overlooked syntax or context may bypass the filter.
Consistently used, trusted encoding and sanitization libraries.
OWASP Java Encoder Project.
HTML Purifier.
Joi.
Built-in input handling and context-appropriate output encoding.
Provide partial mitigation and logging when application code cannot be fixed immediately.
It does not replace secure application-side validation and encoding.
Prevents browser JavaScript from reading that cookie.
No. The Secure attribute controls HTTPS-only transmission.
Secure.
Scripts cannot read protected cookies through document.cookie.
Yes. Applications needing JavaScript cookie access may be affected.
Content Security Policy.
Which sources a browser may load content from.
Scripts, CSS, images, fonts, iframes, and other resources.
Yes. Allowed resource sources can be specified.
Reporting browser-detected policy violations to a specified endpoint.
The configured policy may be too permissive or ineffective.
Test that it blocks unwanted sources without breaking legitimate functionality.
Requests matching an attack indicator or pattern.
XSS exploits the browser trust context; it does not itself grant server execution.
Server-side validation, safe output encoding, and defense-in-depth controls.