Bitzu

CPSA ยท Web application assessment: injection, sessions and code

Cross-site scripting: types and impact

Reflected, stored and DOM XSS and what an attacker gains from each.

Key points

  • XSS: the victim's browser runs attacker script as the site.
  • Reflected: payload in the request, echoed back; victim must follow a crafted link.
  • Stored: payload saved (comment, profile, ticket), served to later viewers, admins too.
  • DOM-based: client JS puts untrusted data into a dangerous sink; server may never see it.
  • Impact: session theft without HttpOnly, acting as the user, page rewriting, phishing forms, keylogging.

Source: https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html

Practice questions

Single choice

Which XSS type saves the malicious input on the server so that every later visitor to the page is affected?

  1. Reflected XSS
  2. Stored XSS
  3. DOM-based XSS
  4. Cross-site request forgery
Show answer

Answer: B. Stored XSS

Stored XSS persists the payload (database, file) and delivers it to all viewers. Reflected needs each victim to follow a crafted request; DOM-based happens in client-side code.

Select all that apply

Which outcomes can a successful XSS attack realistically give the attacker?

  1. Stealing a session cookie that lacks HttpOnly
  2. Performing actions as the logged-in victim
  3. Showing a fake login form inside the trusted page
  4. Reading the server's application source files directly
  5. Getting an operating system shell on the web server
Show answer

Answer: A. Stealing a session cookie that lacks HttpOnly, B. Performing actions as the logged-in victim, C. Showing a fake login form inside the trusted page

Script runs in the victim's browser within the site's origin: it can read non-HttpOnly cookies, act as the user and alter the page. It does not give access to server source files or an operating system shell by itself.

True or false

True or false: if every session cookie is marked HttpOnly, XSS on that site has no meaningful impact.

Show answer

Answer: False

False. HttpOnly only stops script reading the cookie. Injected script can still send authenticated requests as the victim, change page content and capture typed credentials.

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.

Download on the App StoreGet it on Google Play

More CPSA topics in this module