Security Testing (OWASP)

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)

#CategoryWhat it isTest idea
A01Broken Access ControlUsers do things they shouldn'tHit admin endpoints as a regular user — expect 403
A02Cryptographic FailuresWeak/missing encryptionCheck HTTPS forced, secrets not in logs, modern TLS
A03InjectionSQL, command, LDAP, NoSQL injectionSend ' OR 1=1 --, expect parameterised query handling
A04Insecure DesignMissing controls by designThreat modelling sessions
A05Security MisconfigurationDefaults, verbose errorsCheck headers (HSTS, CSP, X-Frame-Options), no stack traces in prod
A06Vulnerable ComponentsOutdated libs with known CVEsDependabot, Snyk, npm audit
A07Authentication FailuresWeak login flowsBrute-force, no MFA, weak passwords accepted, session fixation
A08Software & Data IntegrityTrusting unsigned updatesVerify CI signs releases, package integrity
A09Logging & Monitoring FailuresAttacks not detectedConfirm failed logins are logged + alerted
A10SSRFServer fetches attacker-controlled URLsSend 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.

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

ToolPurpose
sqlmapAutomated SQL injection — given a URL/parameter, tries many payloads
nmapPort scanning, service fingerprinting
niktoWeb server vulnerability scanner
Snyk / DependabotSCA — flags vulnerable dependencies
TrivyScans Docker images for known CVEs
Semgrep / Bandit / ESLint security pluginsSAST — static code analysis

52.6 Authentication tests

52.7 Security headers (cheap wins)

HeaderPurpose
Content-Security-PolicyRestricts which sources scripts/styles can load from
Strict-Transport-SecurityForces HTTPS for the domain
X-Content-Type-Options: nosniffStops MIME sniffing
X-Frame-Options: DENYPrevents clickjacking via iframe
Referrer-PolicyLimits Referer info on outbound links
Permissions-PolicyDisables 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

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.