CPSA ยท Web testing techniques
Testing for cross-site scripting
Detecting injection points, arbitrary script execution context, data theft and phishing use.
Key points
- Testing: submit a short unique marker into every input, then find where it is reflected or stored.
- Output context (HTML body, attribute, script block, URL) decides which characters break out and run script.
- Types: reflected, stored, DOM-based.
- Impact: script runs with the victim's privileges; reads page data, acts as the user, captures credentials via fake forms, defaces content.
Source: https://portswigger.net/web-security/cross-site-scripting
Practice questions
Which XSS type stores the malicious script on the server and serves it to later visitors?
- Reflected XSS
- Stored XSS
- DOM-based XSS
- Self-XSS only
Show answer
Answer: B. Stored XSS
Stored (persistent) XSS lives in the application's data. Reflected comes from the current request; DOM-based arises in client-side code handling data.
What can an attacker achieve with script running in a victim's session via XSS?
- Perform actions as the victim within the application
- Read data the victim's page can access
- Directly read the server's source code files
- Present a fake login form to capture credentials
- Alter the database schema directly
Show answer
Answer: A. Perform actions as the victim within the application, B. Read data the victim's page can access, D. Present a fake login form to capture credentials
The script acts with the victim's rights: it can read accessible data, perform actions and show fake login prompts. It cannot read the server's source code or change the database schema directly.
A page served over HTTPS cannot be affected by XSS because the traffic is encrypted.
Show answer
Answer: False
False. TLS protects data in transit; XSS is a flaw in how the application handles input and output, and the injected script runs inside the encrypted page.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
