eslint-plugin-express-security 1.4.0 → 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.
Files changed (59) hide show
  1. package/README.md +7 -0
  2. package/package.json +5 -8
  3. package/src/index.d.ts +17 -40
  4. package/src/index.js +26 -66
  5. package/src/oxlint.d.ts +17 -20
  6. package/src/oxlint.js +0 -18
  7. package/src/rules/no-client-controlled-authorization/index.js +194 -0
  8. package/src/rules/no-cors-credentials-wildcard/index.js +0 -22
  9. package/src/rules/no-disabled-helmet-protections/index.js +125 -0
  10. package/src/rules/no-error-details-in-response/index.js +0 -26
  11. package/src/rules/no-exposed-debug-endpoints/index.js +0 -19
  12. package/src/rules/no-express-unsafe-regex-route/index.js +1 -32
  13. package/src/rules/no-graphql-introspection-production/index.js +0 -21
  14. package/src/rules/no-host-header-in-links/index.js +0 -31
  15. package/src/rules/no-idor-resource-access/index.js +126 -0
  16. package/src/rules/no-insecure-cookie-options/index.js +0 -12
  17. package/src/rules/no-missing-cors-check/index.js +4 -54
  18. package/src/rules/no-missing-csrf-protection/index.js +0 -25
  19. package/src/rules/no-missing-security-headers/index.js +0 -40
  20. package/src/rules/no-permissive-cors/index.js +0 -27
  21. package/src/rules/no-permissive-trust-proxy/index.js +106 -0
  22. package/src/rules/no-sensitive-data-in-query/index.js +1 -26
  23. package/src/rules/no-static-root-exposure/index.js +0 -21
  24. package/src/rules/no-unsafe-csp-directives/index.js +264 -0
  25. package/src/rules/no-user-controlled-redirect/index.js +0 -26
  26. package/src/rules/no-user-controlled-render-locals/index.js +0 -45
  27. package/src/rules/require-case-insensitive-path-guard/index.js +0 -21
  28. package/src/rules/require-csrf-protection/index.js +0 -42
  29. package/src/rules/require-express-body-parser-limits/index.js +0 -24
  30. package/src/rules/require-helmet/index.js +1 -25
  31. package/src/rules/require-query-type-guard/index.js +0 -20
  32. package/src/rules/require-rate-limiting/index.js +0 -13
  33. package/src/rules/require-route-authentication/index.js +225 -0
  34. package/src/rules/require-strict-transport-security/index.js +171 -0
  35. package/src/types/index.js +0 -5
  36. package/src/utils/index.js +81 -0
  37. package/AGENTS.md +0 -100
  38. package/CHANGELOG.md +0 -192
  39. package/src/rules/no-cors-credentials-wildcard/index.d.ts +0 -26
  40. package/src/rules/no-error-details-in-response/index.d.ts +0 -57
  41. package/src/rules/no-exposed-debug-endpoints/index.d.ts +0 -14
  42. package/src/rules/no-express-unsafe-regex-route/index.d.ts +0 -27
  43. package/src/rules/no-graphql-introspection-production/index.d.ts +0 -26
  44. package/src/rules/no-host-header-in-links/index.d.ts +0 -56
  45. package/src/rules/no-insecure-cookie-options/index.d.ts +0 -39
  46. package/src/rules/no-missing-cors-check/index.d.ts +0 -28
  47. package/src/rules/no-missing-csrf-protection/index.d.ts +0 -30
  48. package/src/rules/no-missing-security-headers/index.d.ts +0 -26
  49. package/src/rules/no-permissive-cors/index.d.ts +0 -28
  50. package/src/rules/no-sensitive-data-in-query/index.d.ts +0 -51
  51. package/src/rules/no-static-root-exposure/index.d.ts +0 -45
  52. package/src/rules/no-user-controlled-redirect/index.d.ts +0 -44
  53. package/src/rules/no-user-controlled-render-locals/index.d.ts +0 -49
  54. package/src/rules/require-case-insensitive-path-guard/index.d.ts +0 -59
  55. package/src/rules/require-csrf-protection/index.d.ts +0 -28
  56. package/src/rules/require-express-body-parser-limits/index.d.ts +0 -31
  57. package/src/rules/require-helmet/index.d.ts +0 -29
  58. package/src/rules/require-query-type-guard/index.d.ts +0 -54
  59. package/src/rules/require-rate-limiting/index.d.ts +0 -31
package/CHANGELOG.md DELETED
@@ -1,192 +0,0 @@
1
- ## [1.2.3] - 2026-02-08
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
-
46
- ## 1.3.4
47
-
48
- ### Patch Changes
49
-
50
- - [#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.
51
-
52
- - Updated dependencies [[`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad)]:
53
- - @interlace/eslint-devkit@1.4.2
54
-
55
- ## 1.3.3
56
-
57
- ### Patch Changes
58
-
59
- - [#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
60
-
61
- ## 1.3.2
62
-
63
- ### Patch Changes
64
-
65
- - [#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).
66
-
67
- ## 1.3.1
68
-
69
- ### Patch Changes
70
-
71
- - [#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
72
- emits. The emitted machine-readable message sources its `CVSS:x` from
73
- `CWE_MAPPING` via `formatLLMMessage` → `enrichFromCWE`, but the static
74
- `meta.docs.cvss` documentation field had drifted on 45 rules across these 7
75
- plugins — e.g. `no-hardcoded-credentials` documented `9.5` while emitting
76
- `CVSS:9.8` (the value the published article and SARIF/LLM consumers already
77
- read).
78
-
79
- This corrects the **documentation metadata only** — no emitted finding changes.
80
- Locked by `security-cvss-docs-consistency.lock.test.ts` (cross-plugin: every
81
- security rule's `meta.docs.cvss` must equal the CVSS it emits), the
82
- `no-hardcoded-credentials` rule lock (real ESLint `Linter` emission), and a
83
- devkit `enrichFromCWE` contract test pinning `CWE-798 → 9.8`.
84
-
85
- Follow-up (not in scope): 50 security rules document a CVSS that never appears
86
- in any emitted message (their messages carry no CWE), and several rules emit the
87
- generic CWE score where a rule-specific score may be warranted — both change
88
- emitted output and are separate decisions.
89
-
90
- ## 1.3.0
91
-
92
- ### Minor Changes
93
-
94
- - [#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
95
-
96
- 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.
97
-
98
- ### Patch Changes
99
-
100
- - [#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
101
-
102
- Rules that were recognized as null guards are now correctly identified as safe:
103
- 1. **Truthy if guard** — `if (obj) { obj.prop }` — direct truthy check proves non-null. Also covers chains: `if (response)` protects `response.data.items`.
104
- 2. **Short-circuit AND** — `obj && obj.prop` — right side of `&&` only runs when left is truthy.
105
- 3. **Ternary consequent** — `obj ? obj.prop : fallback` — truthy test guards the consequent.
106
-
107
- 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.
108
-
109
- - Updated dependencies [[`736a5fe`](https://github.com/ofri-peretz/eslint/commit/736a5fed47e673f6157ea900b29fe2a54e4bc7df)]:
110
- - @interlace/eslint-devkit@1.4.1
111
-
112
- ### Bug Fixes
113
-
114
- - align codecov component IDs with full package names ([2831b968](https://github.com/ofri-peretz/eslint/commit/2831b968))
115
-
116
- ### Documentation
117
-
118
- - fix changelog header format across all packages ([c3a15082](https://github.com/ofri-peretz/eslint/commit/c3a15082))
119
-
120
- ### ❤️ Thank You
121
-
122
- - Ofri Peretz
123
-
124
- ## [1.2.2] - 2026-02-06
125
-
126
- ### Bug Fixes
127
-
128
- - align codecov component names and update docs components ([0a59a86c](https://github.com/ofri-peretz/eslint/commit/0a59a86c))
129
-
130
- ### ❤️ Thank You
131
-
132
- - Ofri Peretz
133
-
134
- ## [1.2.1] - 2026-02-02
135
-
136
- This was a version bump only for eslint-plugin-express-security to align it with other projects, there were no code changes.
137
-
138
- # Changelog
139
-
140
- All notable changes to `eslint-plugin-express-security` will be documented in this file.
141
-
142
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
143
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
144
-
145
- ### Documentation
146
-
147
- - 📘 Launched new documentation site: [eslint.interlace.tools](https://eslint.interlace.tools/)
148
-
149
- ## [1.0.0] - 2025-12-29
150
-
151
- ### Added
152
-
153
- #### Headers & CORS Rules (4)
154
-
155
- - `require-helmet` - Require helmet middleware for security headers (CWE-693)
156
- - `no-permissive-cors` - Detect wildcard CORS origins (CWE-942)
157
- - `no-cors-credentials-wildcard` - Block credentials: true with wildcard origin (CWE-942)
158
- - `require-express-body-parser-limits` - Require body parser size limits (CWE-770)
159
-
160
- #### CSRF & Cookies Rules (2)
161
-
162
- - `require-csrf-protection` - Require CSRF middleware for state-changing routes (CWE-352)
163
- - `no-insecure-cookie-options` - Detect missing Secure/HttpOnly cookie attributes (CWE-614)
164
-
165
- #### Rate Limiting & DoS Rules (2)
166
-
167
- - `require-rate-limiting` - Require rate limiting middleware (CWE-770)
168
- - `no-express-unsafe-regex-route` - Detect ReDoS-vulnerable regex patterns (CWE-1333)
169
-
170
- #### GraphQL Rules (1)
171
-
172
- - `no-graphql-introspection-production` - Disable GraphQL introspection in production (CWE-200)
173
-
174
- #### Presets (4)
175
-
176
- - `recommended` - Balanced security defaults
177
- - `strict` - All 9 rules as errors
178
- - `api` - HTTP/API security rules only
179
- - `graphql` - GraphQL-specific rules only
180
-
181
- #### Features
182
-
183
- - LLM-optimized error messages with CWE references
184
- - OWASP Top 10 2021 alignment (A01, A03, A05, A07)
185
- - Middleware-aware detection (helmet, cors, csurf, express-rate-limit)
186
- - TypeScript support with exported option types
187
- - Comprehensive test coverage (132 tests, 93.15% line coverage)
188
-
189
- ### Security
190
-
191
- - Covers 6 CWEs: 200, 352, 614, 693, 770, 942, 1333
192
- - 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,57 +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-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 {};
@@ -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,56 +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-host-header-in-links
8
- *
9
- * Detects Host-header poisoning (CWE-640): building absolute URLs — most
10
- * critically password-reset and account-verification links — from
11
- * `req.headers.host`, `req.headers['x-forwarded-host']`, or
12
- * `req.get('host')`. Both headers are attacker-controlled on any request
13
- * that reaches the app directly, so a mailed link built from them can point
14
- * the recovery token at an attacker-owned host.
15
- *
16
- * CWE-640: Weak Password Recovery Mechanism for Forgotten Password
17
- * OWASP A07:2021 – Identification and Authentication Failures
18
- *
19
- * ## Detection method: structural-api + single-hop flow
20
- *
21
- * The rule fires when a host-header read (or a variable assigned from one in
22
- * the same file) participates in URL-building string concatenation or a
23
- * template literal. "URL-building" means a static part of the string
24
- * contains `://` or starts with `//`, OR the string is an argument of a
25
- * mail-send call (`sendMail` / `send` by default, configurable via
26
- * `checkMailCallees`).
27
- *
28
- * It deliberately does NOT flag:
29
- * - URLs built from config/env constants (`process.env.PUBLIC_ORIGIN + ...`)
30
- * - host values used only for logging (`console.log('host ' + req.headers.host)`)
31
- * - host reads validated inside an if-guard against `allowedHosts`
32
- *
33
- * @see https://cwe.mitre.org/data/definitions/640.html
34
- * @see https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management_Testing/06-Test_HTTP_Methods
35
- */
36
- import type { TSESLint } from '@interlace/eslint-devkit';
37
- type MessageIds = 'hostHeaderInLink' | 'useConfiguredOrigin';
38
- export interface Options {
39
- /**
40
- * Literal host values considered trusted. If an enclosing `if` statement
41
- * validates the host against one of these literals, the use is not
42
- * reported. Default: []
43
- */
44
- allowedHosts?: string[];
45
- /**
46
- * Callee names treated as mail-send sinks — a host header flowing into any
47
- * argument of these calls is flagged even without a `://` marker.
48
- * Default: ['sendMail', 'send']
49
- */
50
- checkMailCallees?: string[];
51
- }
52
- type RuleOptions = [Options?];
53
- export declare const noHostHeaderInLinks: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
54
- name: string;
55
- };
56
- 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 {};
@@ -1,30 +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-csrf-protection
8
- * Detects missing CSRF token validation in POST/PUT/DELETE requests
9
- * CWE-352: Cross-Site Request Forgery (CSRF)
10
- *
11
- * @see https://cwe.mitre.org/data/definitions/352.html
12
- * @see https://owasp.org/www-community/attacks/csrf
13
- */
14
- import type { TSESLint } from '@interlace/eslint-devkit';
15
- type MessageIds = 'missingCsrfProtection' | 'addCsrfValidation';
16
- export interface Options {
17
- /** Allow missing CSRF protection in test files. Default: false */
18
- allowInTests?: boolean;
19
- /** CSRF middleware patterns to recognize. Default: ['csrf', 'csurf', 'csrfProtection', 'verifyCsrfToken'] */
20
- csrfMiddlewarePatterns?: string[];
21
- /** HTTP methods that require CSRF protection. Default: ['post', 'put', 'delete', 'patch'] */
22
- protectedMethods?: string[];
23
- /** Additional safe patterns to ignore. Default: [] */
24
- ignorePatterns?: string[];
25
- }
26
- type RuleOptions = [Options?];
27
- export declare const noMissingCsrfProtection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
28
- name: string;
29
- };
30
- 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-missing-security-headers
8
- * Detects missing security headers in HTTP responses
9
- * CWE-693: Protection Mechanism Failure
10
- *
11
- * @see https://cwe.mitre.org/data/definitions/693.html
12
- * @see https://owasp.org/www-project-secure-headers/
13
- */
14
- import type { TSESLint } from '@interlace/eslint-devkit';
15
- type MessageIds = 'missingSecurityHeader' | 'addSecurityHeaders' | 'useMiddleware' | 'setHeader';
16
- export interface Options {
17
- /** Required security headers. Default: ['Content-Security-Policy', 'X-Frame-Options', 'X-Content-Type-Options'] */
18
- requiredHeaders?: string[];
19
- /** Ignore in test files. Default: true */
20
- ignoreInTests?: boolean;
21
- }
22
- type RuleOptions = [Options?];
23
- export declare const noMissingSecurityHeaders: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
24
- name: string;
25
- };
26
- 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-permissive-cors
8
- * Detects overly permissive CORS configurations in Express.js applications
9
- * CWE-942: Permissive Cross-domain Policy with Untrusted Domains
10
- *
11
- * @see https://cwe.mitre.org/data/definitions/942.html
12
- * @see https://owasp.org/www-community/attacks/CORS_OriginHeaderScrutiny
13
- */
14
- import type { TSESLint } from '@interlace/eslint-devkit';
15
- type MessageIds = 'permissiveCors' | 'useWhitelist';
16
- export interface Options {
17
- /** Allow permissive CORS in test files. Default: false */
18
- allowInTests?: boolean;
19
- /** Allow origin: true for development. Default: false */
20
- allowOriginTrue?: boolean;
21
- /** Allowed origins that should not trigger warnings. Default: [] */
22
- allowedOrigins?: string[];
23
- }
24
- type RuleOptions = [Options?];
25
- export declare const noPermissiveCors: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
26
- name: string;
27
- };
28
- export {};
@@ -1,51 +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-sensitive-data-in-query
8
- *
9
- * Detects sensitive data carried in the URL query string (CWE-598): reading
10
- * sensitive-named parameters (password, token, secret, apiKey, ...) from
11
- * `req.query` — either via member access (`req.query.password`) or
12
- * destructuring (`const { password } = req.query`). Query strings land in
13
- * access logs, proxy logs, browser history and the Referer header of every
14
- * outbound link, so secrets must travel in a POST body or header instead.
15
- *
16
- * CWE-598: Use of GET Request Method With Sensitive Query Strings
17
- * OWASP A04:2021 – Insecure Design
18
- *
19
- * ## Detection method: structural-api + token matching
20
- *
21
- * The rule fires on the AST shape `<req>.query.<name>` (req/request/ctx)
22
- * and on object-pattern destructuring from `<req>.query`. Sensitivity is
23
- * decided by tokenizing the parameter name (camelCase and snake_case both
24
- * split) and matching whole tokens — so `api_token` and `accessToken` match
25
- * `token`, while `author` does NOT match `auth` and `cardinality` does NOT
26
- * match `card`.
27
- *
28
- * It deliberately does NOT flag:
29
- * - the same names read from `req.body` or `req.params`
30
- * - non-sensitive query fields (`req.query.page`)
31
- * - names listed in the `allowedParams` option (e.g. `token` on a dedicated
32
- * email-verification route)
33
- *
34
- * @see https://cwe.mitre.org/data/definitions/598.html
35
- * @see https://owasp.org/www-community/vulnerabilities/Information_exposure_through_query_strings_in_url
36
- */
37
- import type { TSESLint } from '@interlace/eslint-devkit';
38
- type MessageIds = 'sensitiveQueryParam' | 'moveToBody';
39
- export interface Options {
40
- /** Additional sensitive parameter names (extends the defaults). Default: [] */
41
- sensitiveParams?: string[];
42
- /** Additional regex patterns (strings, case-insensitive) matched against the raw parameter name. Default: [] */
43
- extraPatterns?: string[];
44
- /** Parameter names explicitly allowed in the query string (exact, case-insensitive). Default: [] */
45
- allowedParams?: string[];
46
- }
47
- type RuleOptions = [Options?];
48
- export declare const noSensitiveDataInQuery: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
49
- name: string;
50
- };
51
- export {};