Pcornel
Security · Web Security

XSS

Cheat sheet · https://pcornel.dk/topic.php?topic=4755

Back to the Topic

Answer

XSS (cross-site scripting) injects malicious script into pages viewed by other users, stealing sessions or acting as them. Context-aware output encoding, framework auto-escaping and a strict CSP prevent it.

Remember

  • Encode output for its context (HTML, attribute, JS, URL).
  • Use framework auto-escaping.
  • A strict CSP limits damage.

First checks

  • DAST XSS tests (ZAP) — findings
  • curl -sI https://<site> | grep -i content-security-policy — CSP header
  • Output encoding in templates — framework auto-escaping

Verify in this order

untrusted input → encoded output → no script execution

Where it usually breaks

First mismatch in asset/subject identity → trust/authentication → authorization/policy → enforcement/control → telemetry/detection → protected outcome/response; preserve identity/policy/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=4755

Confirmation

Confirm action

Continue?