eslint-plugin-jwt-security 2.3.0 → 2.3.2
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 +5 -5
- package/package.json +16 -24
- package/src/index.d.ts +17 -0
- package/src/index.js +1 -0
- package/src/oxlint.d.ts +17 -0
- package/src/oxlint.js +1 -0
- package/src/rules/no-algorithm-confusion/index.js +1 -0
- package/src/rules/no-algorithm-none/index.js +1 -0
- package/src/rules/no-decode-without-verify/index.js +1 -0
- package/src/rules/no-hardcoded-secret/index.js +1 -0
- package/src/rules/no-sensitive-payload/index.js +1 -0
- package/src/rules/no-timestamp-manipulation/index.js +1 -0
- package/src/rules/no-weak-secret/index.js +1 -0
- package/src/rules/require-algorithm-whitelist/index.js +1 -0
- package/src/rules/require-audience-validation/index.js +1 -0
- package/src/rules/require-expiration/index.js +1 -0
- package/src/rules/require-issued-at/index.js +1 -0
- package/src/rules/require-issuer-validation/index.js +1 -0
- package/src/rules/require-max-age/index.js +1 -0
- package/src/types/index.js +1 -0
- package/src/utils/index.js +1 -0
- package/AGENTS.md +0 -102
- package/CHANGELOG.md +0 -161
- package/dist/AGENTS.md +0 -102
- package/dist/CHANGELOG.md +0 -161
- package/dist/LICENSE +0 -23
- package/dist/README.md +0 -158
- package/dist/package.json +0 -125
- package/dist/src/index.d.ts +0 -101
- package/dist/src/index.js +0 -171
- package/dist/src/oxlint.d.ts +0 -20
- package/dist/src/oxlint.js +0 -21
- package/dist/src/rules/no-algorithm-confusion/index.d.ts +0 -24
- package/dist/src/rules/no-algorithm-confusion/index.js +0 -165
- package/dist/src/rules/no-algorithm-none/index.d.ts +0 -24
- package/dist/src/rules/no-algorithm-none/index.js +0 -222
- package/dist/src/rules/no-decode-without-verify/index.d.ts +0 -23
- package/dist/src/rules/no-decode-without-verify/index.js +0 -131
- package/dist/src/rules/no-hardcoded-secret/index.d.ts +0 -23
- package/dist/src/rules/no-hardcoded-secret/index.js +0 -189
- package/dist/src/rules/no-sensitive-payload/index.d.ts +0 -20
- package/dist/src/rules/no-sensitive-payload/index.js +0 -103
- package/dist/src/rules/no-timestamp-manipulation/index.d.ts +0 -23
- package/dist/src/rules/no-timestamp-manipulation/index.js +0 -97
- package/dist/src/rules/no-weak-secret/index.d.ts +0 -23
- package/dist/src/rules/no-weak-secret/index.js +0 -165
- package/dist/src/rules/require-algorithm-whitelist/index.d.ts +0 -24
- package/dist/src/rules/require-algorithm-whitelist/index.js +0 -113
- package/dist/src/rules/require-audience-validation/index.d.ts +0 -20
- package/dist/src/rules/require-audience-validation/index.js +0 -100
- package/dist/src/rules/require-expiration/index.d.ts +0 -23
- package/dist/src/rules/require-expiration/index.js +0 -136
- package/dist/src/rules/require-issued-at/index.d.ts +0 -23
- package/dist/src/rules/require-issued-at/index.js +0 -113
- package/dist/src/rules/require-issuer-validation/index.d.ts +0 -20
- package/dist/src/rules/require-issuer-validation/index.js +0 -100
- package/dist/src/rules/require-max-age/index.d.ts +0 -24
- package/dist/src/rules/require-max-age/index.js +0 -93
- package/dist/src/types/index.js +0 -7
- package/dist/src/utils/index.d.ts +0 -98
- package/dist/src/utils/index.js +0 -238
- package/src/__compatibility__/jwt-interface.spec.ts +0 -192
- package/src/index.test.ts +0 -47
- package/src/index.ts +0 -209
- package/src/oxlint.test.ts +0 -61
- package/src/oxlint.ts +0 -23
- package/src/rules/no-algorithm-confusion/index.ts +0 -208
- package/src/rules/no-algorithm-confusion/no-algorithm-confusion.test.ts +0 -106
- package/src/rules/no-algorithm-none/index.ts +0 -270
- package/src/rules/no-algorithm-none/no-algorithm-none.test.ts +0 -146
- package/src/rules/no-decode-without-verify/index.ts +0 -162
- package/src/rules/no-decode-without-verify/no-decode-without-verify.test.ts +0 -76
- package/src/rules/no-hardcoded-secret/index.ts +0 -230
- package/src/rules/no-hardcoded-secret/no-hardcoded-secret.test.ts +0 -97
- package/src/rules/no-sensitive-payload/index.ts +0 -123
- package/src/rules/no-sensitive-payload/no-sensitive-payload.test.ts +0 -157
- package/src/rules/no-timestamp-manipulation/index.ts +0 -118
- package/src/rules/no-timestamp-manipulation/no-timestamp-manipulation.test.ts +0 -54
- package/src/rules/no-weak-secret/index.ts +0 -204
- package/src/rules/no-weak-secret/no-weak-secret.test.ts +0 -114
- package/src/rules/require-algorithm-whitelist/index.ts +0 -145
- package/src/rules/require-algorithm-whitelist/require-algorithm-whitelist.test.ts +0 -72
- package/src/rules/require-audience-validation/index.ts +0 -120
- package/src/rules/require-audience-validation/require-audience-validation.test.ts +0 -68
- package/src/rules/require-expiration/index.ts +0 -170
- package/src/rules/require-expiration/require-expiration.test.ts +0 -135
- package/src/rules/require-issued-at/index.ts +0 -143
- package/src/rules/require-issued-at/require-issued-at.test.ts +0 -64
- package/src/rules/require-issuer-validation/index.ts +0 -120
- package/src/rules/require-issuer-validation/require-issuer-validation.test.ts +0 -68
- package/src/rules/require-max-age/index.ts +0 -117
- package/src/rules/require-max-age/require-max-age.test.ts +0 -69
- package/src/tests/coverage-dual-layer.test.ts +0 -323
- package/src/types/index.ts +0 -107
- package/src/utils/index.ts +0 -285
- package/src/utils/utils.test.ts +0 -324
- /package/{dist/src → src}/types/index.d.ts +0 -0
package/dist/src/index.d.ts
DELETED
|
@@ -1,101 +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-plugin-jwt-security
|
|
8
|
-
*
|
|
9
|
-
* Comprehensive JWT security ESLint plugin for Node.js applications.
|
|
10
|
-
* Detects vulnerabilities across jsonwebtoken, jose, express-jwt,
|
|
11
|
-
* @nestjs/jwt, jwks-rsa, and jwt-decode libraries.
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - Algorithm confusion attack detection (CVE-2022-23540)
|
|
15
|
-
* - "Back to the Future" replay attack prevention (LightSEC 2025)
|
|
16
|
-
* - Signature verification enforcement
|
|
17
|
-
* - Weak secret detection
|
|
18
|
-
* - Expiration and claim validation
|
|
19
|
-
* - AI-assisted fix guidance with CWE references
|
|
20
|
-
*
|
|
21
|
-
* @see https://tools.ietf.org/html/rfc8725
|
|
22
|
-
* @see https://securitypattern.com/post/jwt-back-to-the-future
|
|
23
|
-
*/
|
|
24
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
25
|
-
import { noAlgorithmNone } from './rules/no-algorithm-none';
|
|
26
|
-
import { noAlgorithmConfusion } from './rules/no-algorithm-confusion';
|
|
27
|
-
import { requireAlgorithmWhitelist } from './rules/require-algorithm-whitelist';
|
|
28
|
-
import { noDecodeWithoutVerify } from './rules/no-decode-without-verify';
|
|
29
|
-
import { noWeakSecret } from './rules/no-weak-secret';
|
|
30
|
-
import { requireExpiration } from './rules/require-expiration';
|
|
31
|
-
import { noHardcodedSecret } from './rules/no-hardcoded-secret';
|
|
32
|
-
import { requireIssuedAt } from './rules/require-issued-at';
|
|
33
|
-
import { requireIssuerValidation } from './rules/require-issuer-validation';
|
|
34
|
-
import { requireAudienceValidation } from './rules/require-audience-validation';
|
|
35
|
-
import { noTimestampManipulation } from './rules/no-timestamp-manipulation';
|
|
36
|
-
import { requireMaxAge } from './rules/require-max-age';
|
|
37
|
-
import { noSensitivePayload } from './rules/no-sensitive-payload';
|
|
38
|
-
/**
|
|
39
|
-
* Collection of all JWT security ESLint rules (13 rules)
|
|
40
|
-
*/
|
|
41
|
-
export declare const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
42
|
-
/**
|
|
43
|
-
* ESLint Plugin object
|
|
44
|
-
*/
|
|
45
|
-
export declare const plugin: TSESLint.FlatConfig.Plugin;
|
|
46
|
-
/**
|
|
47
|
-
* Configuration presets for flat config
|
|
48
|
-
*/
|
|
49
|
-
export declare const configs: {
|
|
50
|
-
/**
|
|
51
|
-
* Flagship preset — the rule from this plugin in the ecosystem-wide
|
|
52
|
-
* flagship list (`.agent/flagship-rules.md`). Use this when you want
|
|
53
|
-
* the highest-signal JWT subset shippable in CI gates.
|
|
54
|
-
*/
|
|
55
|
-
flagship: {
|
|
56
|
-
plugins: {
|
|
57
|
-
jwt: TSESLint.FlatConfig.Plugin;
|
|
58
|
-
};
|
|
59
|
-
rules: {
|
|
60
|
-
'jwt/no-algorithm-none': "error";
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Recommended preset - balanced security
|
|
65
|
-
*/
|
|
66
|
-
recommended: {
|
|
67
|
-
plugins: {
|
|
68
|
-
jwt: TSESLint.FlatConfig.Plugin;
|
|
69
|
-
};
|
|
70
|
-
rules: Record<string, TSESLint.SharedConfig.RuleEntry>;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Strict preset - maximum security (includes 2025 research)
|
|
74
|
-
*/
|
|
75
|
-
strict: {
|
|
76
|
-
plugins: {
|
|
77
|
-
jwt: TSESLint.FlatConfig.Plugin;
|
|
78
|
-
};
|
|
79
|
-
rules: Record<string, TSESLint.SharedConfig.RuleEntry>;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Legacy preset - migration mode
|
|
83
|
-
*/
|
|
84
|
-
legacy: {
|
|
85
|
-
plugins: {
|
|
86
|
-
jwt: TSESLint.FlatConfig.Plugin;
|
|
87
|
-
};
|
|
88
|
-
rules: Record<string, TSESLint.SharedConfig.RuleEntry>;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* All rules preset
|
|
92
|
-
*/
|
|
93
|
-
all: {
|
|
94
|
-
plugins: {
|
|
95
|
-
jwt: TSESLint.FlatConfig.Plugin;
|
|
96
|
-
};
|
|
97
|
-
rules: Record<string, TSESLint.SharedConfig.RuleEntry>;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
export default plugin;
|
|
101
|
-
export { noAlgorithmNone, noAlgorithmConfusion, requireAlgorithmWhitelist, noDecodeWithoutVerify, noWeakSecret, requireExpiration, noHardcodedSecret, requireIssuedAt, requireIssuerValidation, requireAudienceValidation, noTimestampManipulation, requireMaxAge, noSensitivePayload, };
|
package/dist/src/index.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
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.noSensitivePayload = exports.requireMaxAge = exports.noTimestampManipulation = exports.requireAudienceValidation = exports.requireIssuerValidation = exports.requireIssuedAt = exports.noHardcodedSecret = exports.requireExpiration = exports.noWeakSecret = exports.noDecodeWithoutVerify = exports.requireAlgorithmWhitelist = exports.noAlgorithmConfusion = exports.noAlgorithmNone = exports.configs = exports.plugin = exports.rules = void 0;
|
|
9
|
-
// Import rules - Core Security
|
|
10
|
-
const no_algorithm_none_1 = require("./rules/no-algorithm-none");
|
|
11
|
-
Object.defineProperty(exports, "noAlgorithmNone", { enumerable: true, get: function () { return no_algorithm_none_1.noAlgorithmNone; } });
|
|
12
|
-
const no_algorithm_confusion_1 = require("./rules/no-algorithm-confusion");
|
|
13
|
-
Object.defineProperty(exports, "noAlgorithmConfusion", { enumerable: true, get: function () { return no_algorithm_confusion_1.noAlgorithmConfusion; } });
|
|
14
|
-
const require_algorithm_whitelist_1 = require("./rules/require-algorithm-whitelist");
|
|
15
|
-
Object.defineProperty(exports, "requireAlgorithmWhitelist", { enumerable: true, get: function () { return require_algorithm_whitelist_1.requireAlgorithmWhitelist; } });
|
|
16
|
-
const no_decode_without_verify_1 = require("./rules/no-decode-without-verify");
|
|
17
|
-
Object.defineProperty(exports, "noDecodeWithoutVerify", { enumerable: true, get: function () { return no_decode_without_verify_1.noDecodeWithoutVerify; } });
|
|
18
|
-
const no_weak_secret_1 = require("./rules/no-weak-secret");
|
|
19
|
-
Object.defineProperty(exports, "noWeakSecret", { enumerable: true, get: function () { return no_weak_secret_1.noWeakSecret; } });
|
|
20
|
-
const require_expiration_1 = require("./rules/require-expiration");
|
|
21
|
-
Object.defineProperty(exports, "requireExpiration", { enumerable: true, get: function () { return require_expiration_1.requireExpiration; } });
|
|
22
|
-
const no_hardcoded_secret_1 = require("./rules/no-hardcoded-secret");
|
|
23
|
-
Object.defineProperty(exports, "noHardcodedSecret", { enumerable: true, get: function () { return no_hardcoded_secret_1.noHardcodedSecret; } });
|
|
24
|
-
// Import rules - 2025 Vulnerability Research
|
|
25
|
-
const require_issued_at_1 = require("./rules/require-issued-at");
|
|
26
|
-
Object.defineProperty(exports, "requireIssuedAt", { enumerable: true, get: function () { return require_issued_at_1.requireIssuedAt; } });
|
|
27
|
-
const require_issuer_validation_1 = require("./rules/require-issuer-validation");
|
|
28
|
-
Object.defineProperty(exports, "requireIssuerValidation", { enumerable: true, get: function () { return require_issuer_validation_1.requireIssuerValidation; } });
|
|
29
|
-
const require_audience_validation_1 = require("./rules/require-audience-validation");
|
|
30
|
-
Object.defineProperty(exports, "requireAudienceValidation", { enumerable: true, get: function () { return require_audience_validation_1.requireAudienceValidation; } });
|
|
31
|
-
const no_timestamp_manipulation_1 = require("./rules/no-timestamp-manipulation");
|
|
32
|
-
Object.defineProperty(exports, "noTimestampManipulation", { enumerable: true, get: function () { return no_timestamp_manipulation_1.noTimestampManipulation; } });
|
|
33
|
-
const require_max_age_1 = require("./rules/require-max-age");
|
|
34
|
-
Object.defineProperty(exports, "requireMaxAge", { enumerable: true, get: function () { return require_max_age_1.requireMaxAge; } });
|
|
35
|
-
const no_sensitive_payload_1 = require("./rules/no-sensitive-payload");
|
|
36
|
-
Object.defineProperty(exports, "noSensitivePayload", { enumerable: true, get: function () { return no_sensitive_payload_1.noSensitivePayload; } });
|
|
37
|
-
/**
|
|
38
|
-
* Collection of all JWT security ESLint rules (13 rules)
|
|
39
|
-
*/
|
|
40
|
-
exports.rules = {
|
|
41
|
-
// Core Security Rules
|
|
42
|
-
'no-algorithm-none': no_algorithm_none_1.noAlgorithmNone,
|
|
43
|
-
'no-algorithm-confusion': no_algorithm_confusion_1.noAlgorithmConfusion,
|
|
44
|
-
'require-algorithm-whitelist': require_algorithm_whitelist_1.requireAlgorithmWhitelist,
|
|
45
|
-
'no-decode-without-verify': no_decode_without_verify_1.noDecodeWithoutVerify,
|
|
46
|
-
'no-weak-secret': no_weak_secret_1.noWeakSecret,
|
|
47
|
-
'require-expiration': require_expiration_1.requireExpiration,
|
|
48
|
-
'no-hardcoded-secret': no_hardcoded_secret_1.noHardcodedSecret,
|
|
49
|
-
// 2025 Vulnerability Research - "Back to the Future" & Replay Prevention
|
|
50
|
-
'require-issued-at': require_issued_at_1.requireIssuedAt,
|
|
51
|
-
'require-issuer-validation': require_issuer_validation_1.requireIssuerValidation,
|
|
52
|
-
'require-audience-validation': require_audience_validation_1.requireAudienceValidation,
|
|
53
|
-
'no-timestamp-manipulation': no_timestamp_manipulation_1.noTimestampManipulation,
|
|
54
|
-
'require-max-age': require_max_age_1.requireMaxAge,
|
|
55
|
-
'no-sensitive-payload': no_sensitive_payload_1.noSensitivePayload,
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* ESLint Plugin object
|
|
59
|
-
*/
|
|
60
|
-
exports.plugin = {
|
|
61
|
-
meta: {
|
|
62
|
-
name: 'eslint-plugin-jwt-security',
|
|
63
|
-
version: '2.2.9',
|
|
64
|
-
},
|
|
65
|
-
rules: exports.rules,
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Recommended configuration - baseline security
|
|
69
|
-
* Critical rules as errors, high as warnings
|
|
70
|
-
*/
|
|
71
|
-
const recommendedRules = {
|
|
72
|
-
// CRITICAL - Algorithm attacks
|
|
73
|
-
'jwt/no-algorithm-none': 'error',
|
|
74
|
-
'jwt/no-algorithm-confusion': 'error',
|
|
75
|
-
// HIGH - Verification and secrets
|
|
76
|
-
'jwt/require-algorithm-whitelist': 'error',
|
|
77
|
-
'jwt/no-decode-without-verify': 'error',
|
|
78
|
-
'jwt/no-weak-secret': 'error',
|
|
79
|
-
'jwt/no-hardcoded-secret': 'error',
|
|
80
|
-
'jwt/no-timestamp-manipulation': 'error', // LightSEC 2025
|
|
81
|
-
// MEDIUM - Best practices
|
|
82
|
-
'jwt/require-expiration': 'error',
|
|
83
|
-
'jwt/no-sensitive-payload': 'warn',
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Strict configuration - maximum security (2025 research)
|
|
87
|
-
* All rules as errors - includes replay attack prevention
|
|
88
|
-
*/
|
|
89
|
-
const strictRules = {
|
|
90
|
-
// All core rules as errors
|
|
91
|
-
'jwt/no-algorithm-none': 'error',
|
|
92
|
-
'jwt/no-algorithm-confusion': 'error',
|
|
93
|
-
'jwt/require-algorithm-whitelist': 'error',
|
|
94
|
-
'jwt/no-decode-without-verify': 'error',
|
|
95
|
-
'jwt/no-weak-secret': 'error',
|
|
96
|
-
'jwt/no-hardcoded-secret': 'error',
|
|
97
|
-
'jwt/require-expiration': 'error',
|
|
98
|
-
// 2025 Research - Full replay attack prevention
|
|
99
|
-
'jwt/require-issued-at': 'error',
|
|
100
|
-
'jwt/require-issuer-validation': 'error',
|
|
101
|
-
'jwt/require-audience-validation': 'error',
|
|
102
|
-
'jwt/no-timestamp-manipulation': 'error',
|
|
103
|
-
'jwt/require-max-age': 'error',
|
|
104
|
-
'jwt/no-sensitive-payload': 'error',
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Legacy configuration - migration mode
|
|
108
|
-
* Only critical rules enabled
|
|
109
|
-
*/
|
|
110
|
-
const legacyRules = {
|
|
111
|
-
// Only most critical rules
|
|
112
|
-
'jwt/no-algorithm-none': 'error',
|
|
113
|
-
'jwt/no-algorithm-confusion': 'error',
|
|
114
|
-
'jwt/no-hardcoded-secret': 'warn',
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Configuration presets for flat config
|
|
118
|
-
*/
|
|
119
|
-
exports.configs = {
|
|
120
|
-
/**
|
|
121
|
-
* Flagship preset — the rule from this plugin in the ecosystem-wide
|
|
122
|
-
* flagship list (`.agent/flagship-rules.md`). Use this when you want
|
|
123
|
-
* the highest-signal JWT subset shippable in CI gates.
|
|
124
|
-
*/
|
|
125
|
-
flagship: {
|
|
126
|
-
plugins: {
|
|
127
|
-
jwt: exports.plugin,
|
|
128
|
-
},
|
|
129
|
-
rules: {
|
|
130
|
-
'jwt/no-algorithm-none': 'error',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
/**
|
|
134
|
-
* Recommended preset - balanced security
|
|
135
|
-
*/
|
|
136
|
-
recommended: {
|
|
137
|
-
plugins: {
|
|
138
|
-
jwt: exports.plugin,
|
|
139
|
-
},
|
|
140
|
-
rules: recommendedRules,
|
|
141
|
-
},
|
|
142
|
-
/**
|
|
143
|
-
* Strict preset - maximum security (includes 2025 research)
|
|
144
|
-
*/
|
|
145
|
-
strict: {
|
|
146
|
-
plugins: {
|
|
147
|
-
jwt: exports.plugin,
|
|
148
|
-
},
|
|
149
|
-
rules: strictRules,
|
|
150
|
-
},
|
|
151
|
-
/**
|
|
152
|
-
* Legacy preset - migration mode
|
|
153
|
-
*/
|
|
154
|
-
legacy: {
|
|
155
|
-
plugins: {
|
|
156
|
-
jwt: exports.plugin,
|
|
157
|
-
},
|
|
158
|
-
rules: legacyRules,
|
|
159
|
-
},
|
|
160
|
-
/**
|
|
161
|
-
* All rules preset
|
|
162
|
-
*/
|
|
163
|
-
all: {
|
|
164
|
-
plugins: {
|
|
165
|
-
jwt: exports.plugin,
|
|
166
|
-
},
|
|
167
|
-
rules: strictRules,
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
// Default export for flat config usage
|
|
171
|
-
exports.default = exports.plugin;
|
package/dist/src/oxlint.d.ts
DELETED
|
@@ -1,20 +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
|
-
* oxlint sub-export.
|
|
8
|
-
*
|
|
9
|
-
* Consumers wire oxlint to this entry via:
|
|
10
|
-
* { "jsPlugins": ["eslint-plugin-jwt-security/oxlint"] }
|
|
11
|
-
*
|
|
12
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-jwt-security/oxlint')` and reads
|
|
13
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
14
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
15
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
16
|
-
*
|
|
17
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
18
|
-
*/
|
|
19
|
-
import { plugin } from './index';
|
|
20
|
-
export = plugin;
|
package/dist/src/oxlint.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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-jwt-security/oxlint"] }
|
|
12
|
-
*
|
|
13
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-jwt-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
|
-
const index_1 = require("./index");
|
|
21
|
-
module.exports = index_1.plugin;
|
|
@@ -1,24 +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-algorithm-confusion
|
|
8
|
-
*
|
|
9
|
-
* Detects algorithm confusion attacks where symmetric algorithms (HS256/384/512)
|
|
10
|
-
* are used with asymmetric keys (public keys). This allows attackers to sign
|
|
11
|
-
* tokens using the public key as an HMAC secret.
|
|
12
|
-
*
|
|
13
|
-
* CWE-347: Improper Verification of Cryptographic Signature
|
|
14
|
-
*
|
|
15
|
-
* @see https://portswigger.net/web-security/jwt/algorithm-confusion
|
|
16
|
-
*/
|
|
17
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
18
|
-
import type { NoAlgorithmConfusionOptions } from '../../types';
|
|
19
|
-
type MessageIds = 'algorithmConfusion' | 'symmetricWithPublicKey' | 'useAsymmetricAlgorithm';
|
|
20
|
-
type RuleOptions = [NoAlgorithmConfusionOptions?];
|
|
21
|
-
export declare const noAlgorithmConfusion: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
export default noAlgorithmConfusion;
|
|
@@ -1,165 +0,0 @@
|
|
|
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.noAlgorithmConfusion = void 0;
|
|
9
|
-
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
-
const utils_1 = require("../../utils");
|
|
11
|
-
// Patterns that indicate a public key
|
|
12
|
-
const PUBLIC_KEY_PATTERNS = [
|
|
13
|
-
/public/i,
|
|
14
|
-
/\.pub$/,
|
|
15
|
-
/\.pem$/,
|
|
16
|
-
/-----BEGIN PUBLIC KEY-----/,
|
|
17
|
-
/-----BEGIN RSA PUBLIC KEY-----/,
|
|
18
|
-
/-----BEGIN EC PUBLIC KEY-----/,
|
|
19
|
-
/getPublicKey/i,
|
|
20
|
-
/publicKey/i,
|
|
21
|
-
/jwks/i,
|
|
22
|
-
];
|
|
23
|
-
exports.noAlgorithmConfusion = (0, eslint_devkit_1.createRule)({
|
|
24
|
-
name: 'no-algorithm-confusion',
|
|
25
|
-
meta: {
|
|
26
|
-
type: 'problem',
|
|
27
|
-
docs: {
|
|
28
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-jwt-security/docs/rules/no-algorithm-confusion.md',
|
|
29
|
-
description: 'Prevent algorithm confusion attacks using symmetric algorithms with asymmetric keys',
|
|
30
|
-
cwe: 'CWE-347',
|
|
31
|
-
cvss: 9.5,
|
|
32
|
-
},
|
|
33
|
-
fixable: undefined,
|
|
34
|
-
hasSuggestions: false,
|
|
35
|
-
messages: {
|
|
36
|
-
algorithmConfusion: (0, eslint_devkit_1.formatLLMMessage)({
|
|
37
|
-
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
38
|
-
issueName: 'JWT Algorithm Confusion Attack',
|
|
39
|
-
cwe: 'CWE-347',
|
|
40
|
-
description: 'Symmetric algorithm (HS*) used with public key allows token forgery',
|
|
41
|
-
severity: 'CRITICAL',
|
|
42
|
-
fix: 'Use asymmetric algorithms (RS256, ES256) with public keys',
|
|
43
|
-
documentationLink: 'https://portswigger.net/web-security/jwt/algorithm-confusion',
|
|
44
|
-
}),
|
|
45
|
-
symmetricWithPublicKey: (0, eslint_devkit_1.formatLLMMessage)({
|
|
46
|
-
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
47
|
-
issueName: 'Symmetric Algorithm with Public Key',
|
|
48
|
-
cwe: 'CWE-347',
|
|
49
|
-
description: 'HS256/384/512 should only be used with shared secrets, not public keys',
|
|
50
|
-
severity: 'CRITICAL',
|
|
51
|
-
fix: 'Switch to RS256 or ES256 for asymmetric key verification',
|
|
52
|
-
documentationLink: 'https://portswigger.net/web-security/jwt/algorithm-confusion',
|
|
53
|
-
}),
|
|
54
|
-
useAsymmetricAlgorithm: (0, eslint_devkit_1.formatLLMMessage)({
|
|
55
|
-
icon: eslint_devkit_1.MessageIcons.INFO,
|
|
56
|
-
issueName: 'Use Asymmetric Algorithm',
|
|
57
|
-
description: 'Replace HS* with RS* or ES* algorithm',
|
|
58
|
-
severity: 'LOW',
|
|
59
|
-
fix: 'Use RS256 or ES256 with public key verification',
|
|
60
|
-
documentationLink: 'https://tools.ietf.org/html/rfc8725',
|
|
61
|
-
}),
|
|
62
|
-
},
|
|
63
|
-
schema: [
|
|
64
|
-
{
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: {
|
|
67
|
-
symmetricAlgorithms: {
|
|
68
|
-
type: 'array',
|
|
69
|
-
items: { type: 'string' },
|
|
70
|
-
default: ['HS256', 'HS384', 'HS512'],
|
|
71
|
-
description: 'Algorithms to flag when used with public keys',
|
|
72
|
-
},
|
|
73
|
-
trustedSanitizers: {
|
|
74
|
-
type: 'array',
|
|
75
|
-
items: { type: 'string' },
|
|
76
|
-
default: [],
|
|
77
|
-
},
|
|
78
|
-
trustedAnnotations: {
|
|
79
|
-
type: 'array',
|
|
80
|
-
items: { type: 'string' },
|
|
81
|
-
default: [],
|
|
82
|
-
},
|
|
83
|
-
strictMode: {
|
|
84
|
-
type: 'boolean',
|
|
85
|
-
default: false,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
additionalProperties: false,
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
},
|
|
92
|
-
defaultOptions: [
|
|
93
|
-
{
|
|
94
|
-
symmetricAlgorithms: ['HS256', 'HS384', 'HS512'],
|
|
95
|
-
trustedSanitizers: [],
|
|
96
|
-
trustedAnnotations: [],
|
|
97
|
-
strictMode: false,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
create(context) {
|
|
101
|
-
const options = context.options[0] ?? {};
|
|
102
|
-
const symmetricAlgSet = new Set(options.symmetricAlgorithms ?? ['HS256', 'HS384', 'HS512']);
|
|
103
|
-
const sourceCode = context.sourceCode;
|
|
104
|
-
/**
|
|
105
|
-
* Check if a node looks like a public key reference
|
|
106
|
-
*/
|
|
107
|
-
const looksLikePublicKey = (node) => {
|
|
108
|
-
const text = sourceCode.getText(node);
|
|
109
|
-
return PUBLIC_KEY_PATTERNS.some((pattern) => pattern.test(text));
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Check if algorithms include symmetric algorithms
|
|
113
|
-
*/
|
|
114
|
-
const hasSymmetricAlgorithm = (algorithms) => {
|
|
115
|
-
for (const alg of algorithms) {
|
|
116
|
-
if (symmetricAlgSet.has(alg)) {
|
|
117
|
-
return alg;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return null;
|
|
121
|
-
};
|
|
122
|
-
return {
|
|
123
|
-
CallExpression(node) {
|
|
124
|
-
// Only check verify operations
|
|
125
|
-
if (!(0, utils_1.isVerifyOperation)(node)) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
// Need at least 2 arguments: token, key
|
|
129
|
-
if (node.arguments.length < 2) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const keyArg = node.arguments[1];
|
|
133
|
-
const optionsArg = (0, utils_1.getOptionsArgument)(node, 2);
|
|
134
|
-
// Check if key looks like a public key
|
|
135
|
-
if (!looksLikePublicKey(keyArg)) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
// If there are options, check the algorithms
|
|
139
|
-
if (optionsArg) {
|
|
140
|
-
const algorithms = (0, utils_1.extractAlgorithms)(optionsArg);
|
|
141
|
-
const symmetricAlg = hasSymmetricAlgorithm(algorithms);
|
|
142
|
-
if (symmetricAlg) {
|
|
143
|
-
// Find the algorithm node for precise error location
|
|
144
|
-
for (const prop of optionsArg.properties) {
|
|
145
|
-
if (prop.type === 'Property' &&
|
|
146
|
-
prop.key.type === 'Identifier' &&
|
|
147
|
-
['algorithms', 'algorithm', 'alg'].includes(prop.key.name)) {
|
|
148
|
-
context.report({
|
|
149
|
-
node: prop.value,
|
|
150
|
-
messageId: 'algorithmConfusion',
|
|
151
|
-
data: { algorithm: symmetricAlg },
|
|
152
|
-
});
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// If no options specified but key looks like public key,
|
|
159
|
-
// and we're in verify, flag as potential issue
|
|
160
|
-
// (verification without explicit algorithm with public key is risky)
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
exports.default = exports.noAlgorithmConfusion;
|
|
@@ -1,24 +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-algorithm-none
|
|
8
|
-
*
|
|
9
|
-
* Detects attempts to use the 'none' algorithm which bypasses JWT signature verification.
|
|
10
|
-
* This is a critical vulnerability (CVE-2022-23540) that allows attackers to forge JWT tokens.
|
|
11
|
-
*
|
|
12
|
-
* CWE-347: Improper Verification of Cryptographic Signature
|
|
13
|
-
*
|
|
14
|
-
* @see https://nvd.nist.gov/vuln/detail/CVE-2022-23540
|
|
15
|
-
* @see https://tools.ietf.org/html/rfc8725
|
|
16
|
-
*/
|
|
17
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
18
|
-
import type { NoAlgorithmNoneOptions } from '../../types';
|
|
19
|
-
type MessageIds = 'algorithmNone' | 'algorithmNoneInArray' | 'emptyAlgorithms' | 'useSecureAlgorithm' | 'decodeWithoutVerify';
|
|
20
|
-
type RuleOptions = [NoAlgorithmNoneOptions?];
|
|
21
|
-
export declare const noAlgorithmNone: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
export default noAlgorithmNone;
|