Web Security
Purpose
Assess the browser-facing attack surface: cross-site scripting, cross-site request forgery, cookie/session safety, and the headers/policies that harden a web app — the client-side counterpart to api-security.
When to Use
- Reviewing a web/dashboard frontend (and its browser-facing backend behavior) for security, in
../../security-review.
- Not for API-layer risks (
api-security) or mobile (mobile-security) — though headers/CORS overlap with api-security.
Inputs
- The web app + how it renders user/content data and authenticates (cookies vs tokens).
- Backend response headers, CORS, and cookie configuration.
Discovery Questions
- Where is user/external content rendered — is output encoded, and is dangerous HTML injection (
dangerouslySetInnerHTML, raw templating) present?
- Is there a Content Security Policy, and does it meaningfully constrain scripts?
- If auth uses cookies, is CSRF protected and are cookies
httpOnly/secure/sameSite?
- Are security headers present (HSTS, X-Content-Type-Options, frame-ancestors/X-Frame-Options)? Any open redirects?
Responsibilities
- XSS: verify output encoding by default (frameworks help, but
dangerouslySetInnerHTML/v-html/raw injection are findings); user-controlled HTML sanitized; a Content Security Policy as defense-in-depth constraining script sources.
- CSRF: for cookie-based auth, state-changing requests are CSRF-protected (tokens /
sameSite cookies); token-in-header auth is inherently less CSRF-prone — confirm which model and that it's coherent.
- Cookies/session:
httpOnly (no JS access), secure (HTTPS-only), sameSite set; session invalidation on logout (authentication-security).
- Headers: HSTS,
X-Content-Type-Options: nosniff, frame protection (clickjacking), a reviewed CSP; correct CORS (no wildcard-with-credentials — shared with api-security).
- Redirects/navigation: no open redirects (user-controlled redirect targets validated against an allowlist);
target=_blank gets rel=noopener.
- No secrets in the bundle: anything shipped to the browser is public — flag embedded secrets (
../../devops/environment-management boundary).
- User-uploaded content served safely (separate origin, correct content-type/disposition —
../../backend/file-storage).
- Route findings to fixes + regression tests (
security-regression-testing).
Required Workflow
- Review rendering paths for XSS; check for a meaningful CSP.
- Determine the auth model; verify CSRF handling + cookie flags.
- Check security headers + clickjacking protection.
- Check redirects/navigation + bundle secret exposure.
- Verify safe serving of user content; record findings + tests.
Decision Rules
- Framework auto-escaping helps, but every
dangerouslySetInnerHTML/raw-HTML path is a finding until proven sanitized.
- Cookie auth without CSRF protection is a confirmed finding; token-in-header changes the model — verify coherence, don't assume.
- A CSP is defense-in-depth, not a substitute for encoding — check both.
- Anything in the client bundle is public — embedded secrets are always findings.
Rules
- Findings separated Confirmed vs Potential; never declare the app "secure" (
../../security-review).
- Each finding maps to a fix + a regression test.
- Bundle secrets, XSS sinks, and missing CSRF protection are treated as real findings, not style notes.
Anti-Patterns
- Rendering user content via
dangerouslySetInnerHTML without sanitization.
- Cookie auth with no CSRF defense.
- Non-
httpOnly/secure/sameSite session cookies.
- Missing security headers / no CSP.
- Open redirects from user-controlled URLs.
- Secrets shipped in the client bundle.
Validation Checklist
Definition of Done
A recorded web security assessment — XSS/CSP, CSRF, cookie/session safety, headers, redirects, and bundle secret exposure — with Confirmed/Potential findings routed to fixes and regression tests, and no "secure" claim.
Related Skills
api-security, authentication-security, ../../backend/backend-security, ../../backend/file-storage, ../../devops/environment-management, secrets-audit, security-regression-testing, ../../security-review, threat-modeling.
Related Knowledge
../../../knowledge/ (rendering paths, auth model, browser threats).
Related References
../../../references/security/ (web review checklists, when populated).
Context Loading Guidance
- Requires: the web app's rendering + auth, backend headers/cookies/CORS.
- Does not require: API business logic depth (
api-security), mobile concerns.
- May load:
api-security, authentication-security.
- Stop when: findings + routed fixes/tests are recorded.
Token Efficiency Guidance
The finding table (category → location → severity → fix) is the artifact; focus on XSS sinks, CSRF, and cookie flags where browser breaches concentrate.
1---2name: web-security3description: Use to review web/browser security — XSS (output encoding, CSP), CSRF for cookie auth, secure cookie flags, security headers, clickjacking, open redirects, and no secrets in client bundles. The browser-facing security lens; API-layer concerns are api-security.4---56# Web Security78## Purpose910Assess the browser-facing attack surface: cross-site scripting, cross-site request forgery, cookie/session safety, and the headers/policies that harden a web app — the client-side counterpart to `api-security`.1112## When to Use1314- Reviewing a web/dashboard frontend (and its browser-facing backend behavior) for security, in `../../security-review`.15- **Not** for API-layer risks (`api-security`) or mobile (`mobile-security`) — though headers/CORS overlap with `api-security`.1617## Inputs1819- The web app + how it renders user/content data and authenticates (cookies vs tokens).20- Backend response headers, CORS, and cookie configuration.2122## Discovery Questions2324- Where is user/external content rendered — is output encoded, and is dangerous HTML injection (`dangerouslySetInnerHTML`, raw templating) present?25- Is there a **Content Security Policy**, and does it meaningfully constrain scripts?26- If auth uses cookies, is **CSRF** protected and are cookies `httpOnly`/`secure`/`sameSite`?27- Are security headers present (HSTS, X-Content-Type-Options, frame-ancestors/X-Frame-Options)? Any open redirects?2829## Responsibilities3031- **XSS**: verify output encoding by default (frameworks help, but `dangerouslySetInnerHTML`/`v-html`/raw injection are findings); user-controlled HTML sanitized; a **Content Security Policy** as defense-in-depth constraining script sources.32- **CSRF**: for cookie-based auth, state-changing requests are CSRF-protected (tokens / `sameSite` cookies); token-in-header auth is inherently less CSRF-prone — confirm which model and that it's coherent.33- **Cookies/session**: `httpOnly` (no JS access), `secure` (HTTPS-only), `sameSite` set; session invalidation on logout (`authentication-security`).34- **Headers**: HSTS, `X-Content-Type-Options: nosniff`, frame protection (clickjacking), a reviewed CSP; correct CORS (no wildcard-with-credentials — shared with `api-security`).35- **Redirects/navigation**: no open redirects (user-controlled redirect targets validated against an allowlist); `target=_blank` gets `rel=noopener`.36- **No secrets in the bundle**: anything shipped to the browser is public — flag embedded secrets (`../../devops/environment-management` boundary).37- **User-uploaded content** served safely (separate origin, correct content-type/disposition — `../../backend/file-storage`).38- Route findings to fixes + regression tests (`security-regression-testing`).3940## Required Workflow41421. Review rendering paths for XSS; check for a meaningful CSP.432. Determine the auth model; verify CSRF handling + cookie flags.443. Check security headers + clickjacking protection.454. Check redirects/navigation + bundle secret exposure.465. Verify safe serving of user content; record findings + tests.4748## Decision Rules4950- Framework auto-escaping helps, but every `dangerouslySetInnerHTML`/raw-HTML path is a finding until proven sanitized.51- Cookie auth without CSRF protection is a confirmed finding; token-in-header changes the model — verify coherence, don't assume.52- A CSP is defense-in-depth, not a substitute for encoding — check both.53- Anything in the client bundle is public — embedded secrets are always findings.5455## Rules5657- Findings separated Confirmed vs Potential; never declare the app "secure" (`../../security-review`).58- Each finding maps to a fix + a regression test.59- Bundle secrets, XSS sinks, and missing CSRF protection are treated as real findings, not style notes.6061## Anti-Patterns6263- Rendering user content via `dangerouslySetInnerHTML` without sanitization.64- Cookie auth with no CSRF defense.65- Non-`httpOnly`/`secure`/`sameSite` session cookies.66- Missing security headers / no CSP.67- Open redirects from user-controlled URLs.68- Secrets shipped in the client bundle.6970## Validation Checklist7172- [ ] Output encoding verified; XSS sinks sanitized; meaningful CSP.73- [ ] CSRF handled for the auth model; cookies httpOnly/secure/sameSite.74- [ ] Security headers + clickjacking protection present.75- [ ] Redirects validated; no bundle secrets.76- [ ] User content served safely; findings → regression tests.7778## Definition of Done7980A recorded web security assessment — XSS/CSP, CSRF, cookie/session safety, headers, redirects, and bundle secret exposure — with Confirmed/Potential findings routed to fixes and regression tests, and no "secure" claim.8182## Related Skills8384`api-security`, `authentication-security`, `../../backend/backend-security`, `../../backend/file-storage`, `../../devops/environment-management`, `secrets-audit`, `security-regression-testing`, `../../security-review`, `threat-modeling`.8586## Related Knowledge8788`../../../knowledge/` (rendering paths, auth model, browser threats).8990## Related References9192`../../../references/security/` (web review checklists, when populated).9394## Context Loading Guidance9596- **Requires:** the web app's rendering + auth, backend headers/cookies/CORS.97- **Does not require:** API business logic depth (`api-security`), mobile concerns.98- **May load:** `api-security`, `authentication-security`.99- **Stop when:** findings + routed fixes/tests are recorded.100101## Token Efficiency Guidance102103The finding table (category → location → severity → fix) is the artifact; focus on XSS sinks, CSRF, and cookie flags where browser breaches concentrate.