\n```\nIf the page shows `You searched for ` as raw HTML, the script runs → **reflected XSS**.\n\n### Types\n| Type | How |\n| --- | --- |\n| Reflected | Payload in the request is echoed back immediately |\n| Stored | Payload saved (comment, profile) and shown to other users |\n| DOM-based | Front-end JavaScript writes untrusted data into the page |\n\n### Fixes\n- **Output encoding** (frameworks like React/Angular escape by default — avoid `dangerouslySetInnerHTML`/`innerHTML`).\n- **Input validation**.\n- **Content-Security-Policy** to block inline scripts.\n- **HttpOnly** cookies so scripts can't read session cookies.\n\n### What to say in the interview\n\"XSS is untrusted input rendered as executable script in other users' browsers. ZAP's active scanner injects payloads into parameters and checks for unencoded reflection. Fixes are output encoding, safe framework APIs, a strict CSP and HttpOnly cookies.\""}}}

What is XSS and how would ZAP detect it?

IntermediateConceptOWASP ZAP
Answer

Short answer

Cross-Site Scripting (XSS) happens when an app puts untrusted input into a web page without proper encoding, so an attacker's JavaScript runs in other users' browsers — stealing sessions, performing actions as them or defacing pages. ZAP's active scan injects script payloads into parameters and checks whether they come back unencoded in the response.

Example

https://shop.example.com/search?q=<script>alert(document.cookie)</script>

If the page shows You searched for <script>alert(document.cookie)</script> as raw HTML, the script runs → reflected XSS.

Types

Type How
Reflected Payload in the request is echoed back immediately
Stored Payload saved (comment, profile) and shown to other users
DOM-based Front-end JavaScript writes untrusted data into the page

Fixes

  • Output encoding (frameworks like React/Angular escape by default — avoid dangerouslySetInnerHTML/innerHTML).
  • Input validation.
  • Content-Security-Policy to block inline scripts.
  • HttpOnly cookies so scripts can't read session cookies.

What to say in the interview

"XSS is untrusted input rendered as executable script in other users' browsers. ZAP's active scanner injects payloads into parameters and checks for unencoded reflection. Fixes are output encoding, safe framework APIs, a strict CSP and HttpOnly cookies."

All Security Tools questions Roadmap: OWASP ZAP — dynamic testing (DAST)

More on OWASP ZAP