Logout clears client+server session data within 1s
Why it matters
A logout that only clears client-side state — localStorage, React context, or a cookie set to Max-Age=0 without server-side destruction — leaves the server-side session record valid. Any actor who captured the session token (via network sniff, log file, browser extension, or XSS) can replay it after the user 'logged out' and regain full access. CWE-613 defines this as insufficient session expiration. OWASP A07 (Identification and Authentication Failures) and PCI-DSS Req 8.2.6 both require server-side invalidation. The consequence in a financial context is that post-logout token replay enables transfers, account changes, and data exfiltration on an account the user believed was secured.
Severity rationale
High because a server-side session that survives client logout allows token replay attacks — any captured session token remains valid indefinitely, granting full financial account access after the user has explicitly signed out.
Remediation
Implement all four cleanup steps in src/app/api/auth/logout/route.ts — server destruction, token invalidation, cookie clearing, and client state reset must complete atomically:
export async function POST(req: Request) {
const session = await getSession(req);
if (session) {
await sessionStore.destroy(session.id); // 1. server session gone
await tokenBlacklist.add(session.token); // 2. token invalidated
}
const response = new Response(JSON.stringify({ ok: true }), { status: 200 });
// 3. clear cookies server-side
response.headers.set('Set-Cookie',
'sessionId=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0');
response.headers.set('Set-Cookie',
'authToken=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0');
return response;
}
Client-side cleanup (step 4 — localStorage.clear(), sessionStorage.clear()) must run in the calling component after the server response confirms destruction, not in lieu of it.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Session Security Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-613 — Insufficient Session Expiration
- owasp:2021 · A07
- nist:rev5 · AC-12 — Session Termination
- pci-dss:4.0 · Req 8.2.6 — Inactive account management / session cleanup
Taxons
History
- 2026-04-18·v1.0.0·Initial import from finserv-session-security·automated