```html
React Web App · Security Audit Framework
Passwordless · MFA · Session Management
Reduce password-based attack vectors. Support FIDO2/WebAuthn for passkey login.
TOTP, SMS OTP, or hardware keys. Enforce MFA for admin/editor roles at minimum.
Access token TTL ≤ 15 min. Refresh token rotation with reuse detection enabled.
httpOnly + Secure + SameSite=Strict cookies prevent XSS token theft.
Rate limiting with exponential backoff. Lock after N failed attempts. CAPTCHA for suspicious patterns.
Never trust cached auth state alone. Re-validate token signature, expiry, and issuer server-side.
RBAC vs ABAC · Client + Server Enforcement
RBAC: role-based (admin/editor/viewer). ABAC: attribute-based (department, clearance, time). Document role matrix explicitly.
Client-side route guards are UX convenience only. All resource access must be validated in the API layer.
Wrap sensitive routes with permission checks. Redirect unauthorized users to 403 page, not silently to login.
Audit permission assignments regularly. Avoid wildcard grants. Scope API tokens to specific operations.
Never trust user-supplied resource IDs alone. Always verify the requesting user owns or has access to the resource.
Use usePermission() hooks or permission context. Don't just hide — ensure server blocks unauthorized actions too.
Include horizontal and vertical privilege escalation in test cases. Automated tests for permission boundaries.
API Tokens · Service Accounts · Expiry Management
Maintain a living registry of all NHIs. Include owner, purpose, scope, creation date, and expiry.
Max token lifetime: 90 days for service tokens, 1 year for CI/CD tokens with rotation policy defined.
Never commit secrets to git. Use secret scanning tools (GitGuardian, gitleaks) in CI pipeline.
Each service should have its own identity with scoped permissions. Shared credentials are a security anti-pattern.
Use scheduled jobs or secrets manager rotation policies. Alert on-call team before production tokens expire.
Define incident runbook for token compromise. Remove orphaned service accounts within 30 days of decommission.
Identity Telemetry · Access Attempt Logs · Audit Trail
Include timestamp, user ID, IP address, device fingerprint, and result. Store in tamper-evident log store.
403 responses should generate structured audit log entries with full context. Never silently fail authorization.
Standard fields: userId, sessionId, requestId, action, resource, result, ip, userAgent.
Alert on: 5+ failed logins/5min, access from new geolocation, off-hours admin actions, impossible travel detection.
Logs should be write-once or append-only. Restrict log access to security team. Align with compliance requirements (SOC2, GDPR).
Use log scrubbing middleware. Mask or redact fields: password, token, ssn, cardNumber. Audit logging libraries for leaks.
Generate UUID at React app level, pass via X-Correlation-ID header, propagate through all microservices for full trace.
Broken Auth · Broken Access Control · Logging Failures
OWASP #1 risk. All routes must require explicit permission grants. Fail securely — deny unless explicitly permitted.
Restrict access to /.env, /api/debug, /actuator. Remove debug endpoints before production deploy.
Check against OWASP Application Security Verification Standard. Key areas: V2 (Auth), V3 (Session), V4 (Access Control).
Integrate with threat intelligence feeds. Block known compromised credential pairs via Have I Been Pwned API on registration.
OWASP A09:2021. Verify logging covers: auth events, high-value transactions, input validation failures, and system errors.
Run tabletop exercises. Can you answer: who accessed what, when, from where, and what did they change? Within 1 hour of incident.
Asymmetric signing (RS256) allows public key verification. Rotate signing keys regularly. Validate alg header — reject none algorithm.