AI pentesting guides / What to test

React, Vue, Angular

Single-page application pentesting

Single-page application pentesting tests a browser app built with frameworks such as React, Angular or Vue together with the API behind it, to prove flaws in client-side code, token handling and, most importantly, server-side authorisation. In an SPA the browser does the rendering and routing, so the server is reduced to an API and every security decision must live there.

SPAs change how testing works more than what is tested. Traditional crawlers see an empty HTML shell; the real attack surface is in the JavaScript bundle and the API calls it makes.

Mapping an SPA

Read the JavaScript bundles and source maps if exposed: they list API routes, feature flags, admin views hidden behind client-side checks and sometimes keys. Exercise the app through a proxy with each role to capture real API traffic. Client-side route guards hide pages, they do not protect data, so any admin view in the bundle points at API calls worth testing as a normal user.

SPA-specific checks

  • DOM-based XSS through sinks such as innerHTML, dangerouslySetInnerHTML or bypassed Angular sanitisation, fed by URL fragments or query strings.
  • Token storage: tokens in localStorage are readable by any script running in the page, so XSS becomes account takeover.
  • CORS policy on the API, especially reflected origins with credentials allowed.
  • Exposed source maps, environment files and debug builds.
  • Open redirects in post-login return URLs.
  • API authorisation: the SPA hides buttons, the API must refuse the calls.

Proving SPA findings

For API issues, a direct request with another user's ID or a lower role, plus a control, is proof. For XSS, proof is script execution in a browser, ideally shown with a harmless alert or console marker in a recorded session, not just a reflected string. For token exposure, show that a script in the page context can read the token.

Remediation

Enforce authorisation on every API endpoint regardless of what the UI shows. Avoid raw HTML sinks and keep framework sanitisation on. Prefer HttpOnly, Secure, SameSite cookies or a backend-for-frontend pattern over tokens in localStorage. Set a Content Security Policy. Do not ship source maps to production unless you intend them to be public.

With Pentest-Swarm

How Pentest-Swarm tests single-page applications

Pentest-Swarm treats an SPA as a web app plus an API, and spends most effort on the API, where the high-impact findings are.

  • JavaScript-aware crawling with katana and historical URLs with gau to recover API routes from the bundle and history.
  • BOLA, mass assignment and 403-bypass proofs on the API using differential oracles.
  • Reflected and DOM XSS discovery with dalfox, reported with evidence.
  • Open-redirect proof read from the Location header against a safe sentinel host.

Where it falls short

Pentest-Swarm's XSS findings are not confirmed by a headless browser oracle, so treat them as evidence to verify rather than proven execution. It does not currently test CORS misconfiguration, CSRF or client-side token storage automatically. For complex client-side logic, a manual tester with browser tooling remains the better choice.

Questions

Are SPAs more secure than server-rendered apps?

Not inherently. Frameworks reduce some XSS risk, but SPAs move logic to the client, which tempts teams to rely on client-side checks the API does not repeat.

Should JWTs be stored in localStorage?

It is common but risky, because any XSS can read them. HttpOnly cookies or a backend-for-frontend reduce that exposure.

Do exposed source maps matter?

They make reverse engineering easier and sometimes leak internal comments, routes or keys. Treat them as an information exposure.

Sources

  1. OWASP DOM-based XSS Prevention Cheat Sheet