eslint-plugin-express-security 1.3.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -27
- package/package.json +27 -18
- package/src/index.d.ts +17 -40
- package/src/index.js +47 -62
- package/src/oxlint.d.ts +17 -20
- package/src/oxlint.js +0 -18
- package/src/rules/no-client-controlled-authorization/index.js +194 -0
- package/src/rules/no-cors-credentials-wildcard/index.js +0 -22
- package/src/rules/no-disabled-helmet-protections/index.js +125 -0
- package/src/rules/no-error-details-in-response/index.js +176 -0
- package/src/rules/no-exposed-debug-endpoints/index.js +27 -32
- package/src/rules/no-express-unsafe-regex-route/index.js +1 -32
- package/src/rules/no-graphql-introspection-production/index.js +0 -21
- package/src/rules/no-host-header-in-links/index.js +235 -0
- package/src/rules/no-idor-resource-access/index.js +126 -0
- package/src/rules/no-insecure-cookie-options/index.js +0 -12
- package/src/rules/no-missing-cors-check/index.js +4 -54
- package/src/rules/no-missing-csrf-protection/index.js +0 -25
- package/src/rules/no-missing-security-headers/index.js +50 -69
- package/src/rules/no-permissive-cors/index.js +0 -27
- package/src/rules/no-permissive-trust-proxy/index.js +106 -0
- package/src/rules/no-sensitive-data-in-query/index.js +182 -0
- package/src/rules/no-static-root-exposure/index.js +267 -0
- package/src/rules/no-unsafe-csp-directives/index.js +264 -0
- package/src/rules/no-user-controlled-redirect/index.js +0 -26
- package/src/rules/no-user-controlled-render-locals/index.js +268 -0
- package/src/rules/require-case-insensitive-path-guard/index.js +180 -0
- package/src/rules/require-csrf-protection/index.js +0 -42
- package/src/rules/require-express-body-parser-limits/index.js +0 -24
- package/src/rules/require-helmet/index.js +1 -25
- package/src/rules/require-query-type-guard/index.js +258 -0
- package/src/rules/require-rate-limiting/index.js +0 -13
- package/src/rules/require-route-authentication/index.js +225 -0
- package/src/rules/require-strict-transport-security/index.js +171 -0
- package/src/types/index.js +0 -5
- package/src/utils/index.js +81 -0
- package/AGENTS.md +0 -100
- package/CHANGELOG.md +0 -149
- package/src/rules/no-cors-credentials-wildcard/index.d.ts +0 -26
- package/src/rules/no-exposed-debug-endpoints/index.d.ts +0 -14
- package/src/rules/no-express-unsafe-regex-route/index.d.ts +0 -27
- package/src/rules/no-graphql-introspection-production/index.d.ts +0 -26
- package/src/rules/no-insecure-cookie-options/index.d.ts +0 -39
- package/src/rules/no-missing-cors-check/index.d.ts +0 -28
- package/src/rules/no-missing-csrf-protection/index.d.ts +0 -30
- package/src/rules/no-missing-security-headers/index.d.ts +0 -26
- package/src/rules/no-permissive-cors/index.d.ts +0 -28
- package/src/rules/no-user-controlled-redirect/index.d.ts +0 -44
- package/src/rules/require-csrf-protection/index.d.ts +0 -28
- package/src/rules/require-express-body-parser-limits/index.d.ts +0 -31
- package/src/rules/require-helmet/index.d.ts +0 -29
- package/src/rules/require-rate-limiting/index.d.ts +0 -31
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireStrictTransportSecurity = void 0;
|
|
4
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
+
const DEFAULT_MIN_MAX_AGE = 15552000;
|
|
6
|
+
const HSTS_NAMES = new Set(['hsts', 'strictTransportSecurity']);
|
|
7
|
+
function propertyKeyName(prop) {
|
|
8
|
+
if (prop.computed)
|
|
9
|
+
return null;
|
|
10
|
+
if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier)
|
|
11
|
+
return prop.key.name;
|
|
12
|
+
if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
|
|
13
|
+
typeof prop.key.value === 'string') {
|
|
14
|
+
return prop.key.value;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
function isHelmetHstsFactory(node) {
|
|
19
|
+
const callee = node.callee;
|
|
20
|
+
if (callee.type !== eslint_devkit_1.AST_NODE_TYPES.MemberExpression)
|
|
21
|
+
return false;
|
|
22
|
+
if (callee.property.type !== eslint_devkit_1.AST_NODE_TYPES.Identifier)
|
|
23
|
+
return false;
|
|
24
|
+
if (callee.computed)
|
|
25
|
+
return false;
|
|
26
|
+
if (callee.object.type !== eslint_devkit_1.AST_NODE_TYPES.Identifier)
|
|
27
|
+
return false;
|
|
28
|
+
return callee.object.name === 'helmet' && HSTS_NAMES.has(callee.property.name);
|
|
29
|
+
}
|
|
30
|
+
function isHelmetCall(node) {
|
|
31
|
+
return (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
32
|
+
node.callee.name === 'helmet');
|
|
33
|
+
}
|
|
34
|
+
exports.requireStrictTransportSecurity = (0, eslint_devkit_1.createRule)({
|
|
35
|
+
name: 'require-strict-transport-security',
|
|
36
|
+
meta: {
|
|
37
|
+
type: 'problem',
|
|
38
|
+
hasSuggestions: true,
|
|
39
|
+
docs: {
|
|
40
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-express-security/docs/rules/require-strict-transport-security.md',
|
|
41
|
+
description: 'Require a Strict-Transport-Security header with a long max-age and includeSubDomains',
|
|
42
|
+
cwe: 'CWE-319',
|
|
43
|
+
cvss: 7.4,
|
|
44
|
+
confidence: 'high',
|
|
45
|
+
},
|
|
46
|
+
messages: {
|
|
47
|
+
hstsDisabled: (0, eslint_devkit_1.formatLLMMessage)({
|
|
48
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
49
|
+
issueName: 'HSTS Disabled (CWE-319)',
|
|
50
|
+
cwe: 'CWE-319',
|
|
51
|
+
cvss: 7.4,
|
|
52
|
+
description: 'helmet({ {{option}}: false }) removes the Strict-Transport-Security header. Every first request of a session can then be downgraded to plaintext HTTP and stripped in transit.',
|
|
53
|
+
severity: 'HIGH',
|
|
54
|
+
fix: 'Remove the `{{option}}: false` entry, or configure it: { maxAge: 31536000, includeSubDomains: true, preload: true }.',
|
|
55
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/319.html',
|
|
56
|
+
}),
|
|
57
|
+
maxAgeTooShort: (0, eslint_devkit_1.formatLLMMessage)({
|
|
58
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
59
|
+
issueName: 'HSTS max-age Too Short (CWE-319)',
|
|
60
|
+
cwe: 'CWE-319',
|
|
61
|
+
cvss: 5.9,
|
|
62
|
+
description: 'Strict-Transport-Security max-age is {{maxAge}}s, below the {{minimum}}s floor. Once it lapses, the next visit is downgradeable again.',
|
|
63
|
+
severity: 'MEDIUM',
|
|
64
|
+
fix: 'Set maxAge to at least {{minimum}} seconds. Preload submission (hstspreload.org) requires 31536000 — one year — plus includeSubDomains and preload.',
|
|
65
|
+
documentationLink: 'https://hstspreload.org/',
|
|
66
|
+
}),
|
|
67
|
+
subdomainsExcluded: (0, eslint_devkit_1.formatLLMMessage)({
|
|
68
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
69
|
+
issueName: 'HSTS Excludes Subdomains (CWE-319)',
|
|
70
|
+
cwe: 'CWE-319',
|
|
71
|
+
cvss: 5.9,
|
|
72
|
+
description: 'includeSubDomains is off, so any subdomain still answers over plaintext HTTP — enough to plant a cookie the parent domain trusts.',
|
|
73
|
+
severity: 'MEDIUM',
|
|
74
|
+
fix: 'Set includeSubDomains: true once every subdomain serves HTTPS.',
|
|
75
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/319.html',
|
|
76
|
+
}),
|
|
77
|
+
raiseMaxAge: 'Raise maxAge to {{minimum}} seconds',
|
|
78
|
+
},
|
|
79
|
+
schema: [
|
|
80
|
+
{
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
minMaxAge: {
|
|
84
|
+
type: 'number',
|
|
85
|
+
minimum: 0,
|
|
86
|
+
description: 'Minimum accepted max-age in seconds',
|
|
87
|
+
},
|
|
88
|
+
requireSubDomains: {
|
|
89
|
+
type: 'boolean',
|
|
90
|
+
description: 'Require includeSubDomains',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
additionalProperties: false,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
defaultOptions: [{}],
|
|
98
|
+
create(context, [options]) {
|
|
99
|
+
const { minMaxAge, requireSubDomains } = options;
|
|
100
|
+
const minimum = minMaxAge ?? DEFAULT_MIN_MAX_AGE;
|
|
101
|
+
const wantSubDomains = requireSubDomains ?? true;
|
|
102
|
+
function checkHstsOptions(config) {
|
|
103
|
+
for (const prop of config.properties) {
|
|
104
|
+
if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
|
|
105
|
+
continue;
|
|
106
|
+
const name = propertyKeyName(prop);
|
|
107
|
+
if (!name)
|
|
108
|
+
continue;
|
|
109
|
+
if (name === 'maxAge' &&
|
|
110
|
+
prop.value.type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
|
|
111
|
+
typeof prop.value.value === 'number' &&
|
|
112
|
+
prop.value.value < minimum) {
|
|
113
|
+
const maxAgeNode = prop.value;
|
|
114
|
+
context.report({
|
|
115
|
+
node: prop,
|
|
116
|
+
messageId: 'maxAgeTooShort',
|
|
117
|
+
data: { maxAge: String(maxAgeNode.value), minimum: String(minimum) },
|
|
118
|
+
suggest: [
|
|
119
|
+
{
|
|
120
|
+
messageId: 'raiseMaxAge',
|
|
121
|
+
data: { minimum: String(minimum) },
|
|
122
|
+
fix: (fixer) => fixer.replaceText(maxAgeNode, String(minimum)),
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
});
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (wantSubDomains &&
|
|
129
|
+
name === 'includeSubDomains' &&
|
|
130
|
+
prop.value.type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
|
|
131
|
+
prop.value.value === false) {
|
|
132
|
+
context.report({ node: prop, messageId: 'subdomainsExcluded' });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function checkHstsValue(node, value, option) {
|
|
137
|
+
if (value.type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
|
|
138
|
+
value.value === false) {
|
|
139
|
+
context.report({ node, messageId: 'hstsDisabled', data: { option } });
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (value.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
|
|
143
|
+
checkHstsOptions(value);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
CallExpression(node) {
|
|
148
|
+
if (isHelmetHstsFactory(node)) {
|
|
149
|
+
const config = node.arguments[0];
|
|
150
|
+
if (config && config.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
|
|
151
|
+
checkHstsOptions(config);
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (!isHelmetCall(node))
|
|
156
|
+
return;
|
|
157
|
+
const config = node.arguments[0];
|
|
158
|
+
if (!config || config.type !== eslint_devkit_1.AST_NODE_TYPES.ObjectExpression)
|
|
159
|
+
return;
|
|
160
|
+
for (const prop of config.properties) {
|
|
161
|
+
if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
|
|
162
|
+
continue;
|
|
163
|
+
const name = propertyKeyName(prop);
|
|
164
|
+
if (!name || !HSTS_NAMES.has(name))
|
|
165
|
+
continue;
|
|
166
|
+
checkHstsValue(prop, prop.value, name);
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
});
|
package/src/types/index.js
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walk = walk;
|
|
4
|
+
exports.readsPrincipal = readsPrincipal;
|
|
5
|
+
exports.isClientRequestMember = isClientRequestMember;
|
|
6
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
7
|
+
const PRINCIPAL_PROPERTIES = new Set([
|
|
8
|
+
'user',
|
|
9
|
+
'auth',
|
|
10
|
+
'session',
|
|
11
|
+
'currentUser',
|
|
12
|
+
'principal',
|
|
13
|
+
'identity',
|
|
14
|
+
'userId',
|
|
15
|
+
'authInfo',
|
|
16
|
+
]);
|
|
17
|
+
const PRINCIPAL_RECEIVER = /^(req|request|res|response|ctx|locals)$/i;
|
|
18
|
+
const CLIENT_CONTAINERS = new Set(['body', 'query', 'params']);
|
|
19
|
+
const REQUEST_RECEIVER = /^(req|request)$/i;
|
|
20
|
+
function walk(node, visit) {
|
|
21
|
+
visit(node);
|
|
22
|
+
for (const key of Object.keys(node)) {
|
|
23
|
+
if (key === 'parent')
|
|
24
|
+
continue;
|
|
25
|
+
const value = node[key];
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
for (const item of value) {
|
|
28
|
+
if (item && typeof item === 'object' && 'type' in item) {
|
|
29
|
+
walk(item, visit);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (value && typeof value === 'object' && 'type' in value) {
|
|
35
|
+
walk(value, visit);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function readsPrincipal(node) {
|
|
40
|
+
let found = false;
|
|
41
|
+
walk(node, (child) => {
|
|
42
|
+
if (found)
|
|
43
|
+
return;
|
|
44
|
+
if (child.type !== eslint_devkit_1.AST_NODE_TYPES.MemberExpression)
|
|
45
|
+
return;
|
|
46
|
+
if (child.property.type !== eslint_devkit_1.AST_NODE_TYPES.Identifier)
|
|
47
|
+
return;
|
|
48
|
+
if (!PRINCIPAL_PROPERTIES.has(child.property.name))
|
|
49
|
+
return;
|
|
50
|
+
const { object } = child;
|
|
51
|
+
if (object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
52
|
+
found = PRINCIPAL_RECEIVER.test(object.name);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (object.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
|
|
56
|
+
object.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
57
|
+
found = PRINCIPAL_RECEIVER.test(object.property.name);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return found;
|
|
61
|
+
}
|
|
62
|
+
function isClientRequestMember(node) {
|
|
63
|
+
if (node.type !== eslint_devkit_1.AST_NODE_TYPES.MemberExpression)
|
|
64
|
+
return false;
|
|
65
|
+
const { object } = node;
|
|
66
|
+
if (object.type !== eslint_devkit_1.AST_NODE_TYPES.MemberExpression)
|
|
67
|
+
return false;
|
|
68
|
+
if (object.property.type !== eslint_devkit_1.AST_NODE_TYPES.Identifier)
|
|
69
|
+
return false;
|
|
70
|
+
if (!CLIENT_CONTAINERS.has(object.property.name))
|
|
71
|
+
return false;
|
|
72
|
+
const root = object.object;
|
|
73
|
+
if (root.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
74
|
+
return REQUEST_RECEIVER.test(root.name);
|
|
75
|
+
}
|
|
76
|
+
if (root.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
|
|
77
|
+
root.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
78
|
+
return REQUEST_RECEIVER.test(root.property.name);
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
package/AGENTS.md
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# AGENTS.md
|
|
2
|
-
|
|
3
|
-
> Context for AI coding agents working on eslint-plugin-express-security
|
|
4
|
-
|
|
5
|
-
## Setup Commands
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Install dependencies (from monorepo root)
|
|
9
|
-
npm install
|
|
10
|
-
|
|
11
|
-
# Build this package
|
|
12
|
-
nx build eslint-plugin-express-security
|
|
13
|
-
|
|
14
|
-
# Run tests
|
|
15
|
-
nx test eslint-plugin-express-security
|
|
16
|
-
|
|
17
|
-
# Run tests with coverage
|
|
18
|
-
nx test eslint-plugin-express-security --coverage
|
|
19
|
-
|
|
20
|
-
# Lint this package
|
|
21
|
-
nx lint eslint-plugin-express-security
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Code Style
|
|
25
|
-
|
|
26
|
-
- TypeScript strict mode with `@interlace/eslint-devkit` types
|
|
27
|
-
- Use `AST_NODE_TYPES` constants, never string literals for node types
|
|
28
|
-
- Use `formatLLMMessage()` for all rule error messages
|
|
29
|
-
- Include CWE, CVSS, OWASP in every security message
|
|
30
|
-
- Coverage-ignore comments (`c8 ignore`, `v8 ignore`, `istanbul ignore`) are banned — write a test for the branch (synthetic AST / mock context if parser-unreachable) or delete it if dead
|
|
31
|
-
- Single-pass AST traversal patterns (O(n) complexity)
|
|
32
|
-
- Detect Express objects through heuristics (variable naming, import analysis)
|
|
33
|
-
|
|
34
|
-
## Testing Instructions
|
|
35
|
-
|
|
36
|
-
- Tests use `@typescript-eslint/rule-tester` with Vitest
|
|
37
|
-
- Each rule has `index.ts` (implementation) and `*.test.ts` (tests) in same directory
|
|
38
|
-
- Run specific rule test: `nx test eslint-plugin-express-security --testPathPattern="require-helmet"`
|
|
39
|
-
- Coverage target: ≥90% lines, ≥95% functions
|
|
40
|
-
- All tests must pass before committing
|
|
41
|
-
|
|
42
|
-
## Project Structure
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
src/
|
|
46
|
-
├── index.ts # Plugin entry, exports rules and 4 configs
|
|
47
|
-
├── types/index.ts # Exported rule option types
|
|
48
|
-
└── rules/ # 9 rule directories
|
|
49
|
-
└── [rule-name]/
|
|
50
|
-
├── index.ts # Rule implementation
|
|
51
|
-
└── *.test.ts # Rule tests
|
|
52
|
-
docs/rules/ # Markdown documentation per rule
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Plugin Purpose
|
|
56
|
-
|
|
57
|
-
Security-focused ESLint plugin with **9 rules** for Express.js applications. Covers security headers (helmet), CORS misconfigurations, CSRF protection, cookie security, rate limiting, ReDoS prevention, and GraphQL security.
|
|
58
|
-
|
|
59
|
-
## Rule Categories
|
|
60
|
-
|
|
61
|
-
| Category | Rules | CWEs |
|
|
62
|
-
| ------------------- | ------------------------------------------------------------------------------------------------------------ | ------------- |
|
|
63
|
-
| Headers & CORS | `require-helmet`, `no-permissive-cors`, `no-cors-credentials-wildcard`, `require-express-body-parser-limits` | 693, 770, 942 |
|
|
64
|
-
| CSRF & Cookies | `require-csrf-protection`, `no-insecure-cookie-options` | 352, 614 |
|
|
65
|
-
| Rate Limiting & DoS | `require-rate-limiting`, `no-express-unsafe-regex-route` | 770, 1333 |
|
|
66
|
-
| GraphQL | `no-graphql-introspection-production` | 200 |
|
|
67
|
-
|
|
68
|
-
## Common Fix Patterns
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
// Helmet
|
|
72
|
-
// BAD: const app = express()
|
|
73
|
-
// GOOD: const app = express(); app.use(helmet())
|
|
74
|
-
|
|
75
|
-
// CORS
|
|
76
|
-
// BAD: app.use(cors({ origin: '*' }))
|
|
77
|
-
// GOOD: app.use(cors({ origin: ['https://your-app.com'] }))
|
|
78
|
-
|
|
79
|
-
// CSRF
|
|
80
|
-
// BAD: app.post('/api/transfer', handler)
|
|
81
|
-
// GOOD: app.use(csurf({ cookie: true })); app.post('/api/transfer', handler)
|
|
82
|
-
|
|
83
|
-
// Cookies
|
|
84
|
-
// BAD: res.cookie('session', token)
|
|
85
|
-
// GOOD: res.cookie('session', token, { httpOnly: true, secure: true, sameSite: 'strict' })
|
|
86
|
-
|
|
87
|
-
// Rate limiting
|
|
88
|
-
// BAD: app.post('/api/login', handler)
|
|
89
|
-
// GOOD: app.use('/api/', rateLimit({ windowMs: 15*60*1000, max: 100 }))
|
|
90
|
-
|
|
91
|
-
// Body parser limits
|
|
92
|
-
// BAD: app.use(express.json())
|
|
93
|
-
// GOOD: app.use(express.json({ limit: '100kb' }))
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Security Considerations
|
|
97
|
-
|
|
98
|
-
- All rules map to OWASP Top 10 2021: A01, A03, A05, A07
|
|
99
|
-
- CWE coverage: 200, 352, 614, 693, 770, 942, 1333
|
|
100
|
-
- Middleware-aware detection: helmet, cors, csurf, express-rate-limit
|
package/CHANGELOG.md
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
## [1.2.3] - 2026-02-08
|
|
2
|
-
|
|
3
|
-
## 1.3.4
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [#269](https://github.com/ofri-peretz/eslint/pull/269) [`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - docs: dual-logo README header (Interlace mark + ESLint mark side by side) and closing Interlace footer — refreshes the README rendered on npmjs.com. No runtime changes.
|
|
8
|
-
|
|
9
|
-
- Updated dependencies [[`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad)]:
|
|
10
|
-
- @interlace/eslint-devkit@1.4.2
|
|
11
|
-
|
|
12
|
-
## 1.3.3
|
|
13
|
-
|
|
14
|
-
### Patch Changes
|
|
15
|
-
|
|
16
|
-
- [#252](https://github.com/ofri-peretz/eslint/pull/252) [`d67e395`](https://github.com/ofri-peretz/eslint/commit/d67e3953c2748ad36e6aebe0f24b1d04e518b4d0) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Fix Codecov badge showing "unknown" — switch from flag to component URL format
|
|
17
|
-
|
|
18
|
-
## 1.3.2
|
|
19
|
-
|
|
20
|
-
### Patch Changes
|
|
21
|
-
|
|
22
|
-
- [#225](https://github.com/ofri-peretz/eslint/pull/225) [`34ff5a8`](https://github.com/ofri-peretz/eslint/commit/34ff5a8e6f5126c5d1c0a524759e0af2b5476b46) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - CI-only: pin all coverage thresholds at 100% (integration target, merges last).
|
|
23
|
-
|
|
24
|
-
## 1.3.1
|
|
25
|
-
|
|
26
|
-
### Patch Changes
|
|
27
|
-
|
|
28
|
-
- [#213](https://github.com/ofri-peretz/eslint/pull/213) [`391dbe6`](https://github.com/ofri-peretz/eslint/commit/391dbe6b39f78d549379218567cb959649f8c614) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Align every security rule's `meta.docs.cvss` to the CVSS its finding actually
|
|
29
|
-
emits. The emitted machine-readable message sources its `CVSS:x` from
|
|
30
|
-
`CWE_MAPPING` via `formatLLMMessage` → `enrichFromCWE`, but the static
|
|
31
|
-
`meta.docs.cvss` documentation field had drifted on 45 rules across these 7
|
|
32
|
-
plugins — e.g. `no-hardcoded-credentials` documented `9.5` while emitting
|
|
33
|
-
`CVSS:9.8` (the value the published article and SARIF/LLM consumers already
|
|
34
|
-
read).
|
|
35
|
-
|
|
36
|
-
This corrects the **documentation metadata only** — no emitted finding changes.
|
|
37
|
-
Locked by `security-cvss-docs-consistency.lock.test.ts` (cross-plugin: every
|
|
38
|
-
security rule's `meta.docs.cvss` must equal the CVSS it emits), the
|
|
39
|
-
`no-hardcoded-credentials` rule lock (real ESLint `Linter` emission), and a
|
|
40
|
-
devkit `enrichFromCWE` contract test pinning `CWE-798 → 9.8`.
|
|
41
|
-
|
|
42
|
-
Follow-up (not in scope): 50 security rules document a CVSS that never appears
|
|
43
|
-
in any emitted message (their messages carry no CWE), and several rules emit the
|
|
44
|
-
generic CWE score where a rule-specific score may be warranted — both change
|
|
45
|
-
emitted output and are separate decisions.
|
|
46
|
-
|
|
47
|
-
## 1.3.0
|
|
48
|
-
|
|
49
|
-
### Minor Changes
|
|
50
|
-
|
|
51
|
-
- [#169](https://github.com/ofri-peretz/eslint/pull/169) [`ae39ec5`](https://github.com/ofri-peretz/eslint/commit/ae39ec52bf619351e6217a823014fc05bb97d618) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - feat: add `no-user-controlled-redirect` rule — structural CWE-601 open redirect detection
|
|
52
|
-
|
|
53
|
-
Fires on `res.redirect(req.query.*)`, `res.redirect(req.body.*)`, and `res.redirect(req.params.*)` — an AST-structural check that passes the naming-heuristic litmus test (rename `res`/`req` to any identifier and the rule still fires, because detection is on the member-access chain, not on variable names). Severity: `error` in flagship config.
|
|
54
|
-
|
|
55
|
-
### Patch Changes
|
|
56
|
-
|
|
57
|
-
- [#143](https://github.com/ofri-peretz/eslint/pull/143) [`213cde1`](https://github.com/ofri-peretz/eslint/commit/213cde190ff2aea49ca7c1b533170940f879d9b4) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - fix(no-missing-null-checks): eliminate 53 false positives via three new narrowing patterns
|
|
58
|
-
|
|
59
|
-
Rules that were recognized as null guards are now correctly identified as safe:
|
|
60
|
-
1. **Truthy if guard** — `if (obj) { obj.prop }` — direct truthy check proves non-null. Also covers chains: `if (response)` protects `response.data.items`.
|
|
61
|
-
2. **Short-circuit AND** — `obj && obj.prop` — right side of `&&` only runs when left is truthy.
|
|
62
|
-
3. **Ternary consequent** — `obj ? obj.prop : fallback` — truthy test guards the consequent.
|
|
63
|
-
|
|
64
|
-
Also: bumped `beforeAll` timeout to 30 seconds in 7 compatibility test files (`__compatibility__/*.spec.ts`). Native-addon packages routinely exceed the previous 10-second default on a cold ESM load.
|
|
65
|
-
|
|
66
|
-
- Updated dependencies [[`736a5fe`](https://github.com/ofri-peretz/eslint/commit/736a5fed47e673f6157ea900b29fe2a54e4bc7df)]:
|
|
67
|
-
- @interlace/eslint-devkit@1.4.1
|
|
68
|
-
|
|
69
|
-
### Bug Fixes
|
|
70
|
-
|
|
71
|
-
- align codecov component IDs with full package names ([2831b968](https://github.com/ofri-peretz/eslint/commit/2831b968))
|
|
72
|
-
|
|
73
|
-
### Documentation
|
|
74
|
-
|
|
75
|
-
- fix changelog header format across all packages ([c3a15082](https://github.com/ofri-peretz/eslint/commit/c3a15082))
|
|
76
|
-
|
|
77
|
-
### ❤️ Thank You
|
|
78
|
-
|
|
79
|
-
- Ofri Peretz
|
|
80
|
-
|
|
81
|
-
## [1.2.2] - 2026-02-06
|
|
82
|
-
|
|
83
|
-
### Bug Fixes
|
|
84
|
-
|
|
85
|
-
- align codecov component names and update docs components ([0a59a86c](https://github.com/ofri-peretz/eslint/commit/0a59a86c))
|
|
86
|
-
|
|
87
|
-
### ❤️ Thank You
|
|
88
|
-
|
|
89
|
-
- Ofri Peretz
|
|
90
|
-
|
|
91
|
-
## [1.2.1] - 2026-02-02
|
|
92
|
-
|
|
93
|
-
This was a version bump only for eslint-plugin-express-security to align it with other projects, there were no code changes.
|
|
94
|
-
|
|
95
|
-
# Changelog
|
|
96
|
-
|
|
97
|
-
All notable changes to `eslint-plugin-express-security` will be documented in this file.
|
|
98
|
-
|
|
99
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
100
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
101
|
-
|
|
102
|
-
### Documentation
|
|
103
|
-
|
|
104
|
-
- 📘 Launched new documentation site: [eslint.interlace.tools](https://eslint.interlace.tools/)
|
|
105
|
-
|
|
106
|
-
## [1.0.0] - 2025-12-29
|
|
107
|
-
|
|
108
|
-
### Added
|
|
109
|
-
|
|
110
|
-
#### Headers & CORS Rules (4)
|
|
111
|
-
|
|
112
|
-
- `require-helmet` - Require helmet middleware for security headers (CWE-693)
|
|
113
|
-
- `no-permissive-cors` - Detect wildcard CORS origins (CWE-942)
|
|
114
|
-
- `no-cors-credentials-wildcard` - Block credentials: true with wildcard origin (CWE-942)
|
|
115
|
-
- `require-express-body-parser-limits` - Require body parser size limits (CWE-770)
|
|
116
|
-
|
|
117
|
-
#### CSRF & Cookies Rules (2)
|
|
118
|
-
|
|
119
|
-
- `require-csrf-protection` - Require CSRF middleware for state-changing routes (CWE-352)
|
|
120
|
-
- `no-insecure-cookie-options` - Detect missing Secure/HttpOnly cookie attributes (CWE-614)
|
|
121
|
-
|
|
122
|
-
#### Rate Limiting & DoS Rules (2)
|
|
123
|
-
|
|
124
|
-
- `require-rate-limiting` - Require rate limiting middleware (CWE-770)
|
|
125
|
-
- `no-express-unsafe-regex-route` - Detect ReDoS-vulnerable regex patterns (CWE-1333)
|
|
126
|
-
|
|
127
|
-
#### GraphQL Rules (1)
|
|
128
|
-
|
|
129
|
-
- `no-graphql-introspection-production` - Disable GraphQL introspection in production (CWE-200)
|
|
130
|
-
|
|
131
|
-
#### Presets (4)
|
|
132
|
-
|
|
133
|
-
- `recommended` - Balanced security defaults
|
|
134
|
-
- `strict` - All 9 rules as errors
|
|
135
|
-
- `api` - HTTP/API security rules only
|
|
136
|
-
- `graphql` - GraphQL-specific rules only
|
|
137
|
-
|
|
138
|
-
#### Features
|
|
139
|
-
|
|
140
|
-
- LLM-optimized error messages with CWE references
|
|
141
|
-
- OWASP Top 10 2021 alignment (A01, A03, A05, A07)
|
|
142
|
-
- Middleware-aware detection (helmet, cors, csurf, express-rate-limit)
|
|
143
|
-
- TypeScript support with exported option types
|
|
144
|
-
- Comprehensive test coverage (132 tests, 93.15% line coverage)
|
|
145
|
-
|
|
146
|
-
### Security
|
|
147
|
-
|
|
148
|
-
- Covers 6 CWEs: 200, 352, 614, 693, 770, 942, 1333
|
|
149
|
-
- Maps to OWASP Top 10 2021: A01, A03, A05, A07
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-cors-credentials-wildcard
|
|
8
|
-
* Prevents dangerous CORS configurations with credentials: true and wildcard origin
|
|
9
|
-
*
|
|
10
|
-
* CVE-2024-25124 - CVSS 9.1 Critical
|
|
11
|
-
* CWE-942: Permissive Cross-domain Policy with Untrusted Domains
|
|
12
|
-
*
|
|
13
|
-
* @see https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-25124
|
|
14
|
-
* @see https://cwe.mitre.org/data/definitions/942.html
|
|
15
|
-
*/
|
|
16
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
17
|
-
type MessageIds = 'credentialsWildcard' | 'useExplicitOrigins';
|
|
18
|
-
export interface Options {
|
|
19
|
-
/** Allow in test files. Default: false */
|
|
20
|
-
allowInTests?: boolean;
|
|
21
|
-
}
|
|
22
|
-
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noCorsCredentialsWildcard: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
-
name: string;
|
|
25
|
-
};
|
|
26
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
export interface Options {
|
|
7
|
-
endpoints?: string[];
|
|
8
|
-
ignoreFiles?: string[];
|
|
9
|
-
}
|
|
10
|
-
type RuleOptions = [Options?];
|
|
11
|
-
export declare const noExposedDebugEndpoints: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
12
|
-
name: string;
|
|
13
|
-
};
|
|
14
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-express-unsafe-regex-route
|
|
8
|
-
* Detects ReDoS-vulnerable regular expressions in Express.js route patterns
|
|
9
|
-
* CWE-1333: Inefficient Regular Expression Complexity
|
|
10
|
-
*
|
|
11
|
-
* Vulnerable patterns can cause catastrophic backtracking,
|
|
12
|
-
* leading to denial of service via CPU exhaustion.
|
|
13
|
-
*
|
|
14
|
-
* @see https://cwe.mitre.org/data/definitions/1333.html
|
|
15
|
-
* @see https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
|
|
16
|
-
*/
|
|
17
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
18
|
-
type MessageIds = 'unsafeRegexRoute' | 'unsafeParamPattern' | 'refactorRoute';
|
|
19
|
-
export interface Options {
|
|
20
|
-
/** Allow in test files. Default: false */
|
|
21
|
-
allowInTests?: boolean;
|
|
22
|
-
}
|
|
23
|
-
type RuleOptions = [Options?];
|
|
24
|
-
export declare const noExpressUnsafeRegexRoute: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
25
|
-
name: string;
|
|
26
|
-
};
|
|
27
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-graphql-introspection-production
|
|
8
|
-
* Detects GraphQL servers with introspection enabled in production
|
|
9
|
-
* CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
|
|
10
|
-
*
|
|
11
|
-
* @see https://cwe.mitre.org/data/definitions/200.html
|
|
12
|
-
* @see https://cheatsheetseries.owasp.org/cheatsheets/GraphQL_Cheat_Sheet.html
|
|
13
|
-
*/
|
|
14
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
-
type MessageIds = 'graphqlIntrospection' | 'disableIntrospection';
|
|
16
|
-
export interface Options {
|
|
17
|
-
/** Allow introspection in test files. Default: true */
|
|
18
|
-
allowInTests?: boolean;
|
|
19
|
-
/** Allow introspection in development. Default: true */
|
|
20
|
-
allowInDevelopment?: boolean;
|
|
21
|
-
}
|
|
22
|
-
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noGraphqlIntrospectionProduction: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
-
name: string;
|
|
25
|
-
};
|
|
26
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-insecure-cookie-options
|
|
8
|
-
* Detects cookies set without secure flags (httpOnly, secure, sameSite)
|
|
9
|
-
* CWE-614: Sensitive Cookie in HTTPS Session Without 'Secure' Attribute
|
|
10
|
-
*
|
|
11
|
-
* @see https://cwe.mitre.org/data/definitions/614.html
|
|
12
|
-
* @see https://owasp.org/www-community/controls/SecureCookieAttribute
|
|
13
|
-
*/
|
|
14
|
-
import type { TSESLint, TSESTree } from '@interlace/eslint-devkit';
|
|
15
|
-
type MessageIds = 'insecureCookie' | 'addSecureFlags';
|
|
16
|
-
export interface Options {
|
|
17
|
-
/** Allow insecure cookies in test files. Default: false */
|
|
18
|
-
allowInTests?: boolean;
|
|
19
|
-
/** Require httpOnly flag. Default: true */
|
|
20
|
-
requireHttpOnly?: boolean;
|
|
21
|
-
/** Require secure flag. Default: true */
|
|
22
|
-
requireSecure?: boolean;
|
|
23
|
-
/** Require sameSite flag. Default: true */
|
|
24
|
-
requireSameSite?: boolean;
|
|
25
|
-
/** Acceptable sameSite values. Default: ['strict', 'lax'] */
|
|
26
|
-
acceptableSameSiteValues?: string[];
|
|
27
|
-
}
|
|
28
|
-
type RuleOptions = [Options?];
|
|
29
|
-
/**
|
|
30
|
-
* Check cookie options object for security flags
|
|
31
|
-
*/
|
|
32
|
-
export declare function checkCookieOptions(node: TSESTree.ObjectExpression, sourceCode: TSESLint.SourceCode, options: Options): {
|
|
33
|
-
issues: string[];
|
|
34
|
-
hasSuggestions: boolean;
|
|
35
|
-
};
|
|
36
|
-
export declare const noInsecureCookieOptions: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
37
|
-
name: string;
|
|
38
|
-
};
|
|
39
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-missing-cors-check
|
|
8
|
-
* Detects missing CORS validation (wildcard CORS, missing origin check)
|
|
9
|
-
* CWE-346: Origin Validation Error
|
|
10
|
-
*
|
|
11
|
-
* @see https://cwe.mitre.org/data/definitions/346.html
|
|
12
|
-
* @see https://owasp.org/www-community/attacks/CORS_Misconfiguration
|
|
13
|
-
*/
|
|
14
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
-
type MessageIds = 'missingCorsCheck' | 'useOriginValidation' | 'useCorsMiddleware';
|
|
16
|
-
export interface Options {
|
|
17
|
-
/** Allow missing CORS checks in test files. Default: false */
|
|
18
|
-
allowInTests?: boolean;
|
|
19
|
-
/** Trusted CORS libraries. Default: ['cors', '@koa/cors', 'express-cors'] */
|
|
20
|
-
trustedLibraries?: string[];
|
|
21
|
-
/** Additional safe patterns to ignore. Default: [] */
|
|
22
|
-
ignorePatterns?: string[];
|
|
23
|
-
}
|
|
24
|
-
type RuleOptions = [Options?];
|
|
25
|
-
export declare const noMissingCorsCheck: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
26
|
-
name: string;
|
|
27
|
-
};
|
|
28
|
-
export {};
|