SPA Penetration Testing
Table of Contents
Related: Web Application Testing Methodology API Testing Methodology JavaScript Recon and Source Analysis JSON Web Tokens JWT Attacks OAuth 2.0 Insecure Authentication Mechanism Session Management Testing Broken Object Level Authorisation Mass Assignment NoSQL Injection CORS CORS Misconfigurations Cross-Site Scripting HTTP Security Headers File Upload Vulnerabilities PT1 Vulnerability Classification Cheat Sheet
This is the entry point for SPA/API pentest targets on PT1. It does not repeat technique detail already covered in the notes above — follow the links for methodology and payloads. This note holds only what is specific to the SPA/API context, plus the consolidated exam-day checklist.
1. Why SPAs Require a Different Approach
Traditional web app testing assumes server-rendered HTML, cookie sessions, and navigable page URLs. SPAs break all three: auth moves to a bearer token, navigation is client-side routing backed by API calls, and the attack surface lives in JSON request/response bodies rather than HTML forms.
| Aspect | Traditional Web App | SPA + API Backend |
|---|---|---|
| Authentication | Session cookie, server state | JWT/token in storage or header |
| Enumeration | Spider HTML links | Watch Network tab; API discovery |
| XSS surface | Server-rendered reflection | DOM-based; framework output encoding |
| Access control | URL-based, middleware enforced | Per-endpoint API authorisation |
| Source exposure | Minimal client logic | Full app logic in JS bundle |
Spidering and checking Set-Cookie will miss most of the surface. Recon must go through Burp HTTP history and the JS bundle instead — see JavaScript Recon and Source Analysis for the full extraction methodology (source maps, bundle grepping, framework fingerprinting).
2. SPA-Specific Recon Notes
Two checks that don't fit cleanly into the general recon methodology:
- Documentation endpoints often enumerate the whole API automatically:
/swagger.json,/openapi.json,/api-docs,/graphqlwith introspection. Import directly into Burp if found. - 403 (not 404) on a fuzzed endpoint confirms it exists behind an authorisation check — flag it as an authorisation-bypass target, not a dead end.
3. Authentication and Authorisation
Full JWT/OAuth/session methodology lives in the linked notes. The one SPA-specific point worth remembering: locate the token first (localStorage, sessionStorage, cookie, or header — check Burp history and DevTools Application tab), because where it's stored changes what's exploitable — a localStorage token is reachable by XSS, an HttpOnly cookie isn't.
For authorisation, BOLA/IDOR and Mass Assignment are the two highest-frequency findings on SPA targets specifically because object identifiers and writable fields both travel through JSON bodies rather than URLs — test every endpoint that takes an identifier or accepts a POST/PUT body against both.
Note: general Broken Access Control (vertical privilege escalation via role/permission bypass, not tied to an object ID) doesn't have its own note yet — BOLA covers the horizontal case. Worth adding if you hit a vertical-escalation finding that doesn't fit BOLA cleanly.
4. Injection
SQL and NoSQL injection methodology is fully covered in their own notes. The only SPA-specific reframing: the injection point is a JSON field or query parameter, not a form field — always capture the raw HTTP request in your report evidence, not just the parameter name.
5. XSS in SPAs
Framework output encoding (React, Vue, Angular) kills most reflected/stored XSS via templates, so on an SPA target focus specifically on:
- DOM-based sinks:
innerHTML,document.write(),eval(),location.hash=/=location.searchread directly into the DOM - React's
dangerouslySetInnerHTML— trace what data reaches it - Stored XSS via API: the payload goes in a JSON POST body, the trigger is a later GET that renders it back
Grep the bundle for sink patterns before manual testing:
grep -E "innerHTML|dangerouslySetInnerHTML|document\.write|eval\(" bundle.js
General XSS methodology and payload catalogue: Cross-Site Scripting.
6. GraphQL (gap)
No dedicated GraphQL testing note exists yet. Minimum checks until
one is written: test introspection (POST /graphql with
query{__schema{types{name}}}), IDOR via direct object queries,
missing authorisation on mutations, and batching-based rate-limit
bypass.
7. Exam-Day Methodology Checklist
Reconnaissance
[ ]Identify JS framework and check for source maps / exposed docs[ ]Capture full Burp HTTP history from normal app usage[ ]Extract endpoints from JS bundle; fuzz for undocumented ones
Authentication
[ ]Locate token storage; decode and test per JWT Attacks checklist[ ]Test missing / malformed / expired token on every endpoint
Authorisation
[ ]BOLA: cross-account object access with two test accounts[ ]Mass assignment: extra fields on every POST/PUT body[ ]Admin endpoints with a standard-user token
Injection
[ ]SQLi and NoSQLi on all string/JSON parameters[ ]Stored XSS on all fields rendered back to users
Other
[ ]CORS with malicious Origin header[ ]JWT payload for sensitive data[ ]GraphQL introspection / IDOR / missing mutation auth if present
8. Reporting
Use exact classification wording and severity guidance from PT1 Vulnerability Classification Cheat Sheet rather than the table that used to live here — the cheat sheet is the maintained source and includes the disambiguation logic. Always cite the exact HTTP request in the finding description; the PT1 rubric rewards technical specificity over category naming alone.