eslint-plugin-express-security 1.3.4 → 1.4.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/CHANGELOG.md +43 -0
- package/README.md +39 -27
- package/package.json +24 -12
- package/src/index.js +26 -1
- package/src/rules/no-error-details-in-response/index.d.ts +57 -0
- package/src/rules/no-error-details-in-response/index.js +202 -0
- package/src/rules/no-exposed-debug-endpoints/index.js +36 -22
- package/src/rules/no-host-header-in-links/index.d.ts +56 -0
- package/src/rules/no-host-header-in-links/index.js +266 -0
- package/src/rules/no-missing-security-headers/index.js +64 -43
- package/src/rules/no-sensitive-data-in-query/index.d.ts +51 -0
- package/src/rules/no-sensitive-data-in-query/index.js +207 -0
- package/src/rules/no-static-root-exposure/index.d.ts +45 -0
- package/src/rules/no-static-root-exposure/index.js +288 -0
- package/src/rules/no-user-controlled-render-locals/index.d.ts +49 -0
- package/src/rules/no-user-controlled-render-locals/index.js +313 -0
- package/src/rules/require-case-insensitive-path-guard/index.d.ts +59 -0
- package/src/rules/require-case-insensitive-path-guard/index.js +201 -0
- package/src/rules/require-query-type-guard/index.d.ts +54 -0
- package/src/rules/require-query-type-guard/index.js +278 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
## [1.2.3] - 2026-02-08
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#292](https://github.com/ofri-peretz/eslint/pull/292) [`5664efd`](https://github.com/ofri-peretz/eslint/commit/5664efdc4df72a8621253b2d500c82b09944fd49) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - **`express-security/no-exposed-debug-endpoints` — only route registrations count.** The rule had a second listener that reported _any_ bare string literal equal to a debug path (`/admin`, `/health`, `/debug`, …) anywhere in a file. A redirect-URL constant tripped it while authoring benchmark corpus fixtures — `const ADMIN_PATH = '/admin'`, `res.redirect('/admin')` and `if (req.path === '/health')` were all CWE-489 "Exposed Debug Endpoint" findings, none of which registers an endpoint. That listener is gone: a literal is reported only as the path argument of an express route registration.
|
|
8
|
+
|
|
9
|
+
The registration check also now covers every express routing method (`put`, `patch`, `delete`, `head`, `options`, `all`) rather than just `get` / `post` / `use`, plus the chained route builder (`app.route('/admin').delete(handler)`), so `app.delete('/admin/users/:id', handler)` is caught where it previously was not. Conversely, `app.get(name)` with a single argument is an application-setting lookup rather than a route registration and is no longer reported.
|
|
10
|
+
|
|
11
|
+
- [#293](https://github.com/ofri-peretz/eslint/pull/293) [`d6e2b3c`](https://github.com/ofri-peretz/eslint/commit/d6e2b3ccdcaed3797cffc49772c1b7fa56e78a82) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Seven new rules closing benchmark-corpus coverage gaps (A-lite research wave):
|
|
12
|
+
|
|
13
|
+
- `no-host-header-in-links` (CWE-640) — Host-header poisoning in password-reset/email link construction
|
|
14
|
+
- `no-error-details-in-response` (CWE-209) — stack traces / raw error objects sent to clients
|
|
15
|
+
- `no-sensitive-data-in-query` (CWE-598) — passwords/tokens read from GET query strings
|
|
16
|
+
- `no-user-controlled-render-locals` (CWE-73) — `res.render(view, req.body)` template object injection
|
|
17
|
+
- `no-static-root-exposure` (CWE-548) — `express.static(__dirname)` / `serve-index` directory exposure
|
|
18
|
+
- `require-case-insensitive-path-guard` (CWE-178) — case-sensitive path guards bypassed by `/ADMIN`
|
|
19
|
+
- `require-query-type-guard` (CWE-843) — string methods on `req.query` members without type guards
|
|
20
|
+
|
|
21
|
+
In the recommended preset four ship as `error` (`no-host-header-in-links`,
|
|
22
|
+
`no-error-details-in-response`, `no-user-controlled-render-locals`,
|
|
23
|
+
`no-static-root-exposure`) and three as `warn` — the two `require-*` guard
|
|
24
|
+
heuristics plus `no-sensitive-data-in-query`, which matches on parameter names
|
|
25
|
+
and so never gets enforcement severity.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#298](https://github.com/ofri-peretz/eslint/pull/298) [`a53887f`](https://github.com/ofri-peretz/eslint/commit/a53887fdcb4ba5fad0d9f06a19a295d125c7e144) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - **`express-security/no-missing-security-headers` — `.set()` on a non-response receiver is not a header call.** The rule matched `setHeader` / `header` / `set` on the method name alone, so `url.searchParams.set('page', '2')` and `app.set('view engine', 'ejs')` were reported as CVSS 7.5 missing-security-header findings — a false positive on two of the most common calls in an Express codebase. The receiver must now be an HTTP response (`res` / `resp` / `response` / `reply`, including `ctx.res.set(…)` and `this.response.header(…)`). The same predicate gates header _collection_, so a `Content-Security-Policy` string passed to an unrelated `.set()` no longer satisfies the requirement for a real response in the same scope.
|
|
30
|
+
|
|
31
|
+
- [#294](https://github.com/ofri-peretz/eslint/pull/294) [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Rewrite `description` and `keywords` on every published package for npm search discovery. npm ranks on name, description, and keywords, and the registry only picks up these fields at publish — so this is metadata-only and takes effect for each package on its next release.
|
|
32
|
+
|
|
33
|
+
**Descriptions now lead with the search phrase.** Every one starts `ESLint plugin for <the thing you'd search>` instead of a brand-first or category-first framing, and names the concrete vulnerabilities the plugin actually detects. Three were corrected while doing so:
|
|
34
|
+
|
|
35
|
+
- `eslint-plugin-import-next` claimed "100x faster no-cycle detection". No 100x measurement exists: `CLAIMS.md` records **3.1x end-to-end** (8x in pure rule execution) on a 5,483-file React codebase, and the highest number in any benchmark result is 54.9x on the synthetic corpus. The description now states the real-codebase figure.
|
|
36
|
+
- `eslint-plugin-secure-coding` claimed SQL injection, XSS and CSRF coverage — none of which are its rules. It now names what it does detect: LDAP, XPath, XXE, GraphQL and template injection, unsafe deserialization, ReDoS, missing authentication, and PII in logs.
|
|
37
|
+
- `eslint-plugin-secure-coding` ("89 rules") and `eslint-plugin-react-a11y` ("37 rules") hard-coded rule counts that had drifted from reality. Counts are generated into `interlace-numbers.json`; hand-typed copies are removed rather than corrected.
|
|
38
|
+
|
|
39
|
+
**Keywords now match the vocabulary of the plugins that rank.** `eslint-plugin-security`, `eslint-plugin-jsx-a11y`, `eslint-plugin-n` and `eslint-plugin-import` all carry the `eslint` / `eslintplugin` / `eslint-plugin` trio — six of our packages were missing `eslintplugin`, and every one now carries all three plus `static-analysis`, `linting` and `code-quality`. Security plugins add `sast`, `appsec` and `vulnerability`; `node-security` and `secure-coding` also carry `nodesecurity`, the exact keyword `eslint-plugin-security` ranks on. Each plugin gained the CWE identifiers and attack names for what it detects (`cwe-78` command injection, `cwe-22` path traversal, `cwe-89` SQL injection, `cwe-79` XSS, `cwe-347` JWT algorithm confusion, `cwe-352` CSRF, `cwe-943` NoSQL injection), and `node-security` gained the crypto vocabulary it had been missing entirely despite absorbing the crypto rule set (`crypto`, `cryptography`, `weak-hash`, `md5`, `sha1`, `timing-attack`).
|
|
40
|
+
|
|
41
|
+
No rule behavior, exports, or configuration changes.
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [[`e1cdf83`](https://github.com/ofri-peretz/eslint/commit/e1cdf83e3db761907f0ab06f7fc6c1f1da7513a5), [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358)]:
|
|
44
|
+
- @interlace/eslint-devkit@1.4.3
|
|
45
|
+
|
|
3
46
|
## 1.3.4
|
|
4
47
|
|
|
5
48
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ npm install eslint-plugin-express-security --save-dev
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## ⚙️ Configuration Presets
|
|
43
|
+
|
|
43
44
|
| Preset | Description |
|
|
44
45
|
| :------------ | :---------------------------------------------------------------------- |
|
|
45
46
|
| `recommended` | Balanced security for Express projects (critical as error, others warn) |
|
|
@@ -48,6 +49,7 @@ npm install eslint-plugin-express-security --save-dev
|
|
|
48
49
|
| `graphql` | GraphQL-specific security rules only |
|
|
49
50
|
|
|
50
51
|
## 📚 Supported Libraries
|
|
52
|
+
|
|
51
53
|
| Library | npm | Downloads | Detection |
|
|
52
54
|
| :-------- | :---------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------- | :----------------------- |
|
|
53
55
|
| `express` | [](https://www.npmjs.com/package/express) | [](https://www.npmjs.com/package/express) | Misconfig, DoS |
|
|
@@ -58,10 +60,11 @@ npm install eslint-plugin-express-security --save-dev
|
|
|
58
60
|
---
|
|
59
61
|
|
|
60
62
|
## 📦 Compatibility
|
|
61
|
-
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
63
|
+
|
|
64
|
+
| Package | Version |
|
|
65
|
+
| :------ | :-------------------------------- |
|
|
66
|
+
| ESLint | `^8.0.0 \|\| ^9.0.0 \|\| ^10.0.0` |
|
|
67
|
+
| Node.js | `>=18.0.0` |
|
|
65
68
|
|
|
66
69
|
See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) — current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10.
|
|
67
70
|
|
|
@@ -69,50 +72,59 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
69
72
|
|
|
70
73
|
**Legend**
|
|
71
74
|
|
|
72
|
-
| Icon | Description
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
75
|
+
| Icon | Description |
|
|
76
|
+
| :--: | :------------------------------------------------------------------------ |
|
|
77
|
+
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
78
|
+
| ⚠️ | **Warns**: Set to warn in recommended preset. |
|
|
79
|
+
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
80
|
+
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
81
|
+
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
82
|
+
| 🟢 | **Type-unaware**: AST-only, runs in oxlint JS-plugin tier. |
|
|
83
|
+
| 🟡 | **Type-aware (refining)**: pure-AST primary path; types refine precision. |
|
|
84
|
+
| 🟠 | **Type-aware (graceful)**: requires TS program; silent without it. |
|
|
82
85
|
|
|
83
86
|
<!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
|
|
84
87
|
| Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
85
88
|
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
86
89
|
| [no-cors-credentials-wildcard](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-cors-credentials-wildcard?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-942 | | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
|
|
90
|
+
| [no-error-details-in-response](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-error-details-in-response?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-209 | A04:2021 | | Disallow sending caught error objects, stack traces, or spreads of them in HTTP responses. | 🟢 | | | | | |
|
|
87
91
|
| [no-exposed-debug-endpoints](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-exposed-debug-endpoints?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-489 | A05:2021 | | Identifies potential debug, administration, or testing endpoints that are often left exposed in production… | 🟢 | | | | | |
|
|
88
92
|
| [no-express-unsafe-regex-route](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-express-unsafe-regex-route?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-1333 | | | This rule detects Regular Expression Denial of Service (ReDoS) vulnerabilities in Express route patterns | 🟢 | | | | | |
|
|
89
93
|
| [no-graphql-introspection-production](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-graphql-introspection-production?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-200 | | | This rule detects GraphQL servers with introspection enabled in production | 🟢 | | | | | |
|
|
94
|
+
| [no-host-header-in-links](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-host-header-in-links?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-640 | A07:2021 | | Disallow building absolute URLs (password-reset and verification links) from the Host or X-Forwarded-Host r… | 🟢 | | | | | |
|
|
90
95
|
| [no-insecure-cookie-options](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-insecure-cookie-options?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-614 | | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | 💼 | | | | |
|
|
91
96
|
| [no-permissive-cors](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-permissive-cors?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-942 | | | Detects overly permissive CORS configurations in Express.js applications | 🟢 | 💼 | | | | |
|
|
97
|
+
| [no-sensitive-data-in-query](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-sensitive-data-in-query?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-598 | A04:2021 | | Disallow reading sensitive-named parameters (password, token, secret, apiKey, ...) from req.query. | 🟢 | | | | | |
|
|
98
|
+
| [no-static-root-exposure](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-static-root-exposure?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-548 | A05:2021 | | Disallow express.static() roots that expose the application directory and any serve-index usage | 🟢 | | | | | |
|
|
99
|
+
| [no-user-controlled-render-locals](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-user-controlled-render-locals?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-73 | A03:2021 | | Disallow res.render() with locals or view names sourced wholesale from req.body / req.query / req.params | 🟢 | | | | | |
|
|
100
|
+
| [require-case-insensitive-path-guard](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/require-case-insensitive-path-guard?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-178 | A01:2021 | | This rule detects path-based authorization guards that compare req.path case-sensitively, which case-insens… | 🟢 | | | | | |
|
|
92
101
|
| [require-csrf-protection](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/require-csrf-protection?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-352 | | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | 💼 | | | | |
|
|
93
102
|
| [require-express-body-parser-limits](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/require-express-body-parser-limits?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-400 | | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
|
|
94
103
|
| [require-helmet](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/require-helmet?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-693 | | | This rule detects Express.js applications that are missing the helmet middleware | 🟢 | 💼 | | | | |
|
|
104
|
+
| [require-query-type-guard](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/require-query-type-guard?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-843 | A03:2021 | | This rule detects string methods called on req.query values without a type guard — Express query values can… | 🟢 | | | | | |
|
|
95
105
|
| [require-rate-limiting](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/require-rate-limiting?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-770 | | | This rule detects Express.js applications missing rate limiting middleware | 🟢 | 💼 | | | | |
|
|
96
106
|
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
107
|
+
|
|
97
108
|
## 🔗 Related ESLint Plugins
|
|
98
109
|
|
|
99
110
|
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
100
111
|
|
|
101
|
-
| Plugin
|
|
102
|
-
|
|
|
103
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding)
|
|
104
|
-
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg)
|
|
105
|
-
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security)
|
|
106
|
-
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt)
|
|
107
|
-
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security)
|
|
108
|
-
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security)
|
|
109
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security)
|
|
110
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security)
|
|
111
|
-
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security)
|
|
112
|
-
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security hardening.
|
|
113
|
-
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next)
|
|
112
|
+
| Plugin | Downloads | Description |
|
|
113
|
+
| :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------- |
|
|
114
|
+
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | General security rules & OWASP guidelines. |
|
|
115
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
116
|
+
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security) | [](https://www.npmjs.com/package/eslint-plugin-node-security) | Node.js core-module security (fs, child_process, vm, crypto, Buffer). |
|
|
117
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
118
|
+
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [](https://www.npmjs.com/package/eslint-plugin-browser-security) | Browser-specific security & XSS prevention. |
|
|
119
|
+
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security hardening rules. |
|
|
120
|
+
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda security best practices. |
|
|
121
|
+
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security rules & patterns. |
|
|
122
|
+
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | [](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | MongoDB security best practices. |
|
|
123
|
+
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security hardening. |
|
|
124
|
+
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [](https://www.npmjs.com/package/eslint-plugin-import-next) | Next-gen import sorting & architecture. |
|
|
114
125
|
|
|
115
126
|
<!-- INTERLACE:STAR_CTA:START -->
|
|
127
|
+
|
|
116
128
|
## ⭐ Support & follow
|
|
117
129
|
|
|
118
130
|
If this plugin caught a real bug for you, **[star the repo](https://github.com/ofri-peretz/eslint)** — stars are the signal that keeps the Interlace ESLint ecosystem maintained — and **[follow the writeups on Dev.to](https://dev.to/ofri-peretz)** for the benchmarks and security research behind these rules.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-express-security",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "ESLint plugin for Express.js security — detects permissive CORS, missing CSRF protection, missing helmet headers, insecure cookies, and GraphQL introspection in production.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./src/index.d.ts",
|
|
@@ -43,32 +43,44 @@
|
|
|
43
43
|
],
|
|
44
44
|
"keywords": [
|
|
45
45
|
"eslint",
|
|
46
|
-
"eslint-plugin",
|
|
47
46
|
"eslintplugin",
|
|
47
|
+
"eslint-plugin",
|
|
48
|
+
"static-analysis",
|
|
49
|
+
"linting",
|
|
50
|
+
"code-quality",
|
|
51
|
+
"security",
|
|
52
|
+
"sast",
|
|
53
|
+
"appsec",
|
|
54
|
+
"vulnerability",
|
|
55
|
+
"owasp",
|
|
56
|
+
"cwe",
|
|
48
57
|
"interlace-security",
|
|
49
58
|
"express",
|
|
50
59
|
"expressjs",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
60
|
+
"node",
|
|
61
|
+
"nodejs",
|
|
62
|
+
"web-security",
|
|
63
|
+
"api-security",
|
|
54
64
|
"cors",
|
|
55
65
|
"csrf",
|
|
66
|
+
"cwe-352",
|
|
67
|
+
"cookies",
|
|
68
|
+
"helmet",
|
|
69
|
+
"security-headers",
|
|
56
70
|
"graphql",
|
|
57
71
|
"rate-limiting",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"cwe",
|
|
72
|
+
"redos",
|
|
73
|
+
"open-redirect",
|
|
61
74
|
"llm-optimized",
|
|
62
75
|
"ai-assistant",
|
|
63
|
-
"typescript"
|
|
64
|
-
"static-analysis"
|
|
76
|
+
"typescript"
|
|
65
77
|
],
|
|
66
78
|
"engines": {
|
|
67
79
|
"node": ">=18.0.0"
|
|
68
80
|
},
|
|
69
81
|
"dependencies": {
|
|
70
82
|
"tslib": "^2.3.0",
|
|
71
|
-
"@interlace/eslint-devkit": "^1.4.
|
|
83
|
+
"@interlace/eslint-devkit": "^1.4.3"
|
|
72
84
|
},
|
|
73
85
|
"peerDependencies": {
|
|
74
86
|
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
package/src/index.js
CHANGED
|
@@ -27,6 +27,14 @@ const no_missing_csrf_protection_1 = require("./rules/no-missing-csrf-protection
|
|
|
27
27
|
const no_missing_security_headers_1 = require("./rules/no-missing-security-headers");
|
|
28
28
|
// Structural redirect safety — structural-api, enforcement-grade
|
|
29
29
|
const no_user_controlled_redirect_1 = require("./rules/no-user-controlled-redirect");
|
|
30
|
+
// Corpus coverage-gap rules (A-lite, 2026-07) — CWE-640/209/598/073/548/178/843
|
|
31
|
+
const no_host_header_in_links_1 = require("./rules/no-host-header-in-links");
|
|
32
|
+
const no_error_details_in_response_1 = require("./rules/no-error-details-in-response");
|
|
33
|
+
const no_sensitive_data_in_query_1 = require("./rules/no-sensitive-data-in-query");
|
|
34
|
+
const no_user_controlled_render_locals_1 = require("./rules/no-user-controlled-render-locals");
|
|
35
|
+
const no_static_root_exposure_1 = require("./rules/no-static-root-exposure");
|
|
36
|
+
const require_case_insensitive_path_guard_1 = require("./rules/require-case-insensitive-path-guard");
|
|
37
|
+
const require_query_type_guard_1 = require("./rules/require-query-type-guard");
|
|
30
38
|
/**
|
|
31
39
|
* Collection of all Express security ESLint rules
|
|
32
40
|
*/
|
|
@@ -52,6 +60,14 @@ exports.rules = {
|
|
|
52
60
|
'no-missing-security-headers': no_missing_security_headers_1.noMissingSecurityHeaders,
|
|
53
61
|
// Open redirect — structural-api (fires on res.redirect(req.query.*) AST shape)
|
|
54
62
|
'no-user-controlled-redirect': no_user_controlled_redirect_1.noUserControlledRedirect,
|
|
63
|
+
// Corpus coverage-gap rules (A-lite, 2026-07)
|
|
64
|
+
'no-host-header-in-links': no_host_header_in_links_1.noHostHeaderInLinks,
|
|
65
|
+
'no-error-details-in-response': no_error_details_in_response_1.noErrorDetailsInResponse,
|
|
66
|
+
'no-sensitive-data-in-query': no_sensitive_data_in_query_1.noSensitiveDataInQuery,
|
|
67
|
+
'no-user-controlled-render-locals': no_user_controlled_render_locals_1.noUserControlledRenderLocals,
|
|
68
|
+
'no-static-root-exposure': no_static_root_exposure_1.noStaticRootExposure,
|
|
69
|
+
'require-case-insensitive-path-guard': require_case_insensitive_path_guard_1.requireCaseInsensitivePathGuard,
|
|
70
|
+
'require-query-type-guard': require_query_type_guard_1.requireQueryTypeGuard,
|
|
55
71
|
};
|
|
56
72
|
/**
|
|
57
73
|
* ESLint Plugin object
|
|
@@ -59,7 +75,7 @@ exports.rules = {
|
|
|
59
75
|
exports.plugin = {
|
|
60
76
|
meta: {
|
|
61
77
|
name: 'eslint-plugin-express-security',
|
|
62
|
-
version: '1.
|
|
78
|
+
version: '1.4.0',
|
|
63
79
|
},
|
|
64
80
|
rules: exports.rules,
|
|
65
81
|
};
|
|
@@ -88,6 +104,15 @@ const recommendedRules = {
|
|
|
88
104
|
'express-security/no-missing-security-headers': 'warn',
|
|
89
105
|
// Open redirect — structural, CWE-601
|
|
90
106
|
'express-security/no-user-controlled-redirect': 'error',
|
|
107
|
+
// Corpus coverage-gap rules (A-lite, 2026-07)
|
|
108
|
+
'express-security/no-host-header-in-links': 'error',
|
|
109
|
+
'express-security/no-error-details-in-response': 'error',
|
|
110
|
+
// Name-based detection (sensitive param names) — review-prompt severity per scope audit I3
|
|
111
|
+
'express-security/no-sensitive-data-in-query': 'warn',
|
|
112
|
+
'express-security/no-user-controlled-render-locals': 'error',
|
|
113
|
+
'express-security/no-static-root-exposure': 'error',
|
|
114
|
+
'express-security/require-case-insensitive-path-guard': 'warn',
|
|
115
|
+
'express-security/require-query-type-guard': 'warn',
|
|
91
116
|
};
|
|
92
117
|
/**
|
|
93
118
|
* Preset configurations for Express security rules
|
|
@@ -0,0 +1,57 @@
|
|
|
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-error-details-in-response
|
|
8
|
+
*
|
|
9
|
+
* Detects information exposure through error messages (CWE-209): sending a
|
|
10
|
+
* caught error — the raw error object, `err.stack`, a spread `{ ...err }`,
|
|
11
|
+
* or (optionally) `err.message` — to the HTTP client via
|
|
12
|
+
* `res.send()` / `res.json()` / `res.end()`. Stack traces reveal absolute
|
|
13
|
+
* paths, dependency versions and internal module layout; driver errors leak
|
|
14
|
+
* query text, connection strings and hostnames.
|
|
15
|
+
*
|
|
16
|
+
* CWE-209: Generation of Error Message Containing Sensitive Information
|
|
17
|
+
* OWASP A04:2021 – Insecure Design
|
|
18
|
+
*
|
|
19
|
+
* ## Detection method: structural-api + scoped error binding
|
|
20
|
+
*
|
|
21
|
+
* The rule tracks error identifiers introduced by:
|
|
22
|
+
* - `catch (err)` clause parameters (within the catch block), and
|
|
23
|
+
* - error-first callbacks / error middleware — functions whose FIRST
|
|
24
|
+
* parameter is named `err` or `error` (within the function body).
|
|
25
|
+
*
|
|
26
|
+
* A response-send call (`res` / `response` / `reply`, including chained
|
|
27
|
+
* `res.status(500).json(...)`) whose first argument is such an identifier,
|
|
28
|
+
* a `.stack` / `.message` member on it, or an object literal embedding or
|
|
29
|
+
* spreading it, is reported.
|
|
30
|
+
*
|
|
31
|
+
* It deliberately does NOT flag:
|
|
32
|
+
* - generic literal responses (`res.json({ error: 'Internal error' })`)
|
|
33
|
+
* - server-side logging (`logger.error(err)`)
|
|
34
|
+
* - `err.message` under the default `allowMessage: true`
|
|
35
|
+
* - responses inside a NODE_ENV guard when `allowInDev: true`
|
|
36
|
+
*
|
|
37
|
+
* @see https://cwe.mitre.org/data/definitions/209.html
|
|
38
|
+
* @see https://cheatsheetseries.owasp.org/cheatsheets/Error_Handling_Cheat_Sheet.html
|
|
39
|
+
*/
|
|
40
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
41
|
+
export interface Options {
|
|
42
|
+
/**
|
|
43
|
+
* Allow `err.message` in responses. Messages are usually intended for
|
|
44
|
+
* humans, but set to false for a strict policy. Default: true
|
|
45
|
+
*/
|
|
46
|
+
allowMessage?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Allow error details inside an if-guard that checks NODE_ENV
|
|
49
|
+
* (development-only debugging). Default: false
|
|
50
|
+
*/
|
|
51
|
+
allowInDev?: boolean;
|
|
52
|
+
}
|
|
53
|
+
type RuleOptions = [Options?];
|
|
54
|
+
export declare const noErrorDetailsInResponse: TSESLint.RuleModule<"errorDetailsExposed", RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
55
|
+
name: string;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.noErrorDetailsInResponse = void 0;
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
/** Response methods that write a body to the client. */
|
|
11
|
+
const SEND_METHODS = new Set(['send', 'json', 'end']);
|
|
12
|
+
/** First-parameter names that mark an error-first callback / middleware. */
|
|
13
|
+
const ERROR_PARAM_NAME = /^(err|error)$/i;
|
|
14
|
+
exports.noErrorDetailsInResponse = (0, eslint_devkit_1.createRule)({
|
|
15
|
+
name: 'no-error-details-in-response',
|
|
16
|
+
meta: {
|
|
17
|
+
type: 'problem',
|
|
18
|
+
hasSuggestions: false,
|
|
19
|
+
docs: {
|
|
20
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-express-security/docs/rules/no-error-details-in-response.md',
|
|
21
|
+
description: 'Disallow sending caught error objects, stacks, or spreads of them in HTTP responses',
|
|
22
|
+
cwe: 'CWE-209',
|
|
23
|
+
cvss: 5.3,
|
|
24
|
+
},
|
|
25
|
+
messages: {
|
|
26
|
+
errorDetailsExposed: (0, eslint_devkit_1.formatLLMMessage)({
|
|
27
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
28
|
+
issueName: 'Error Details Exposed (CWE-209)',
|
|
29
|
+
cwe: 'CWE-209',
|
|
30
|
+
description: 'The HTTP response includes {{detail}}. Stack traces and driver errors leak file paths, dependency versions, query text and hostnames to the caller.',
|
|
31
|
+
severity: 'MEDIUM',
|
|
32
|
+
fix: "Log the error server-side and respond with a generic body: logger.error(err); res.status(500).json({ error: 'Internal Server Error' })",
|
|
33
|
+
documentationLink: 'https://cheatsheetseries.owasp.org/cheatsheets/Error_Handling_Cheat_Sheet.html',
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
schema: [
|
|
37
|
+
{
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
allowMessage: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
default: true,
|
|
43
|
+
description: 'Allow err.message in responses',
|
|
44
|
+
},
|
|
45
|
+
allowInDev: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: false,
|
|
48
|
+
description: 'Allow error details inside an if-guard checking NODE_ENV',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
additionalProperties: false,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
defaultOptions: [{}],
|
|
56
|
+
create(context, [options]) {
|
|
57
|
+
const { allowMessage, allowInDev } = options;
|
|
58
|
+
const messageAllowed = allowMessage ?? true;
|
|
59
|
+
const devAllowed = allowInDev ?? false;
|
|
60
|
+
const sourceCode = context.sourceCode;
|
|
61
|
+
/** Active error bindings (catch params + error-first callback params). */
|
|
62
|
+
const frames = [];
|
|
63
|
+
function isErrorName(name) {
|
|
64
|
+
return frames.some((frame) => frame.name === name);
|
|
65
|
+
}
|
|
66
|
+
function enterFunction(node) {
|
|
67
|
+
const first = node.params[0];
|
|
68
|
+
if (first !== undefined &&
|
|
69
|
+
first.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
70
|
+
ERROR_PARAM_NAME.test(first.name)) {
|
|
71
|
+
frames.push({ node, name: first.name });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function exitFrame(node) {
|
|
75
|
+
if (frames.length > 0 && frames[frames.length - 1].node === node) {
|
|
76
|
+
frames.pop();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* True when the call is `res.send/json/end(...)` — including chained
|
|
81
|
+
* builders like `res.status(500).json(...)` — on a response object
|
|
82
|
+
* named res/response/reply.
|
|
83
|
+
*/
|
|
84
|
+
function isResponseSend(node) {
|
|
85
|
+
const callee = node.callee;
|
|
86
|
+
if (callee.type !== eslint_devkit_1.AST_NODE_TYPES.MemberExpression)
|
|
87
|
+
return false;
|
|
88
|
+
if (callee.property.type !== eslint_devkit_1.AST_NODE_TYPES.Identifier)
|
|
89
|
+
return false;
|
|
90
|
+
if (!SEND_METHODS.has(callee.property.name))
|
|
91
|
+
return false;
|
|
92
|
+
let obj = callee.object;
|
|
93
|
+
while (obj.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression &&
|
|
94
|
+
obj.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression) {
|
|
95
|
+
obj = obj.callee.object;
|
|
96
|
+
}
|
|
97
|
+
if (obj.type !== eslint_devkit_1.AST_NODE_TYPES.Identifier)
|
|
98
|
+
return false;
|
|
99
|
+
const lower = obj.name.toLowerCase();
|
|
100
|
+
return lower === 'res' || lower === 'response' || lower === 'reply';
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns a description when `node` exposes error details directly:
|
|
104
|
+
* the raw error identifier, `err.stack`, or `err.message` (when
|
|
105
|
+
* disallowed). Returns null otherwise.
|
|
106
|
+
*/
|
|
107
|
+
function detailOf(node) {
|
|
108
|
+
if (node.type === eslint_devkit_1.AST_NODE_TYPES.Identifier && isErrorName(node.name)) {
|
|
109
|
+
return `the raw error \`${node.name}\``;
|
|
110
|
+
}
|
|
111
|
+
if (node.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
|
|
112
|
+
!node.computed &&
|
|
113
|
+
node.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
114
|
+
isErrorName(node.object.name) &&
|
|
115
|
+
node.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
116
|
+
if (node.property.name === 'stack') {
|
|
117
|
+
return `\`${node.object.name}.stack\``;
|
|
118
|
+
}
|
|
119
|
+
if (node.property.name === 'message' && !messageAllowed) {
|
|
120
|
+
return `\`${node.object.name}.message\``;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
/** Findings in a response-send argument (direct or one object level). */
|
|
126
|
+
function collectFindings(arg) {
|
|
127
|
+
const direct = detailOf(arg);
|
|
128
|
+
if (direct !== null)
|
|
129
|
+
return [{ node: arg, detail: direct }];
|
|
130
|
+
if (arg.type !== eslint_devkit_1.AST_NODE_TYPES.ObjectExpression)
|
|
131
|
+
return [];
|
|
132
|
+
const findings = [];
|
|
133
|
+
for (const prop of arg.properties) {
|
|
134
|
+
if (prop.type === eslint_devkit_1.AST_NODE_TYPES.SpreadElement) {
|
|
135
|
+
if (prop.argument.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
136
|
+
isErrorName(prop.argument.name)) {
|
|
137
|
+
findings.push({
|
|
138
|
+
node: prop,
|
|
139
|
+
detail: `\`{ ...${prop.argument.name} }\` (spread of the raw error)`,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const detail = detailOf(prop.value);
|
|
145
|
+
if (detail !== null)
|
|
146
|
+
findings.push({ node: prop.value, detail });
|
|
147
|
+
}
|
|
148
|
+
return findings;
|
|
149
|
+
}
|
|
150
|
+
/** True when an enclosing if-statement's test mentions NODE_ENV. */
|
|
151
|
+
function isInDevGuard(node) {
|
|
152
|
+
let current = node.parent;
|
|
153
|
+
while (current != null) {
|
|
154
|
+
if (current.type === eslint_devkit_1.AST_NODE_TYPES.IfStatement &&
|
|
155
|
+
sourceCode.getText(current.test).includes('NODE_ENV')) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
current = current.parent;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
CatchClause(node) {
|
|
164
|
+
if (node.param !== null &&
|
|
165
|
+
node.param.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
166
|
+
frames.push({ node, name: node.param.name });
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
'CatchClause:exit': exitFrame,
|
|
170
|
+
FunctionDeclaration: enterFunction,
|
|
171
|
+
'FunctionDeclaration:exit': exitFrame,
|
|
172
|
+
FunctionExpression: enterFunction,
|
|
173
|
+
'FunctionExpression:exit': exitFrame,
|
|
174
|
+
ArrowFunctionExpression: enterFunction,
|
|
175
|
+
'ArrowFunctionExpression:exit': exitFrame,
|
|
176
|
+
CallExpression(node) {
|
|
177
|
+
// No active error binding — nothing can leak.
|
|
178
|
+
if (frames.length === 0)
|
|
179
|
+
return;
|
|
180
|
+
if (!isResponseSend(node))
|
|
181
|
+
return;
|
|
182
|
+
const arg = node.arguments[0];
|
|
183
|
+
if (arg === undefined)
|
|
184
|
+
return;
|
|
185
|
+
if (devAllowed && isInDevGuard(node))
|
|
186
|
+
return;
|
|
187
|
+
for (const finding of collectFindings(arg)) {
|
|
188
|
+
context.report({
|
|
189
|
+
node: finding.node,
|
|
190
|
+
messageId: 'errorDetailsExposed',
|
|
191
|
+
data: { detail: finding.detail },
|
|
192
|
+
// No suggestion: the safe replacement depends on the app's error
|
|
193
|
+
// contract (incident ids, logger, status shape), so there is
|
|
194
|
+
// nothing mechanical to offer. The remedy is in the message's
|
|
195
|
+
// `fix:` line. A `fix: () => null` suggestion would be stripped
|
|
196
|
+
// from the output by ESLint and render as nothing at all.
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
});
|