no-missing-csrf-protection
Detects missing CSRF token validation in POST/PUT/DELETE requests
Deprecated. Use
require-csrf-protectioninstead.
Status: 🚫 Deprecated — replaced by require-csrf-protection
CWE: CWE-352
Why this rule was replaced
The replacement inverts the model from "flag suspicious absence" to
"require the protection to be present", which is both easier to reason
about and stricter: require-csrf-protection fails the app that never
mounts CSRF middleware at all, the case this rule could miss.
The rule id still resolves so existing configs keep working, but it receives no new detection work. Reports carry the same CWE metadata as before.
Migration
// eslint.config.js
{
rules: {
// before
'express-security/no-missing-csrf-protection': 'error',
// after
'express-security/require-csrf-protection': 'error',
},
}No source changes are needed — only the rule id in your config.
Options
| Option | Type | Default | Description |
|---|---|---|---|
allowInTests | boolean | false | Allow missing CSRF protection in test files |
csrfMiddlewarePatterns | string[] | [] | CSRF middleware patterns to recognize |
protectedMethods | string[] | [] | HTTP methods that require CSRF protection |
ignorePatterns | string[] | [] | Additional safe patterns to ignore |
Related Rules
require-csrf-protection— the maintained replacement
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.