CSRF protection imported is actually applied
Why it matters
Installing csurf or csrf-csrf and never calling app.use(csrfProtection) or the library's equivalent wrapper leaves every state-mutating route open to cross-site request forgery. OWASP A01 (Broken Access Control) and CWE-352 describe the attack: a malicious third-party page can POST to your /api/transfer endpoint using a victim's session cookie, and your server will accept it as a legitimate request. The library is evidence that the developer knew CSRF was a risk — the installation without application is the exact theater pattern.
Severity rationale
High because every state-mutating endpoint is CSRF-vulnerable, enabling unauthorized actions on behalf of authenticated users from attacker-controlled pages.
Remediation
Apply the CSRF middleware to all state-mutating routes. For Express with csurf:
import csurf from 'csurf'
const csrfProtection = csurf({ cookie: true })
// Apply to individual routes
app.post('/api/transfer', csrfProtection, handler)
// Or globally, then exclude safe methods
app.use(csrfProtection)
For Next.js App Router, use csrf-csrf or @edge-csrf/nextjs and wrap your API handlers. Verify the token is read from a header or double-submit cookie, not just from req.body. The CSRF token must be included in every form or mutation client request.
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 Security Implementation Validation Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-352 — Cross-Site Request Forgery (CSRF)
- owasp:2021 · A01 — Broken Access Control
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-slop-security-theater·automated