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.
- package/README.md +7 -0
- package/package.json +5 -8
- package/src/index.d.ts +17 -40
- package/src/index.js +26 -66
- 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 +0 -26
- package/src/rules/no-exposed-debug-endpoints/index.js +0 -19
- 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 +0 -31
- 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 +0 -40
- 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 +1 -26
- package/src/rules/no-static-root-exposure/index.js +0 -21
- 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 +0 -45
- package/src/rules/require-case-insensitive-path-guard/index.js +0 -21
- 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 +0 -20
- 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 -192
- package/src/rules/no-cors-credentials-wildcard/index.d.ts +0 -26
- package/src/rules/no-error-details-in-response/index.d.ts +0 -57
- 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-host-header-in-links/index.d.ts +0 -56
- 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-sensitive-data-in-query/index.d.ts +0 -51
- package/src/rules/no-static-root-exposure/index.d.ts +0 -45
- package/src/rules/no-user-controlled-redirect/index.d.ts +0 -44
- package/src/rules/no-user-controlled-render-locals/index.d.ts +0 -49
- package/src/rules/require-case-insensitive-path-guard/index.d.ts +0 -59
- 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-query-type-guard/index.d.ts +0 -54
- package/src/rules/require-rate-limiting/index.d.ts +0 -31
package/README.md
CHANGED
|
@@ -86,16 +86,21 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
86
86
|
<!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
|
|
87
87
|
| Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
88
88
|
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
89
|
+
| [no-client-controlled-authorization](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-client-controlled-authorization?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-863 | A01:2021 | | This rule detects access decisions taken on request-supplied role, permission or identity values — the chec… | 🟢 | | | | | |
|
|
89
90
|
| [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: | 🟢 | | | | | |
|
|
91
|
+
| [no-disabled-helmet-protections](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-disabled-helmet-protections?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-693 | A05:2021 | | This rule detects helmet options that switch a shipped security-header default off, leaving a mounted helme… | 🟢 | 💼 | | | | |
|
|
90
92
|
| [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. | 🟢 | | | | | |
|
|
91
93
|
| [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… | 🟢 | | | | | |
|
|
92
94
|
| [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 | 🟢 | | | | | |
|
|
93
95
|
| [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
96
|
| [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… | 🟢 | | | | | |
|
|
97
|
+
| [no-idor-resource-access](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-idor-resource-access?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-639 | A01:2021 | | This rule detects a resource fetched by an identifier taken straight from the request inside a handler that… | 🟢 | | | | | |
|
|
95
98
|
| [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: | 🟢 | 💼 | | | | |
|
|
96
99
|
| [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 | 🟢 | 💼 | | | | |
|
|
100
|
+
| [no-permissive-trust-proxy](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-permissive-trust-proxy?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-348 | A05:2021 | | This rule detects unconditional 'trust proxy' settings, which make req.ip whatever the caller says it is an… | 🟢 | 💼 | | | | |
|
|
97
101
|
| [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
102
|
| [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 | 🟢 | | | | | |
|
|
103
|
+
| [no-unsafe-csp-directives](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/no-unsafe-csp-directives?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-79 | A03:2021 | | This rule detects Content-Security-Policy directives that hand back the protection the header exists to pro… | 🟢 | 💼 | | | | |
|
|
99
104
|
| [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
105
|
| [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… | 🟢 | | | | | |
|
|
101
106
|
| [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: | 🟢 | 💼 | | | | |
|
|
@@ -103,6 +108,8 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
103
108
|
| [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
109
|
| [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… | 🟢 | | | | | |
|
|
105
110
|
| [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 | 🟢 | 💼 | | | | |
|
|
111
|
+
| [require-route-authentication](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/require-route-authentication?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-306 | A07:2021 | | This rule detects routes that expose a critical function — credentials, accounts, payments, configuration —… | 🟢 | | | | | |
|
|
112
|
+
| [require-strict-transport-security](https://eslint.interlace.tools/docs/security/plugin-express-security/rules/require-strict-transport-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-express-security) | CWE-319 | A02:2021 | | This rule detects HSTS configurations that leave a downgrade window open — the header disabled, a max-age b… | 🟢 | 💼 | | | | |
|
|
106
113
|
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
107
114
|
|
|
108
115
|
## 🔗 Related ESLint Plugins
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-express-security",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
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",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"homepage": "https://eslint.interlace.tools/docs/security/plugin-express-security?utm_source=npm&utm_medium=referral&utm_campaign=eslint-plugin-express-security",
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/ofri-peretz/eslint",
|
|
27
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git",
|
|
28
28
|
"directory": "packages/eslint-plugin-express-security"
|
|
29
29
|
},
|
|
30
30
|
"bugs": {
|
|
@@ -35,11 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"src/",
|
|
38
|
-
"dist/",
|
|
39
38
|
"README.md",
|
|
40
|
-
"LICENSE"
|
|
41
|
-
"CHANGELOG.md",
|
|
42
|
-
"AGENTS.md"
|
|
39
|
+
"LICENSE"
|
|
43
40
|
],
|
|
44
41
|
"keywords": [
|
|
45
42
|
"eslint",
|
|
@@ -80,7 +77,7 @@
|
|
|
80
77
|
},
|
|
81
78
|
"dependencies": {
|
|
82
79
|
"tslib": "^2.3.0",
|
|
83
|
-
"@interlace/eslint-devkit": "^1.
|
|
80
|
+
"@interlace/eslint-devkit": "^1.6.0"
|
|
84
81
|
},
|
|
85
82
|
"peerDependencies": {
|
|
86
83
|
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
@@ -114,6 +111,6 @@
|
|
|
114
111
|
},
|
|
115
112
|
"funding": {
|
|
116
113
|
"type": "github",
|
|
117
|
-
"url": "https://github.com/ofri-peretz/eslint"
|
|
114
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git"
|
|
118
115
|
}
|
|
119
116
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,40 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @see https://github.com/ofri-peretz/eslint#readme
|
|
19
|
-
*/
|
|
20
|
-
import { TSESLint } from '@interlace/eslint-devkit';
|
|
21
|
-
/**
|
|
22
|
-
* Collection of all Express security ESLint rules
|
|
23
|
-
*/
|
|
24
|
-
export declare const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
25
|
-
/**
|
|
26
|
-
* ESLint Plugin object
|
|
27
|
-
*/
|
|
28
|
-
export declare const plugin: TSESLint.FlatConfig.Plugin;
|
|
29
|
-
/**
|
|
30
|
-
* Preset configurations for Express security rules
|
|
31
|
-
*/
|
|
32
|
-
export declare const configs: Record<string, TSESLint.FlatConfig.Config>;
|
|
33
|
-
/**
|
|
34
|
-
* Default export for ESLint plugin
|
|
35
|
-
*/
|
|
36
|
-
export default plugin;
|
|
37
|
-
/**
|
|
38
|
-
* Re-export all types from the types barrel
|
|
39
|
-
*/
|
|
40
|
-
export type { RequireHelmetOptions, NoPermissiveCorsOptions, RequireCsrfProtectionOptions, NoInsecureCookieOptions, RequireRateLimitingOptions, NoGraphqlIntrospectionProductionOptions, NoCorsCredentialsWildcardOptions, RequireExpressBodyParserLimitsOptions, NoExpressUnsafeRegexRouteOptions, AllExpressSecurityRulesOptions, } from './types/index';
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
package/src/index.js
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.configs = exports.plugin = exports.rules = void 0;
|
|
9
|
-
// Security rules - Headers & CORS
|
|
10
4
|
const require_helmet_1 = require("./rules/require-helmet");
|
|
11
5
|
const no_permissive_cors_1 = require("./rules/no-permissive-cors");
|
|
12
|
-
// Security rules - CSRF & Cookies
|
|
13
6
|
const require_csrf_protection_1 = require("./rules/require-csrf-protection");
|
|
14
7
|
const no_insecure_cookie_options_1 = require("./rules/no-insecure-cookie-options");
|
|
15
|
-
// Security rules - Rate Limiting
|
|
16
8
|
const require_rate_limiting_1 = require("./rules/require-rate-limiting");
|
|
17
|
-
// Security rules - GraphQL
|
|
18
9
|
const no_graphql_introspection_production_1 = require("./rules/no-graphql-introspection-production");
|
|
19
|
-
// Security rules - Critical CORS & DoS
|
|
20
10
|
const no_cors_credentials_wildcard_1 = require("./rules/no-cors-credentials-wildcard");
|
|
21
11
|
const require_express_body_parser_limits_1 = require("./rules/require-express-body-parser-limits");
|
|
22
12
|
const no_express_unsafe_regex_route_1 = require("./rules/no-express-unsafe-regex-route");
|
|
23
13
|
const no_exposed_debug_endpoints_1 = require("./rules/no-exposed-debug-endpoints");
|
|
24
|
-
// Migrated from browser-security — these check server-side Express patterns, not browser APIs
|
|
25
14
|
const no_missing_cors_check_1 = require("./rules/no-missing-cors-check");
|
|
26
15
|
const no_missing_csrf_protection_1 = require("./rules/no-missing-csrf-protection");
|
|
27
16
|
const no_missing_security_headers_1 = require("./rules/no-missing-security-headers");
|
|
28
|
-
// Structural redirect safety — structural-api, enforcement-grade
|
|
29
17
|
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
18
|
const no_host_header_in_links_1 = require("./rules/no-host-header-in-links");
|
|
32
19
|
const no_error_details_in_response_1 = require("./rules/no-error-details-in-response");
|
|
33
20
|
const no_sensitive_data_in_query_1 = require("./rules/no-sensitive-data-in-query");
|
|
@@ -35,32 +22,28 @@ const no_user_controlled_render_locals_1 = require("./rules/no-user-controlled-r
|
|
|
35
22
|
const no_static_root_exposure_1 = require("./rules/no-static-root-exposure");
|
|
36
23
|
const require_case_insensitive_path_guard_1 = require("./rules/require-case-insensitive-path-guard");
|
|
37
24
|
const require_query_type_guard_1 = require("./rules/require-query-type-guard");
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
const no_disabled_helmet_protections_1 = require("./rules/no-disabled-helmet-protections");
|
|
26
|
+
const require_strict_transport_security_1 = require("./rules/require-strict-transport-security");
|
|
27
|
+
const no_unsafe_csp_directives_1 = require("./rules/no-unsafe-csp-directives");
|
|
28
|
+
const no_permissive_trust_proxy_1 = require("./rules/no-permissive-trust-proxy");
|
|
29
|
+
const require_route_authentication_1 = require("./rules/require-route-authentication");
|
|
30
|
+
const no_client_controlled_authorization_1 = require("./rules/no-client-controlled-authorization");
|
|
31
|
+
const no_idor_resource_access_1 = require("./rules/no-idor-resource-access");
|
|
41
32
|
exports.rules = {
|
|
42
|
-
// Headers & CORS
|
|
43
33
|
'require-helmet': require_helmet_1.requireHelmet,
|
|
44
34
|
'no-permissive-cors': no_permissive_cors_1.noPermissiveCors,
|
|
45
|
-
// CSRF & Cookies
|
|
46
35
|
'require-csrf-protection': require_csrf_protection_1.requireCsrfProtection,
|
|
47
36
|
'no-insecure-cookie-options': no_insecure_cookie_options_1.noInsecureCookieOptions,
|
|
48
|
-
// Rate Limiting
|
|
49
37
|
'require-rate-limiting': require_rate_limiting_1.requireRateLimiting,
|
|
50
|
-
// GraphQL
|
|
51
38
|
'no-graphql-introspection-production': no_graphql_introspection_production_1.noGraphqlIntrospectionProduction,
|
|
52
|
-
// Critical CORS & DoS (P0)
|
|
53
39
|
'no-cors-credentials-wildcard': no_cors_credentials_wildcard_1.noCorsCredentialsWildcard,
|
|
54
40
|
'require-express-body-parser-limits': require_express_body_parser_limits_1.requireExpressBodyParserLimits,
|
|
55
41
|
'no-express-unsafe-regex-route': no_express_unsafe_regex_route_1.noExpressUnsafeRegexRoute,
|
|
56
42
|
'no-exposed-debug-endpoints': no_exposed_debug_endpoints_1.noExposedDebugEndpoints,
|
|
57
|
-
// Migrated from browser-security (server-side Express checks)
|
|
58
43
|
'no-missing-cors-check': no_missing_cors_check_1.noMissingCorsCheck,
|
|
59
44
|
'no-missing-csrf-protection': no_missing_csrf_protection_1.noMissingCsrfProtection,
|
|
60
45
|
'no-missing-security-headers': no_missing_security_headers_1.noMissingSecurityHeaders,
|
|
61
|
-
// Open redirect — structural-api (fires on res.redirect(req.query.*) AST shape)
|
|
62
46
|
'no-user-controlled-redirect': no_user_controlled_redirect_1.noUserControlledRedirect,
|
|
63
|
-
// Corpus coverage-gap rules (A-lite, 2026-07)
|
|
64
47
|
'no-host-header-in-links': no_host_header_in_links_1.noHostHeaderInLinks,
|
|
65
48
|
'no-error-details-in-response': no_error_details_in_response_1.noErrorDetailsInResponse,
|
|
66
49
|
'no-sensitive-data-in-query': no_sensitive_data_in_query_1.noSensitiveDataInQuery,
|
|
@@ -68,72 +51,58 @@ exports.rules = {
|
|
|
68
51
|
'no-static-root-exposure': no_static_root_exposure_1.noStaticRootExposure,
|
|
69
52
|
'require-case-insensitive-path-guard': require_case_insensitive_path_guard_1.requireCaseInsensitivePathGuard,
|
|
70
53
|
'require-query-type-guard': require_query_type_guard_1.requireQueryTypeGuard,
|
|
54
|
+
'no-disabled-helmet-protections': no_disabled_helmet_protections_1.noDisabledHelmetProtections,
|
|
55
|
+
'require-strict-transport-security': require_strict_transport_security_1.requireStrictTransportSecurity,
|
|
56
|
+
'no-unsafe-csp-directives': no_unsafe_csp_directives_1.noUnsafeCspDirectives,
|
|
57
|
+
'no-permissive-trust-proxy': no_permissive_trust_proxy_1.noPermissiveTrustProxy,
|
|
58
|
+
'require-route-authentication': require_route_authentication_1.requireRouteAuthentication,
|
|
59
|
+
'no-client-controlled-authorization': no_client_controlled_authorization_1.noClientControlledAuthorization,
|
|
60
|
+
'no-idor-resource-access': no_idor_resource_access_1.noIdorResourceAccess,
|
|
71
61
|
};
|
|
72
|
-
/**
|
|
73
|
-
* ESLint Plugin object
|
|
74
|
-
*/
|
|
75
62
|
exports.plugin = {
|
|
76
63
|
meta: {
|
|
77
64
|
name: 'eslint-plugin-express-security',
|
|
78
|
-
version: '1.
|
|
65
|
+
version: '1.5.0',
|
|
79
66
|
},
|
|
80
67
|
rules: exports.rules,
|
|
81
68
|
};
|
|
82
|
-
/**
|
|
83
|
-
* Recommended configuration - balanced security enforcement
|
|
84
|
-
*/
|
|
85
69
|
const recommendedRules = {
|
|
86
|
-
// Critical - Security Headers
|
|
87
70
|
'express-security/require-helmet': 'error',
|
|
88
71
|
'express-security/no-permissive-cors': 'error',
|
|
89
|
-
// High - CSRF & Cookies
|
|
90
72
|
'express-security/require-csrf-protection': 'warn',
|
|
91
73
|
'express-security/no-insecure-cookie-options': 'error',
|
|
92
|
-
// High - DDoS Protection
|
|
93
74
|
'express-security/require-rate-limiting': 'warn',
|
|
94
|
-
// Medium - GraphQL
|
|
95
75
|
'express-security/no-graphql-introspection-production': 'warn',
|
|
96
|
-
// Critical - CORS & DoS (P0)
|
|
97
76
|
'express-security/no-cors-credentials-wildcard': 'error',
|
|
98
77
|
'express-security/require-express-body-parser-limits': 'warn',
|
|
99
78
|
'express-security/no-express-unsafe-regex-route': 'error',
|
|
100
79
|
'express-security/no-exposed-debug-endpoints': 'error',
|
|
101
|
-
// Migrated from browser-security
|
|
102
80
|
'express-security/no-missing-cors-check': 'warn',
|
|
103
81
|
'express-security/no-missing-csrf-protection': 'warn',
|
|
104
82
|
'express-security/no-missing-security-headers': 'warn',
|
|
105
|
-
// Open redirect — structural, CWE-601
|
|
106
83
|
'express-security/no-user-controlled-redirect': 'error',
|
|
107
|
-
// Corpus coverage-gap rules (A-lite, 2026-07)
|
|
108
84
|
'express-security/no-host-header-in-links': 'error',
|
|
109
85
|
'express-security/no-error-details-in-response': 'error',
|
|
110
|
-
// Name-based detection (sensitive param names) — review-prompt severity per scope audit I3
|
|
111
86
|
'express-security/no-sensitive-data-in-query': 'warn',
|
|
112
87
|
'express-security/no-user-controlled-render-locals': 'error',
|
|
113
88
|
'express-security/no-static-root-exposure': 'error',
|
|
114
89
|
'express-security/require-case-insensitive-path-guard': 'warn',
|
|
115
90
|
'express-security/require-query-type-guard': 'warn',
|
|
91
|
+
'express-security/no-disabled-helmet-protections': 'error',
|
|
92
|
+
'express-security/require-strict-transport-security': 'error',
|
|
93
|
+
'express-security/no-unsafe-csp-directives': 'error',
|
|
94
|
+
'express-security/no-permissive-trust-proxy': 'error',
|
|
95
|
+
'express-security/require-route-authentication': 'warn',
|
|
96
|
+
'express-security/no-client-controlled-authorization': 'warn',
|
|
97
|
+
'express-security/no-idor-resource-access': 'warn',
|
|
116
98
|
};
|
|
117
|
-
/**
|
|
118
|
-
* Preset configurations for Express security rules
|
|
119
|
-
*/
|
|
120
99
|
exports.configs = {
|
|
121
|
-
/**
|
|
122
|
-
* Recommended security configuration
|
|
123
|
-
*
|
|
124
|
-
* Enables all security rules with sensible severity levels
|
|
125
|
-
*/
|
|
126
100
|
recommended: {
|
|
127
101
|
plugins: {
|
|
128
102
|
'express-security': exports.plugin,
|
|
129
103
|
},
|
|
130
104
|
rules: recommendedRules,
|
|
131
105
|
},
|
|
132
|
-
/**
|
|
133
|
-
* Strict security configuration
|
|
134
|
-
*
|
|
135
|
-
* All security rules set to 'error' for maximum protection
|
|
136
|
-
*/
|
|
137
106
|
strict: {
|
|
138
107
|
plugins: {
|
|
139
108
|
'express-security': exports.plugin,
|
|
@@ -143,28 +112,22 @@ exports.configs = {
|
|
|
143
112
|
'error',
|
|
144
113
|
])),
|
|
145
114
|
},
|
|
146
|
-
/**
|
|
147
|
-
* API security configuration
|
|
148
|
-
*
|
|
149
|
-
* HTTP/API security rules only
|
|
150
|
-
*/
|
|
151
115
|
api: {
|
|
152
116
|
plugins: {
|
|
153
117
|
'express-security': exports.plugin,
|
|
154
118
|
},
|
|
155
119
|
rules: {
|
|
156
120
|
'express-security/require-helmet': 'error',
|
|
121
|
+
'express-security/no-disabled-helmet-protections': 'error',
|
|
122
|
+
'express-security/require-strict-transport-security': 'error',
|
|
123
|
+
'express-security/no-unsafe-csp-directives': 'error',
|
|
124
|
+
'express-security/no-permissive-trust-proxy': 'error',
|
|
157
125
|
'express-security/no-permissive-cors': 'error',
|
|
158
126
|
'express-security/require-csrf-protection': 'error',
|
|
159
127
|
'express-security/no-insecure-cookie-options': 'error',
|
|
160
128
|
'express-security/require-rate-limiting': 'error',
|
|
161
129
|
},
|
|
162
130
|
},
|
|
163
|
-
/**
|
|
164
|
-
* GraphQL security configuration
|
|
165
|
-
*
|
|
166
|
-
* GraphQL-specific security rules only
|
|
167
|
-
*/
|
|
168
131
|
graphql: {
|
|
169
132
|
plugins: {
|
|
170
133
|
'express-security': exports.plugin,
|
|
@@ -174,7 +137,4 @@ exports.configs = {
|
|
|
174
137
|
},
|
|
175
138
|
},
|
|
176
139
|
};
|
|
177
|
-
/**
|
|
178
|
-
* Default export for ESLint plugin
|
|
179
|
-
*/
|
|
180
140
|
exports.default = exports.plugin;
|
package/src/oxlint.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
import { plugin } from './index';
|
|
20
|
-
export = plugin;
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
package/src/oxlint.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
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
|
-
/**
|
|
8
|
-
* oxlint sub-export.
|
|
9
|
-
*
|
|
10
|
-
* Consumers wire oxlint to this entry via:
|
|
11
|
-
* { "jsPlugins": ["eslint-plugin-express-security/oxlint"] }
|
|
12
|
-
*
|
|
13
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-express-security/oxlint')` and reads
|
|
14
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
15
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
16
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
17
|
-
*
|
|
18
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
19
|
-
*/
|
|
20
2
|
const index_1 = require("./index");
|
|
21
3
|
module.exports = index_1.plugin;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noClientControlledAuthorization = void 0;
|
|
4
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
+
const CLIENT_CONTAINERS = new Set([
|
|
6
|
+
'body',
|
|
7
|
+
'query',
|
|
8
|
+
'params',
|
|
9
|
+
'headers',
|
|
10
|
+
'cookies',
|
|
11
|
+
]);
|
|
12
|
+
const REQUEST_RECEIVER = /^(req|request)$/i;
|
|
13
|
+
const AUTHZ_PROPERTIES = new Set([
|
|
14
|
+
'role',
|
|
15
|
+
'roles',
|
|
16
|
+
'admin',
|
|
17
|
+
'isadmin',
|
|
18
|
+
'is_admin',
|
|
19
|
+
'superuser',
|
|
20
|
+
'issuperuser',
|
|
21
|
+
'permission',
|
|
22
|
+
'permissions',
|
|
23
|
+
'scope',
|
|
24
|
+
'scopes',
|
|
25
|
+
'privilege',
|
|
26
|
+
'privileges',
|
|
27
|
+
'usertype',
|
|
28
|
+
'user_type',
|
|
29
|
+
'accesslevel',
|
|
30
|
+
'access_level',
|
|
31
|
+
'acl',
|
|
32
|
+
'claims',
|
|
33
|
+
'grants',
|
|
34
|
+
'userid',
|
|
35
|
+
'user_id',
|
|
36
|
+
'ownerid',
|
|
37
|
+
'owner_id',
|
|
38
|
+
'owner',
|
|
39
|
+
'accountid',
|
|
40
|
+
'account_id',
|
|
41
|
+
'tenantid',
|
|
42
|
+
'tenant_id',
|
|
43
|
+
'orgid',
|
|
44
|
+
'org_id',
|
|
45
|
+
]);
|
|
46
|
+
const AUTHZ_HEADER = /^x-.*(role|admin|user|auth|permission|scope|tenant|account|owner)/i;
|
|
47
|
+
function staticPropertyName(node) {
|
|
48
|
+
if (!node.computed && node.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
|
|
49
|
+
return node.property.name;
|
|
50
|
+
}
|
|
51
|
+
if (node.computed &&
|
|
52
|
+
node.property.type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
|
|
53
|
+
typeof node.property.value === 'string') {
|
|
54
|
+
return node.property.value;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
function clientContainerOf(node) {
|
|
59
|
+
const { object } = node;
|
|
60
|
+
if (object.type !== eslint_devkit_1.AST_NODE_TYPES.MemberExpression)
|
|
61
|
+
return null;
|
|
62
|
+
const container = staticPropertyName(object);
|
|
63
|
+
if (!container || !CLIENT_CONTAINERS.has(container))
|
|
64
|
+
return null;
|
|
65
|
+
const root = object.object;
|
|
66
|
+
if (root.type === eslint_devkit_1.AST_NODE_TYPES.Identifier && REQUEST_RECEIVER.test(root.name)) {
|
|
67
|
+
return container;
|
|
68
|
+
}
|
|
69
|
+
if (root.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
|
|
70
|
+
root.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
71
|
+
REQUEST_RECEIVER.test(root.property.name)) {
|
|
72
|
+
return container;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function isAuthorizationDecision(node) {
|
|
77
|
+
let current = node;
|
|
78
|
+
let parent = node.parent;
|
|
79
|
+
for (let depth = 0; parent && depth < 4; depth += 1) {
|
|
80
|
+
switch (parent.type) {
|
|
81
|
+
case eslint_devkit_1.AST_NODE_TYPES.BinaryExpression:
|
|
82
|
+
if (parent.operator === '===' ||
|
|
83
|
+
parent.operator === '==' ||
|
|
84
|
+
parent.operator === '!==' ||
|
|
85
|
+
parent.operator === '!=') {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case eslint_devkit_1.AST_NODE_TYPES.IfStatement:
|
|
90
|
+
case eslint_devkit_1.AST_NODE_TYPES.ConditionalExpression:
|
|
91
|
+
if (parent.test === current)
|
|
92
|
+
return true;
|
|
93
|
+
break;
|
|
94
|
+
case eslint_devkit_1.AST_NODE_TYPES.SwitchStatement:
|
|
95
|
+
if (parent.discriminant === current)
|
|
96
|
+
return true;
|
|
97
|
+
break;
|
|
98
|
+
case eslint_devkit_1.AST_NODE_TYPES.LogicalExpression:
|
|
99
|
+
if (parent.operator === '??')
|
|
100
|
+
break;
|
|
101
|
+
return true;
|
|
102
|
+
case eslint_devkit_1.AST_NODE_TYPES.UnaryExpression:
|
|
103
|
+
if (parent.operator === '!')
|
|
104
|
+
return true;
|
|
105
|
+
break;
|
|
106
|
+
case eslint_devkit_1.AST_NODE_TYPES.CallExpression:
|
|
107
|
+
if (parent.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
|
|
108
|
+
parent.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
109
|
+
(parent.callee.property.name === 'includes' ||
|
|
110
|
+
parent.callee.property.name === 'some')) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
default:
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
current = parent;
|
|
118
|
+
parent = parent.parent;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
exports.noClientControlledAuthorization = (0, eslint_devkit_1.createRule)({
|
|
123
|
+
name: 'no-client-controlled-authorization',
|
|
124
|
+
meta: {
|
|
125
|
+
type: 'problem',
|
|
126
|
+
docs: {
|
|
127
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-express-security/docs/rules/no-client-controlled-authorization.md',
|
|
128
|
+
description: 'Disallow authorization decisions taken on request-supplied role, permission or identity values',
|
|
129
|
+
cwe: 'CWE-863',
|
|
130
|
+
cvss: 8.1,
|
|
131
|
+
confidence: 'medium',
|
|
132
|
+
},
|
|
133
|
+
messages: {
|
|
134
|
+
clientControlledAuthorization: (0, eslint_devkit_1.formatLLMMessage)({
|
|
135
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
136
|
+
issueName: 'Authorization Decided On Client Input (CWE-863)',
|
|
137
|
+
cwe: 'CWE-863',
|
|
138
|
+
cvss: 8.1,
|
|
139
|
+
description: 'The access decision reads {{expression}} — a value the caller sends. The check runs, and passes for anyone who sets the field.',
|
|
140
|
+
severity: 'HIGH',
|
|
141
|
+
fix: 'Read the attribute from the server-side session or verified token instead: req.user.{{property}} / req.auth.{{property}}.',
|
|
142
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/863.html',
|
|
143
|
+
}),
|
|
144
|
+
},
|
|
145
|
+
schema: [
|
|
146
|
+
{
|
|
147
|
+
type: 'object',
|
|
148
|
+
properties: {
|
|
149
|
+
extraProperties: {
|
|
150
|
+
type: 'array',
|
|
151
|
+
items: { type: 'string' },
|
|
152
|
+
description: 'Extra property names treated as authorization attributes',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
additionalProperties: false,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
defaultOptions: [{}],
|
|
160
|
+
create(context, [options]) {
|
|
161
|
+
const { extraProperties } = options;
|
|
162
|
+
const extra = new Set((extraProperties ?? []).map((name) => name.toLowerCase()));
|
|
163
|
+
function isAuthorizationAttribute(property, container) {
|
|
164
|
+
const normalized = property.toLowerCase();
|
|
165
|
+
if (AUTHZ_PROPERTIES.has(normalized))
|
|
166
|
+
return true;
|
|
167
|
+
if (extra.has(normalized))
|
|
168
|
+
return true;
|
|
169
|
+
return container === 'headers' && AUTHZ_HEADER.test(property);
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
MemberExpression(node) {
|
|
173
|
+
const property = staticPropertyName(node);
|
|
174
|
+
if (!property)
|
|
175
|
+
return;
|
|
176
|
+
const container = clientContainerOf(node);
|
|
177
|
+
if (!container)
|
|
178
|
+
return;
|
|
179
|
+
if (!isAuthorizationAttribute(property, container))
|
|
180
|
+
return;
|
|
181
|
+
if (!isAuthorizationDecision(node))
|
|
182
|
+
return;
|
|
183
|
+
context.report({
|
|
184
|
+
node,
|
|
185
|
+
messageId: 'clientControlledAuthorization',
|
|
186
|
+
data: {
|
|
187
|
+
expression: context.sourceCode.getText(node),
|
|
188
|
+
property,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
});
|