52Security Testing (OWASP, ZAP, Burp)
What you will master here
- OWASP Top 10 (2021) — what each is, how to test
- Common attack vectors: XSS, SQLi, CSRF, SSRF, IDOR, command injection
- Authentication / session weaknesses
- Tools: ZAP, Burp Suite, sqlmap, nmap
- Automated scanning in CI
- SDET role vs dedicated security testers
52.1 OWASP Top 10 (2021)
| # | Category | What it is | Test idea |
|---|---|---|---|
| A01 | Broken Access Control | Users do things they shouldn't | Hit admin endpoints as a regular user — expect 403 |
| A02 | Cryptographic Failures | Weak/missing encryption | Check HTTPS forced, secrets not in logs, modern TLS |
| A03 | Injection | SQL, command, LDAP, NoSQL injection | Send ' OR 1=1 --, expect parameterised query handling |
| A04 | Insecure Design | Missing controls by design | Threat modelling sessions |
| A05 | Security Misconfiguration | Defaults, verbose errors | Check headers (HSTS, CSP, X-Frame-Options), no stack traces in prod |
| A06 | Vulnerable Components | Outdated libs with known CVEs | Dependabot, Snyk, npm audit |
| A07 | Authentication Failures | Weak login flows | Brute-force, no MFA, weak passwords accepted, session fixation |
| A08 | Software & Data Integrity | Trusting unsigned updates | Verify CI signs releases, package integrity |
| A09 | Logging & Monitoring Failures | Attacks not detected | Confirm failed logins are logged + alerted |
| A10 | SSRF | Server fetches attacker-controlled URLs | Send URLs pointing at metadata services / localhost |
52.2 Common attack vectors — test recipes
XSS (Cross-Site Scripting)
// Try storing malicious payload, then reading
const payload = `<script>window.__xss=true</script>`;
await request.post('/api/comments', { data: { text: payload } });
await page.goto('/comments');
const xssFired = await page.evaluate(() => (window as any).__xss);
expect(xssFired).toBeFalsy(); // payload should be escaped, not executed
SQL Injection
// Login form trick
POST /login {"email": "x' OR 1=1 --", "password": "anything"}
// Expected: 401, not 200 (server uses parameterised queries → no match)
CSRF
Cross-Site Request Forgery: an attacker's page submits a request using the user's logged-in cookies.
- Mitigations: SameSite cookies, CSRF token, double-submit cookie pattern.
- Test: from a different origin, try POSTing without the CSRF token — expect 403.
IDOR (Insecure Direct Object Reference)
// Log in as user A, try to access user B's resource
const r = await request.get('/api/orders/12345', { headers: { Cookie: cookieA } });
expect(r.status()).toBe(403); // not 200 with B's data
SSRF
POST /api/fetch {"url": "http://169.254.169.254/latest/meta-data/"}
# expected: rejected (cloud metadata endpoint)
POST /api/fetch {"url": "http://localhost:6379/"}
# expected: rejected (internal Redis)
Open Redirect
GET /redirect?to=https://evil.com # expected: rejected or warning, not silent redirect
52.3 ZAP (OWASP Zed Attack Proxy)
Open-source security scanner. Acts as a proxy: spider the app, then run active scans (auth bypass, XSS, SQLi).
# Baseline scan — passive only (safe to run in CI) docker run -t owasp/zap2docker-stable zap-baseline.py -t https://staging.acme.com # Full active scan — never against prod docker run -t owasp/zap2docker-stable zap-full-scan.py -t https://staging.acme.com
Integrate into CI: baseline scan on every PR; full scan nightly. Fail build on high-severity findings.
52.4 Burp Suite
Commercial (free Community edition) intercepting proxy. Used heavily by pentesters. Features: HTTP history, Repeater (resend modified requests), Intruder (fuzz parameters), Decoder, Sequencer (test session tokens for randomness).
Workflow: configure browser to use Burp as proxy, click around the app, watch traffic. Send interesting requests to Repeater to mutate and replay.
52.5 Other tools
| Tool | Purpose |
|---|---|
| sqlmap | Automated SQL injection — given a URL/parameter, tries many payloads |
| nmap | Port scanning, service fingerprinting |
| nikto | Web server vulnerability scanner |
| Snyk / Dependabot | SCA — flags vulnerable dependencies |
| Trivy | Scans Docker images for known CVEs |
| Semgrep / Bandit / ESLint security plugins | SAST — static code analysis |
52.6 Authentication tests
- Brute force: hit /login with 100 wrong passwords — expect 429 after N
- Weak password accepted: try "password" — expect rejection
- Session fixation: pre-set cookie via JS, log in, ensure server issues a NEW session id
- Token leakage: log in, check tokens not appearing in URL/Referer/server logs
- Insecure direct password storage: register, dump DB, ensure password is hashed (bcrypt/argon2), not plain or MD5
52.7 Security headers (cheap wins)
| Header | Purpose |
|---|---|
| Content-Security-Policy | Restricts which sources scripts/styles can load from |
| Strict-Transport-Security | Forces HTTPS for the domain |
| X-Content-Type-Options: nosniff | Stops MIME sniffing |
| X-Frame-Options: DENY | Prevents clickjacking via iframe |
| Referrer-Policy | Limits Referer info on outbound links |
| Permissions-Policy | Disables camera/mic/geo for the page |
test('security headers present', async ({ request }) => {
const r = await request.get('/');
const h = r.headers();
expect(h['content-security-policy']).toBeDefined();
expect(h['strict-transport-security']).toContain('max-age');
expect(h['x-content-type-options']).toBe('nosniff');
});
52.8 SDET role in security
- Own the cheap, automatable checks: headers, auth flows, basic injection fuzzing, dependency scans in CI.
- Partner with dedicated AppSec / pentest teams for deep audits, threat modelling.
- Bug-bounty triage often lands on SDETs — reproduce, file, verify fix.
Module 53 — Security Q&A
What is OWASP Top 10?
A community-maintained ranking of the most critical web application security risks. Updated every few years (latest 2021). Used as a baseline checklist for any web app — if you don't address these, you have known holes.
What's an XSS attack?
Cross-Site Scripting — attacker injects script that the browser executes in the victim's session. Stored XSS lives in the DB (comment, profile); reflected XSS lives in a URL parameter. Mitigation: encode output, CSP header, framework auto-escape.
How do you test for SQL injection?
Send classic payloads in any input that hits SQL —
' OR 1=1 --, '; DROP TABLE, "; SELECT pg_sleep(10) --. Expect normal error handling (parameterised queries), not data leak or response delay. sqlmap automates this thoroughly.What's IDOR?
Insecure Direct Object Reference — endpoint uses an id from the request but doesn't check that the user OWNS that resource.
GET /orders/123 returns user A's order even when authenticated as B. Test: log in as A, fetch B's resource — expect 403.What is CSRF and how do modern apps prevent it?
Cross-Site Request Forgery — attacker's page submits a request using the victim's cookies. Defences: SameSite cookies (browser refuses to send on cross-origin), CSRF tokens in forms, double-submit cookie pattern.
What is SSRF?
Server-Side Request Forgery — attacker controls a URL the server fetches. Used to reach cloud metadata services (AWS 169.254.169.254 gives you instance creds), internal services, or scan internal network. Mitigate with allow-lists, not block-lists.
What is ZAP?
OWASP Zed Attack Proxy — free intercepting proxy + scanner. Baseline scan runs passive checks (safe for CI); full scan actively attacks (for staging/lab). Common in CI as
zap-baseline.py -t https://staging.What is Burp Suite?
Commercial pentest tool (free Community edition). Acts as an intercepting proxy with Repeater (resend modified requests), Intruder (fuzzing), Decoder, Sequencer. The pentester's daily driver.
What security headers should every app have?
Strict-Transport-Security (force HTTPS), Content-Security-Policy (limit script sources), X-Content-Type-Options: nosniff, X-Frame-Options: DENY (clickjacking), Referrer-Policy. Easy automated test.
What is SAST vs DAST?
SAST (Static): analyses code without running it (Semgrep, SonarQube, ESLint security). Catches issues early but misses runtime config. DAST (Dynamic): scans a running app (ZAP, Burp). Catches deployment-specific issues. Use both.
What's session fixation?
Attacker sets a known session id on a victim, victim logs in, attacker now shares the session. Mitigation: server issues a fresh session id on login. Test: set a cookie, log in, verify the cookie changes.
What is dependency scanning?
Checking your third-party libraries for known vulnerabilities (CVEs). Tools: Snyk, Dependabot, npm audit, OWASP Dependency-Check, Trivy (containers). Should fail the build on critical findings.