Subscription status is verified server-side
Why it matters
JWTs and session cookies have fixed expiry windows. If a subscription lapses between token issuances, the user retains premium access until their next login — potentially days or weeks. CWE-613 (Insufficient Session Expiration) and CWE-602 (Client-Side Enforcement of Server-Side Security) both apply. NIST AC-3 (Access Enforcement) requires that access decisions happen at the enforcement point, not at authentication time. Reading subscription status from the database on each request is the only way to ensure that a cancellation or failed payment takes effect immediately.
Severity rationale
High because stale JWT claims allow canceled subscribers to retain paid access for the full token lifetime without any server-side re-verification.
Remediation
Read subscription status from the database on every protected request, not from the session token. For performance, a short-lived server-side cache (60 seconds) is acceptable; caching in the JWT is not.
// middleware.ts or a shared access-check utility
const user = await db.user.findUnique({
where: { id: session.userId },
select: { subscription_status: true, plan: true }
})
if (!user || !['active', 'trialing'].includes(user.subscription_status)) {
return redirect('/billing/upgrade')
}
Also ensure the set of statuses that grant access (active, trialing, etc.) is identical across all enforcement points — middleware, API routes, Server Actions, and UI components. Inconsistent status lists are a FAIL even if each individual check is server-side.
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 Billing & Payments Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-602 — Client-Side Enforcement of Server-Side Security
- owasp:2021 · A01 — Broken Access Control
- cwe · CWE-613 — Insufficient Session Expiration
- nist:rev5 · AC-3 — Access Enforcement
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-billing·automated