@sun-asterisk/sunlint 1.3.36 → 1.3.38
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/cli.js +34 -0
- package/config/rules/enhanced-rules-registry.json +387 -98
- package/config/rules/rules-registry-generated.json +202 -174
- package/config/rules-summary.json +1 -1
- package/core/architecture-integration.js +115 -17
- package/core/cli-action-handler.js +103 -28
- package/core/cli-program.js +7 -2
- package/core/github-annotate-service.js +62 -0
- package/core/impact-integration.js +31 -16
- package/core/init-command.js +261 -0
- package/core/output-service.js +64 -10
- package/core/performance-optimizer.js +1 -1
- package/core/summary-report-service.js +46 -0
- package/core/unified-rule-registry.js +4 -3
- package/docs/DART_RULE_EXECUTION_FLOW.md +1 -1
- package/docs/REGISTRY_GENERATION_DIAGRAM.md +289 -0
- package/docs/REGISTRY_GENERATION_FLOW.md +486 -0
- package/docs/skills/CREATE_NEW_DART_RULE.md +932 -0
- package/engines/eslint-engine.js +6 -0
- package/engines/heuristic-engine.js +23 -10
- package/engines/impact/core/detectors/database-detector.js +1 -1
- package/engines/impact/core/detectors/endpoint-detector.js +1 -1
- package/engines/impact/core/report-generator.js +235 -73
- package/origin-rules/dart-en.md +4 -4
- package/origin-rules/security-en.md +470 -282
- package/package.json +1 -1
- package/rules/dart/D001_recommended_lint_rules/config.json +134 -0
- package/rules/index.js +6 -4
- package/rules/security/S001_backend_auth_communications/dart/analyzer.js +44 -0
- package/rules/security/S001_backend_auth_communications/index.js +87 -0
- package/rules/security/S001_backend_auth_communications/typescript/analyzer.js +164 -0
- package/rules/security/S002_os_command_injection/dart/analyzer.js +44 -0
- package/rules/security/S002_os_command_injection/index.js +87 -0
- package/rules/security/S002_os_command_injection/typescript/analyzer.js +194 -0
- package/rules/security/S008_svg_content_validation/dart/analyzer.js +44 -0
- package/rules/security/S008_svg_content_validation/index.js +87 -0
- package/rules/security/S008_svg_content_validation/typescript/analyzer.js +216 -0
- package/rules/security/S018_no_sensitive_browser_storage/dart/analyzer.js +44 -0
- package/rules/security/S018_no_sensitive_browser_storage/index.js +86 -0
- package/rules/security/S018_no_sensitive_browser_storage/typescript/analyzer.js +193 -0
- package/rules/security/S021_referrer_policy/dart/analyzer.js +44 -0
- package/rules/security/S021_referrer_policy/index.js +86 -0
- package/rules/security/S021_referrer_policy/typescript/analyzer.js +183 -0
- package/rules/security/S023_no_json_injection/config.json +133 -44
- package/rules/security/S023_no_json_injection/dart/analyzer.js +7 -6
- package/rules/security/S023_no_json_injection/typescript/analyzer.js +402 -126
- package/rules/security/S023_no_json_injection/typescript/ast-analyzer.js +571 -154
- package/rules/security/S026_tls_all_connections/config.json +30 -0
- package/rules/security/S026_tls_all_connections/typescript/analyzer.js +339 -0
- package/rules/security/S027_mtls_certificate_validation/config.json +30 -0
- package/rules/security/S027_mtls_certificate_validation/typescript/analyzer.js +225 -0
- package/rules/security/S035_separate_app_hostnames/config.json +28 -0
- package/rules/security/S035_separate_app_hostnames/typescript/analyzer.js +186 -0
- package/rules/security/S036_lfi_rfi_protection/config.json +2 -2
- package/rules/security/S039_tls_certificate_validation/config.json +29 -0
- package/rules/security/S039_tls_certificate_validation/typescript/analyzer.js +229 -0
- package/rules/security/S046_jwt_algorithm_allowlist/config.json +28 -0
- package/rules/security/S046_jwt_algorithm_allowlist/dart/analyzer.js +44 -0
- package/rules/security/S046_jwt_algorithm_allowlist/index.js +87 -0
- package/rules/security/S046_jwt_algorithm_allowlist/typescript/analyzer.js +235 -0
- package/rules/security/S047_oauth_pkce_protection/config.json +31 -0
- package/rules/security/S047_oauth_pkce_protection/dart/analyzer.js +44 -0
- package/rules/security/S047_oauth_pkce_protection/index.js +86 -0
- package/rules/security/S047_oauth_pkce_protection/typescript/analyzer.js +78 -0
- package/rules/security/S048_oauth_redirect_uri_validation/config.json +30 -0
- package/rules/security/S048_oauth_redirect_uri_validation/typescript/analyzer.js +278 -0
- package/rules/security/S049_short_validity_tokens/typescript/config.json +10 -3
- package/rules/security/S050_reference_tokens_entropy/config.json +28 -0
- package/rules/security/S050_reference_tokens_entropy/dart/analyzer.js +45 -0
- package/rules/security/S050_reference_tokens_entropy/index.js +86 -0
- package/rules/security/S050_reference_tokens_entropy/typescript/analyzer.js +74 -0
- package/rules/security/S053_generic_error_messages/config.json +28 -0
- package/rules/security/S053_generic_error_messages/dart/analyzer.js +45 -0
- package/rules/security/S053_generic_error_messages/index.js +86 -0
- package/rules/security/S053_generic_error_messages/typescript/analyzer.js +80 -0
- package/rules/security/S055_content_type_validation/typescript/symbol-based-analyzer.js +64 -2
- package/rules/security/S059_disable_debug_mode/config.json +28 -0
- package/rules/security/S059_disable_debug_mode/dart/analyzer.js +45 -0
- package/rules/security/S059_disable_debug_mode/index.js +86 -0
- package/rules/security/S059_disable_debug_mode/typescript/analyzer.js +85 -0
- package/rules/security/S060_password_minimum_length/config.json +28 -0
- package/rules/security/S060_password_minimum_length/dart/analyzer.js +45 -0
- package/rules/security/S060_password_minimum_length/index.js +86 -0
- package/rules/security/S060_password_minimum_length/typescript/analyzer.js +78 -0
- package/rules/security/S026_json_schema_validation/config.json +0 -27
- package/rules/security/S026_json_schema_validation/typescript/analyzer.js +0 -251
- package/rules/security/S027_no_hardcoded_secrets/config.json +0 -29
- package/rules/security/S027_no_hardcoded_secrets/typescript/analyzer.js +0 -309
- package/rules/security/S027_no_hardcoded_secrets/typescript/categories.json +0 -153
- package/rules/security/S035_path_session_cookies/config.json +0 -99
- package/rules/security/S035_path_session_cookies/typescript/analyzer.js +0 -316
- package/rules/security/S035_path_session_cookies/typescript/regex-based-analyzer.js +0 -724
- package/rules/security/S035_path_session_cookies/typescript/symbol-based-analyzer.js +0 -373
- package/rules/security/S039_no_session_tokens_in_url/config.json +0 -92
- package/rules/security/S039_no_session_tokens_in_url/typescript/analyzer.js +0 -262
- package/rules/security/S039_no_session_tokens_in_url/typescript/regex-based-analyzer.js +0 -337
- package/rules/security/S039_no_session_tokens_in_url/typescript/symbol-based-analyzer.js +0 -443
- package/rules/security/S048_no_current_password_in_reset/config.json +0 -48
- package/rules/security/S048_no_current_password_in_reset/typescript/analyzer.js +0 -366
- /package/rules/security/{S026_json_schema_validation → S026_tls_all_connections}/dart/analyzer.js +0 -0
- /package/rules/security/{S026_json_schema_validation → S026_tls_all_connections}/index.js +0 -0
- /package/rules/security/{S027_no_hardcoded_secrets → S027_mtls_certificate_validation}/dart/analyzer.js +0 -0
- /package/rules/security/{S027_no_hardcoded_secrets → S027_mtls_certificate_validation}/index.js +0 -0
- /package/rules/security/{S027_no_hardcoded_secrets → S027_mtls_certificate_validation}/typescript/categorized-analyzer.js +0 -0
- /package/rules/security/{S035_path_session_cookies → S035_separate_app_hostnames}/dart/analyzer.js +0 -0
- /package/rules/security/{S035_path_session_cookies → S035_separate_app_hostnames}/index.js +0 -0
- /package/rules/security/{S035_path_session_cookies → S035_separate_app_hostnames}/typescript/README.md +0 -0
- /package/rules/security/{S039_no_session_tokens_in_url → S039_tls_certificate_validation}/dart/analyzer.js +0 -0
- /package/rules/security/{S039_no_session_tokens_in_url → S039_tls_certificate_validation}/index.js +0 -0
- /package/rules/security/{S039_no_session_tokens_in_url → S039_tls_certificate_validation}/typescript/README.md +0 -0
- /package/rules/security/{S048_no_current_password_in_reset → S048_oauth_redirect_uri_validation}/dart/analyzer.js +0 -0
- /package/rules/security/{S048_no_current_password_in_reset → S048_oauth_redirect_uri_validation}/index.js +0 -0
- /package/rules/security/{S048_no_current_password_in_reset → S048_oauth_redirect_uri_validation}/typescript/README.md +0 -0
|
@@ -3,33 +3,46 @@
|
|
|
3
3
|
> This is a comprehensive list of security rules designed to enhance the security posture of applications.
|
|
4
4
|
> Each rule includes a title, detailed description, applicable programming languages, and priority level.
|
|
5
5
|
|
|
6
|
-
### 📘 Rule S001 –
|
|
6
|
+
### 📘 Rule S001 – Authenticate backend component communications securely
|
|
7
7
|
|
|
8
|
-
- **Objective**: Ensure
|
|
8
|
+
- **Objective**: Ensure all communications between backend components (APIs, middleware, data layers) are authenticated using secure, short-lived credentials instead of static secrets.
|
|
9
9
|
- **Details**:
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
10
|
+
- Backend-to-backend communications that bypass standard user session mechanisms must be authenticated.
|
|
11
|
+
- **Required authentication methods**:
|
|
12
|
+
- Individual service accounts (per-service identity)
|
|
13
|
+
- Short-term tokens (JWT with short expiry, OAuth tokens)
|
|
14
|
+
- Certificate-based authentication (mTLS)
|
|
15
|
+
- **Prohibited credentials**:
|
|
16
|
+
- Static passwords or API keys
|
|
17
|
+
- Shared accounts with privileged access
|
|
18
|
+
- Long-lived unchanging credentials
|
|
19
|
+
- Apply to: service-to-service calls, internal APIs, message queues, database connections, cache layers.
|
|
13
20
|
- **Applies to**: All languages
|
|
14
|
-
- **Tools**:
|
|
21
|
+
- **Tools**: Manual Review, IAM Policy Audit, mTLS Scanner, Secret Rotation Checker
|
|
15
22
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
16
|
-
- **Version**:
|
|
17
|
-
- **Status**:
|
|
23
|
+
- **Version**: 2.0
|
|
24
|
+
- **Status**: activated
|
|
18
25
|
- **Severity**: critical
|
|
19
26
|
|
|
20
|
-
### 📘 Rule S002 –
|
|
27
|
+
### 📘 Rule S002 – Protect against OS command injection
|
|
21
28
|
|
|
22
|
-
- **Objective**: Prevent
|
|
29
|
+
- **Objective**: Prevent OS command injection attacks by ensuring all operating system calls use parameterized queries or proper output encoding.
|
|
23
30
|
- **Details**:
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
- **Never** concatenate user input directly into OS commands or shell executions.
|
|
32
|
+
- **Required protection methods**:
|
|
33
|
+
- Use parameterized OS queries (subprocess with argument lists)
|
|
34
|
+
- Apply contextual command line output encoding
|
|
35
|
+
- Use language-specific safe APIs (e.g., `subprocess.run()` with `shell=False`)
|
|
36
|
+
- **Avoid**:
|
|
37
|
+
- `shell=True` with user input
|
|
38
|
+
- String concatenation in `exec()`, `system()`, `Runtime.exec()`
|
|
39
|
+
- Backtick operators or `$()` with untrusted data
|
|
40
|
+
- Validate and sanitize all inputs before passing to system commands.
|
|
28
41
|
- **Applies to**: All languages
|
|
29
|
-
- **Tools**: SonarQube (
|
|
42
|
+
- **Tools**: SonarQube (S2076, S4721), Semgrep (command-injection), Bandit (B602, B603), Manual Review
|
|
30
43
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
31
|
-
- **Version**:
|
|
32
|
-
- **Status**:
|
|
44
|
+
- **Version**: 2.0
|
|
45
|
+
- **Status**: activated
|
|
33
46
|
- **Severity**: critical
|
|
34
47
|
|
|
35
48
|
### 📘 Rule S003 – URL redirects must be within an allow list
|
|
@@ -63,81 +76,109 @@
|
|
|
63
76
|
- **Status**: activated
|
|
64
77
|
- **Severity**: medium
|
|
65
78
|
|
|
66
|
-
### 📘 Rule S005 –
|
|
79
|
+
### 📘 Rule S005 – Enforce authorization at trusted service layer
|
|
67
80
|
|
|
68
|
-
- **Objective**:
|
|
81
|
+
- **Objective**: Ensure authorization rules are enforced at a trusted server-side service layer, not relying on client-side controls that can be manipulated.
|
|
69
82
|
- **Details**:
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
-
|
|
83
|
+
- **Never** rely on client-side JavaScript for authorization decisions.
|
|
84
|
+
- **Required practices**:
|
|
85
|
+
- Enforce all authorization checks on trusted backend services
|
|
86
|
+
- Validate permissions server-side before processing requests
|
|
87
|
+
- Use middleware or interceptors at the service layer
|
|
88
|
+
- **Untrusted controls to avoid**:
|
|
89
|
+
- Client-side JavaScript permission checks
|
|
90
|
+
- Hidden form fields for authorization
|
|
91
|
+
- URL parameters for access control
|
|
92
|
+
- Browser-stored tokens without server validation
|
|
93
|
+
- All sensitive operations must be re-validated at the backend regardless of client-side checks.
|
|
76
94
|
- **Applies to**: All languages
|
|
77
|
-
- **Tools**: Manual Review,
|
|
95
|
+
- **Tools**: Manual Review, Static Analysis, Penetration Testing, SonarQube (custom rule)
|
|
78
96
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
79
|
-
- **Version**:
|
|
97
|
+
- **Version**: 2.0
|
|
80
98
|
- **Status**: activated
|
|
81
|
-
- **Severity**:
|
|
99
|
+
- **Severity**: critical
|
|
82
100
|
|
|
83
|
-
### 📘 Rule S006 – Do not
|
|
101
|
+
### 📘 Rule S006 – Do not use default credentials for service authentication
|
|
84
102
|
|
|
85
|
-
- **Objective**:
|
|
103
|
+
- **Objective**: Ensure service authentication never uses default or well-known credentials that attackers can easily guess or find in documentation.
|
|
86
104
|
- **Details**:
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
- **Never** use default credentials for any service authentication:
|
|
106
|
+
- `root/root`, `admin/admin`, `test/test`
|
|
107
|
+
- Default database passwords (e.g., `postgres/postgres`, `sa/sa`)
|
|
108
|
+
- Factory-default API keys or tokens
|
|
109
|
+
- **Required practices**:
|
|
110
|
+
- Generate unique, strong credentials for each service instance
|
|
111
|
+
- Rotate credentials regularly
|
|
112
|
+
- Use secrets management tools (Vault, AWS Secrets Manager)
|
|
113
|
+
- Scan configurations and deployment scripts for default credential patterns.
|
|
114
|
+
- Block deployments containing default credentials in CI/CD pipelines.
|
|
91
115
|
- **Applies to**: All languages
|
|
92
|
-
- **Tools**: Manual Review,
|
|
116
|
+
- **Tools**: Manual Review, Secret Scanner, GitLeaks, TruffleHog, CI/CD Policy Checks
|
|
93
117
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
94
|
-
- **Version**:
|
|
118
|
+
- **Version**: 2.0
|
|
95
119
|
- **Status**: activated
|
|
96
|
-
- **Severity**:
|
|
120
|
+
- **Severity**: critical
|
|
97
121
|
|
|
98
|
-
### 📘 Rule S007 –
|
|
122
|
+
### 📘 Rule S007 – Perform output encoding before interpreter use
|
|
99
123
|
|
|
100
|
-
- **Objective**:
|
|
124
|
+
- **Objective**: Ensure the application performs proper output encoding and escaping as a final step before data is used by the target interpreter, preventing injection attacks.
|
|
101
125
|
- **Details**:
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
-
|
|
126
|
+
- Output encoding must occur either:
|
|
127
|
+
- As a final step before being used by the interpreter
|
|
128
|
+
- Or by the interpreter itself (using built-in encoding features)
|
|
129
|
+
- **Context-specific encoding**:
|
|
130
|
+
- HTML context: encode `<`, `>`, `&`, `"`, `'`
|
|
131
|
+
- JavaScript context: escape strings properly
|
|
132
|
+
- SQL context: use parameterized queries
|
|
133
|
+
- URL context: use `encodeURIComponent()`
|
|
134
|
+
- Shell context: escape shell metacharacters
|
|
135
|
+
- **Never** trust that earlier encoding is sufficient – encode at the point of use.
|
|
136
|
+
- Use framework-provided encoding functions where available.
|
|
106
137
|
- **Applies to**: All languages
|
|
107
|
-
- **Tools**:
|
|
138
|
+
- **Tools**: SonarQube (S5131, S2076), Semgrep (injection rules), ESLint, Manual Review
|
|
108
139
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
109
|
-
- **Version**:
|
|
140
|
+
- **Version**: 2.0
|
|
110
141
|
- **Status**: activated
|
|
111
|
-
- **Severity**:
|
|
142
|
+
- **Severity**: high
|
|
112
143
|
|
|
113
|
-
### 📘 Rule S008 –
|
|
144
|
+
### 📘 Rule S008 – Validate and sanitize SVG content
|
|
114
145
|
|
|
115
|
-
- **Objective**:
|
|
146
|
+
- **Objective**: Ensure user-supplied SVG (Scalable Vector Graphics) content is validated or sanitized to prevent script injection and other attacks.
|
|
116
147
|
- **Details**:
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
|
|
148
|
+
- SVG files can contain embedded scripts and potentially dangerous elements.
|
|
149
|
+
- **Allowed elements** (safe for graphics):
|
|
150
|
+
- Drawing elements: `svg`, `path`, `rect`, `circle`, `ellipse`, `line`, `polyline`, `polygon`
|
|
151
|
+
- Grouping: `g`, `defs`, `use`, `symbol`
|
|
152
|
+
- Styling: `style` (with restrictions), `linearGradient`, `radialGradient`
|
|
153
|
+
- **Prohibited elements** (must be removed/rejected):
|
|
154
|
+
- `script` tags
|
|
155
|
+
- `foreignObject` (can embed arbitrary HTML)
|
|
156
|
+
- Event handlers (`onclick`, `onload`, `onerror`, etc.)
|
|
157
|
+
- External references (`xlink:href` to external URLs)
|
|
158
|
+
- Use SVG sanitization libraries (e.g., DOMPurify with SVG profile).
|
|
159
|
+
- Consider converting SVGs to raster images for untrusted sources.
|
|
121
160
|
- **Applies to**: All languages
|
|
122
|
-
- **Tools**:
|
|
123
|
-
- **Principles**: CODE_QUALITY,
|
|
124
|
-
- **Version**:
|
|
125
|
-
- **Status**:
|
|
126
|
-
- **Severity**:
|
|
161
|
+
- **Tools**: DOMPurify, svg-sanitizer, Manual Review, CSP Headers
|
|
162
|
+
- **Principles**: CODE_QUALITY, SECURITY
|
|
163
|
+
- **Version**: 2.0
|
|
164
|
+
- **Status**: activated
|
|
165
|
+
- **Severity**: high
|
|
127
166
|
|
|
128
|
-
### 📘 Rule S009 –
|
|
167
|
+
### 📘 Rule S009 – Use only approved cryptographic algorithms, modes, and hash functions
|
|
129
168
|
|
|
130
|
-
- **Objective**: Prevent
|
|
169
|
+
- **Objective**: Prevent cryptographic vulnerabilities by ensuring only secure block modes, padding schemes, ciphers, and hash functions are used throughout the application.
|
|
131
170
|
- **Details**:
|
|
132
|
-
- Do not use
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
171
|
+
- Do not use insecure block modes (e.g., ECB) as they reveal identical data patterns and are vulnerable to pattern analysis attacks.
|
|
172
|
+
- Do not use weak padding schemes (e.g., `PKCS#1 v1.5`) which are vulnerable to padding oracle attacks.
|
|
173
|
+
- Use only approved ciphers and modes such as `AES` with `GCM` (Galois/Counter Mode) for authenticated encryption.
|
|
174
|
+
- Use only approved hash functions for general cryptographic use cases, including digital signatures, HMAC, KDF, and random bit generation.
|
|
175
|
+
- Disallowed hash functions such as `MD5` must not be used for any cryptographic purpose, including checksums, integrity verification, or password hashing.
|
|
176
|
+
- Do not use encryption algorithms with block size < 128-bit like `Triple-DES`, `Blowfish`.
|
|
177
|
+
- For legacy compatibility requirements, isolate the implementation and add clear security warnings.
|
|
137
178
|
- **Applies to**: All languages
|
|
138
179
|
- **Tools**: SonarQube (S2070, S4790, S5547), Semgrep (crypto rules), Manual Review
|
|
139
180
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
140
|
-
- **Version**:
|
|
181
|
+
- **Version**: 2.0
|
|
141
182
|
- **Status**: activated
|
|
142
183
|
- **Severity**: medium
|
|
143
184
|
|
|
@@ -156,36 +197,58 @@
|
|
|
156
197
|
- **Status**: activated
|
|
157
198
|
- **Severity**: high
|
|
158
199
|
|
|
159
|
-
### 📘 Rule S011 –
|
|
200
|
+
### 📘 Rule S011 – Enable Encrypted Client Hello (ECH) for TLS
|
|
160
201
|
|
|
161
|
-
- **Objective**: Prevent
|
|
202
|
+
- **Objective**: Prevent exposure of sensitive metadata during TLS handshake by enabling Encrypted Client Hello (ECH) to protect Server Name Indication (SNI) and other client hello fields.
|
|
162
203
|
- **Details**:
|
|
163
|
-
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
204
|
+
- **Why ECH matters**:
|
|
205
|
+
- Standard TLS exposes SNI in plaintext during handshake
|
|
206
|
+
- Attackers can identify which sites users are visiting
|
|
207
|
+
- Network monitors can filter/block based on SNI
|
|
208
|
+
- **Required configuration**:
|
|
209
|
+
- Enable ECH in TLS settings (TLS 1.3 required)
|
|
210
|
+
- Configure ECH public keys properly
|
|
211
|
+
- Support HTTPS DNS records for ECH key distribution
|
|
212
|
+
- **Benefits**:
|
|
213
|
+
- Encrypts SNI and other sensitive handshake data
|
|
214
|
+
- Prevents traffic analysis based on destination
|
|
215
|
+
- Enhances user privacy
|
|
216
|
+
- Verify ECH is working using browser developer tools or TLS testing tools.
|
|
167
217
|
- **Applies to**: All languages
|
|
168
|
-
- **Tools**:
|
|
169
|
-
- **Principles**:
|
|
170
|
-
- **Version**:
|
|
218
|
+
- **Tools**: SSL Labs, testssl.sh, Browser DevTools, Manual TLS Config Review
|
|
219
|
+
- **Principles**: SECURITY
|
|
220
|
+
- **Version**: 2.0
|
|
171
221
|
- **Status**: activated
|
|
172
|
-
- **Severity**:
|
|
222
|
+
- **Severity**: medium
|
|
173
223
|
|
|
174
|
-
### 📘 Rule S012 –
|
|
224
|
+
### 📘 Rule S012 – Use secrets management solution for backend secrets
|
|
175
225
|
|
|
176
|
-
- **Objective**:
|
|
226
|
+
- **Objective**: Ensure all backend secrets are securely managed using a dedicated secrets management solution, never stored in source code or build artifacts.
|
|
177
227
|
- **Details**:
|
|
178
|
-
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
228
|
+
- **Must use a secrets management solution** (key vault) to:
|
|
229
|
+
- Create secrets securely
|
|
230
|
+
- Store secrets with encryption at rest
|
|
231
|
+
- Control access with fine-grained permissions
|
|
232
|
+
- Rotate and destroy secrets safely
|
|
233
|
+
- **Types of secrets to manage**:
|
|
234
|
+
- Passwords and credentials
|
|
235
|
+
- Cryptographic key material
|
|
236
|
+
- Database connection strings
|
|
237
|
+
- Third-party system integrations
|
|
238
|
+
- TOTP seeds and internal secrets
|
|
239
|
+
- API keys
|
|
240
|
+
- **Prohibited practices**:
|
|
241
|
+
- Secrets in application source code
|
|
242
|
+
- Secrets in build artifacts or container images
|
|
243
|
+
- Secrets in environment files committed to repos
|
|
244
|
+
- **For L3 (high-security) applications**: Must use hardware-backed solution (HSM).
|
|
245
|
+
- Recommended tools: HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, GCP Secret Manager.
|
|
183
246
|
- **Applies to**: All languages
|
|
184
|
-
- **Tools**:
|
|
185
|
-
- **Principles**: SECURITY
|
|
186
|
-
- **Version**:
|
|
247
|
+
- **Tools**: Vault, AWS Secrets Manager, Azure Key Vault, GitLeaks, TruffleHog, HSM
|
|
248
|
+
- **Principles**: CODE_QUALITY, SECURITY
|
|
249
|
+
- **Version**: 2.0
|
|
187
250
|
- **Status**: activated
|
|
188
|
-
- **Severity**:
|
|
251
|
+
- **Severity**: critical
|
|
189
252
|
|
|
190
253
|
### 📘 Rule S013 – Always use TLS for all connections
|
|
191
254
|
|
|
@@ -272,32 +335,33 @@
|
|
|
272
335
|
- **Status**: activated
|
|
273
336
|
- **Severity**: critical
|
|
274
337
|
|
|
275
|
-
### 📘 Rule S018 –
|
|
338
|
+
### 📘 Rule S018 – Do not store sensitive data in browser storage
|
|
276
339
|
|
|
277
|
-
- **Objective**:
|
|
340
|
+
- **Objective**: Prevent sensitive data exposure by ensuring browser storage mechanisms do not contain sensitive information, except for session tokens.
|
|
278
341
|
- **Details**:
|
|
279
|
-
-
|
|
280
|
-
|
|
281
|
-
-
|
|
282
|
-
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
-
|
|
286
|
-
-
|
|
287
|
-
-
|
|
288
|
-
|
|
289
|
-
-
|
|
290
|
-
|
|
291
|
-
-
|
|
292
|
-
|
|
293
|
-
-
|
|
294
|
-
|
|
342
|
+
- **Browser storage types covered**:
|
|
343
|
+
- `localStorage` (persistent, accessible by JavaScript)
|
|
344
|
+
- `sessionStorage` (tab-scoped, accessible by JavaScript)
|
|
345
|
+
- `IndexedDB` (client-side database)
|
|
346
|
+
- Cookies (when not HttpOnly)
|
|
347
|
+
- **Prohibited data in browser storage**:
|
|
348
|
+
- Passwords or credentials
|
|
349
|
+
- Personal Identifiable Information (PII)
|
|
350
|
+
- Financial data (credit cards, bank accounts)
|
|
351
|
+
- API keys or secrets
|
|
352
|
+
- Encryption keys
|
|
353
|
+
- **Exception**: Session tokens may be stored, but:
|
|
354
|
+
- Use `HttpOnly` cookies when possible
|
|
355
|
+
- Apply short expiration times
|
|
356
|
+
- Implement proper token rotation
|
|
357
|
+
- XSS attacks can access all JavaScript-readable storage.
|
|
358
|
+
- Use server-side sessions for sensitive data instead.
|
|
295
359
|
- **Applies to**: All languages
|
|
296
|
-
- **Tools**: Static Analysis (Semgrep,
|
|
297
|
-
- **Principles**: SECURITY
|
|
298
|
-
- **Version**:
|
|
299
|
-
- **Status**:
|
|
300
|
-
- **Severity**:
|
|
360
|
+
- **Tools**: Browser DevTools, Static Analysis (Semgrep, ESLint), Manual Code Review, Security Audit
|
|
361
|
+
- **Principles**: CODE_QUALITY, SECURITY
|
|
362
|
+
- **Version**: 2.0
|
|
363
|
+
- **Status**: activated
|
|
364
|
+
- **Severity**: high
|
|
301
365
|
|
|
302
366
|
### 📘 Rule S019 – Sanitize input before sending emails to prevent SMTP Injection
|
|
303
367
|
|
|
@@ -333,21 +397,28 @@
|
|
|
333
397
|
- **Status**: activated
|
|
334
398
|
- **Severity**: high
|
|
335
399
|
|
|
336
|
-
### 📘 Rule S021 –
|
|
400
|
+
### 📘 Rule S021 – Set Referrer-Policy to prevent sensitive data leakage
|
|
337
401
|
|
|
338
|
-
- **Objective**: Prevent
|
|
402
|
+
- **Objective**: Prevent leakage of sensitive URL data (path, query parameters, hostname) to third-party services via the `Referer` HTTP header.
|
|
339
403
|
- **Details**:
|
|
340
|
-
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
-
|
|
344
|
-
|
|
345
|
-
-
|
|
404
|
+
- **Why it matters**:
|
|
405
|
+
- `Referer` header can expose sensitive data in URLs to external sites
|
|
406
|
+
- Internal application hostnames may reveal infrastructure details
|
|
407
|
+
- Query parameters may contain tokens, IDs, or PII
|
|
408
|
+
- **Implementation methods**:
|
|
409
|
+
- HTTP response header: `Referrer-Policy: strict-origin-when-cross-origin`
|
|
410
|
+
- HTML meta tag: `<meta name="referrer" content="strict-origin-when-cross-origin">`
|
|
411
|
+
- HTML element attributes: `rel="noreferrer"` on links
|
|
412
|
+
- **Recommended policies**:
|
|
413
|
+
- `strict-origin-when-cross-origin` (default, balanced)
|
|
414
|
+
- `same-origin` (stricter, only same-origin gets referrer)
|
|
415
|
+
- `no-referrer` (strictest, never send referrer)
|
|
416
|
+
- For internal non-public applications, use stricter policies to protect hostnames.
|
|
346
417
|
- **Applies to**: All languages
|
|
347
|
-
- **Tools**:
|
|
418
|
+
- **Tools**: Browser DevTools, Security Headers Scanner, OWASP ZAP, Manual Review
|
|
348
419
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
349
|
-
- **Version**:
|
|
350
|
-
- **Status**:
|
|
420
|
+
- **Version**: 2.0
|
|
421
|
+
- **Status**: activated
|
|
351
422
|
- **Severity**: medium
|
|
352
423
|
|
|
353
424
|
### 📘 Rule S022 – Escape data properly based on output context
|
|
@@ -369,21 +440,27 @@
|
|
|
369
440
|
- **Status**: activated
|
|
370
441
|
- **Severity**: medium
|
|
371
442
|
|
|
372
|
-
### 📘 Rule S023 –
|
|
443
|
+
### 📘 Rule S023 – Use output encoding when building dynamic JavaScript/JSON
|
|
373
444
|
|
|
374
|
-
- **Objective**: Prevent JavaScript
|
|
445
|
+
- **Objective**: Prevent JavaScript and JSON injection by applying proper output encoding when dynamically building JavaScript content or JSON data.
|
|
375
446
|
- **Details**:
|
|
376
|
-
-
|
|
377
|
-
|
|
378
|
-
-
|
|
379
|
-
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
447
|
+
- **When building dynamic JavaScript**:
|
|
448
|
+
- Encode data before inserting into JS strings
|
|
449
|
+
- Escape characters: `\`, `'`, `"`, `<`, `>`, `&`, newlines
|
|
450
|
+
- Never use `eval()` or `new Function()` with user data
|
|
451
|
+
- **When building JSON responses**:
|
|
452
|
+
- Use native JSON serializers (`JSON.stringify()`, `json.dumps()`)
|
|
453
|
+
- Escape `</script>` sequences when embedding in HTML
|
|
454
|
+
- Validate JSON structure before parsing
|
|
455
|
+
- **Dangerous patterns to avoid**:
|
|
456
|
+
- String concatenation to build JS: `"var x = '" + userInput + "'"`
|
|
457
|
+
- Inline event handlers with user data
|
|
458
|
+
- Template literals with unescaped user input
|
|
459
|
+
- Use Content Security Policy (CSP) as defense-in-depth.
|
|
383
460
|
- **Applies to**: All languages
|
|
384
|
-
- **Tools**: ESLint (`no-eval`), Semgrep (
|
|
461
|
+
- **Tools**: ESLint (`no-eval`), Semgrep (json-injection), SonarQube (S1523, S5334), Manual Review
|
|
385
462
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
386
|
-
- **Version**:
|
|
463
|
+
- **Version**: 2.0
|
|
387
464
|
- **Status**: activated
|
|
388
465
|
- **Severity**: high
|
|
389
466
|
|
|
@@ -425,47 +502,59 @@
|
|
|
425
502
|
- **Status**: activated
|
|
426
503
|
- **Severity**: medium
|
|
427
504
|
|
|
428
|
-
### 📘 Rule S026 –
|
|
505
|
+
### 📘 Rule S026 – Use TLS encryption for all inbound and outbound connections
|
|
429
506
|
|
|
430
|
-
- **Objective**: Ensure all
|
|
507
|
+
- **Objective**: Ensure all application connections use encrypted TLS protocol, with no fallback to insecure or unencrypted protocols.
|
|
431
508
|
- **Details**:
|
|
432
|
-
-
|
|
433
|
-
-
|
|
434
|
-
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
-
|
|
438
|
-
-
|
|
439
|
-
-
|
|
440
|
-
-
|
|
441
|
-
-
|
|
509
|
+
- **All connections must use TLS**:
|
|
510
|
+
- Inbound: API endpoints, web interfaces, webhooks
|
|
511
|
+
- Outbound: external APIs, databases, partner systems
|
|
512
|
+
- **Connection types covered**:
|
|
513
|
+
- Monitoring systems and health checks
|
|
514
|
+
- Management tools and admin interfaces
|
|
515
|
+
- Remote access and SSH connections
|
|
516
|
+
- Middleware and message queues
|
|
517
|
+
- Database connections (PostgreSQL, MySQL, MongoDB)
|
|
518
|
+
- Mainframe and legacy system integrations
|
|
519
|
+
- Partner and external API calls
|
|
520
|
+
- **Requirements**:
|
|
521
|
+
- TLS 1.2 minimum, prefer TLS 1.3
|
|
522
|
+
- No fallback to HTTP, unencrypted protocols
|
|
523
|
+
- Certificate validation enabled
|
|
524
|
+
- Strong cipher suites only
|
|
525
|
+
- Disable debug modes that bypass TLS in production.
|
|
442
526
|
- **Applies to**: All languages
|
|
443
|
-
- **Tools**:
|
|
527
|
+
- **Tools**: SSL Labs, testssl.sh, nmap, Network Traffic Analysis, Manual Config Review
|
|
444
528
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
445
|
-
- **Version**:
|
|
529
|
+
- **Version**: 2.0
|
|
446
530
|
- **Status**: activated
|
|
447
|
-
- **Severity**:
|
|
531
|
+
- **Severity**: critical
|
|
448
532
|
|
|
449
|
-
### 📘 Rule S027 –
|
|
533
|
+
### 📘 Rule S027 – Validate mTLS client certificates before authentication
|
|
450
534
|
|
|
451
|
-
- **Objective**:
|
|
535
|
+
- **Objective**: Ensure mTLS client certificates are properly validated and trusted before using certificate identity for authentication or authorization decisions.
|
|
452
536
|
- **Details**:
|
|
453
|
-
-
|
|
454
|
-
-
|
|
455
|
-
|
|
456
|
-
-
|
|
457
|
-
-
|
|
458
|
-
|
|
459
|
-
-
|
|
460
|
-
|
|
461
|
-
-
|
|
462
|
-
|
|
537
|
+
- **Before trusting certificate identity**:
|
|
538
|
+
- Verify certificate is signed by trusted CA
|
|
539
|
+
- Check certificate has not expired
|
|
540
|
+
- Validate certificate is not revoked (CRL/OCSP)
|
|
541
|
+
- Confirm certificate subject/SAN matches expected identity
|
|
542
|
+
- **Certificate validation requirements**:
|
|
543
|
+
- Full chain validation up to root CA
|
|
544
|
+
- Check Extended Key Usage for client authentication
|
|
545
|
+
- Verify certificate purpose and constraints
|
|
546
|
+
- **Common mistakes to avoid**:
|
|
547
|
+
- Accepting any valid certificate without identity check
|
|
548
|
+
- Skipping revocation checks
|
|
549
|
+
- Trusting self-signed certificates without explicit pinning
|
|
550
|
+
- Using certificate CN without proper validation
|
|
551
|
+
- Log all certificate validation failures for security monitoring.
|
|
463
552
|
- **Applies to**: All languages
|
|
464
|
-
- **Tools**:
|
|
553
|
+
- **Tools**: OpenSSL, mTLS Testing Tools, Certificate Validator, Manual Config Review
|
|
465
554
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
466
|
-
- **Version**:
|
|
555
|
+
- **Version**: 2.0
|
|
467
556
|
- **Status**: activated
|
|
468
|
-
- **Severity**:
|
|
557
|
+
- **Severity**: critical
|
|
469
558
|
|
|
470
559
|
### 📘 Rule S028 – Limit upload file size and number of files per user
|
|
471
560
|
|
|
@@ -620,43 +709,60 @@
|
|
|
620
709
|
- **Status**: activated
|
|
621
710
|
- **Severity**: medium
|
|
622
711
|
|
|
623
|
-
### 📘 Rule S035 –
|
|
712
|
+
### 📘 Rule S035 – Host separate applications on different hostnames
|
|
624
713
|
|
|
625
|
-
- **Objective**:
|
|
714
|
+
- **Objective**: Leverage same-origin policy restrictions by hosting separate applications on different hostnames to isolate resources, cookies, and prevent cross-application attacks.
|
|
626
715
|
- **Details**:
|
|
627
|
-
-
|
|
628
|
-
|
|
629
|
-
-
|
|
630
|
-
-
|
|
631
|
-
-
|
|
632
|
-
-
|
|
633
|
-
-
|
|
716
|
+
- **Same-origin policy benefits**:
|
|
717
|
+
- Prevents scripts from one origin accessing resources from another
|
|
718
|
+
- Isolates cookies and storage per hostname
|
|
719
|
+
- Limits impact of XSS to single application
|
|
720
|
+
- **Hosting requirements**:
|
|
721
|
+
- Each application should have its own hostname/subdomain
|
|
722
|
+
- Example: `app1.example.com`, `app2.example.com` (good)
|
|
723
|
+
- Avoid: `example.com/app1`, `example.com/app2` (shared origin)
|
|
724
|
+
- **Restrictions enforced**:
|
|
725
|
+
- Document/script isolation between origins
|
|
726
|
+
- Cookie isolation (with proper domain settings)
|
|
727
|
+
- localStorage/sessionStorage separation
|
|
728
|
+
- CORS enforcement for cross-origin requests
|
|
729
|
+
- Use subdomains or separate domains for:
|
|
730
|
+
- Admin panels vs public sites
|
|
731
|
+
- API servers vs frontend apps
|
|
732
|
+
- Multi-tenant applications
|
|
634
733
|
- **Applies to**: All languages
|
|
635
|
-
- **Tools**:
|
|
734
|
+
- **Tools**: Manual Architecture Review, DNS Configuration Audit, Browser DevTools
|
|
636
735
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
637
|
-
- **Version**:
|
|
736
|
+
- **Version**: 2.0
|
|
638
737
|
- **Status**: activated
|
|
639
738
|
- **Severity**: medium
|
|
640
739
|
|
|
641
|
-
### 📘 Rule S036 –
|
|
740
|
+
### 📘 Rule S036 – Use internal data for file paths, validate user filenames strictly
|
|
642
741
|
|
|
643
|
-
- **Objective**:
|
|
742
|
+
- **Objective**: Prevent path traversal, LFI, RFI, and SSRF attacks by using internally generated file paths instead of user-submitted filenames, with strict validation when user input is unavoidable.
|
|
644
743
|
- **Details**:
|
|
645
|
-
- **
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
-
|
|
649
|
-
|
|
650
|
-
-
|
|
651
|
-
-
|
|
652
|
-
-
|
|
653
|
-
-
|
|
744
|
+
- **Preferred approach** - Use internal data:
|
|
745
|
+
- Generate file paths from internal IDs or UUIDs
|
|
746
|
+
- Map user selections to predefined safe paths
|
|
747
|
+
- Store file metadata in database, not in filenames
|
|
748
|
+
- **When user filenames are required**:
|
|
749
|
+
- Strip path separators (`/`, `\`, `..`)
|
|
750
|
+
- Validate against allow-list of characters
|
|
751
|
+
- Limit filename length
|
|
752
|
+
- Sanitize file extensions
|
|
753
|
+
- Normalize paths before validation
|
|
754
|
+
- **Attacks prevented**:
|
|
755
|
+
- Path traversal (`../../etc/passwd`)
|
|
756
|
+
- Local File Inclusion (LFI)
|
|
757
|
+
- Remote File Inclusion (RFI)
|
|
758
|
+
- Server-Side Request Forgery (SSRF)
|
|
759
|
+
- Never use user input directly in: `include()`, `require()`, `open()`, `readFile()`, file download paths.
|
|
654
760
|
- **Applies to**: All languages
|
|
655
|
-
- **Tools**: Static Analysis, OWASP ZAP, Burp Suite,
|
|
761
|
+
- **Tools**: Static Analysis, OWASP ZAP, Burp Suite, Semgrep (path-traversal), Manual Review
|
|
656
762
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
657
|
-
- **Version**:
|
|
763
|
+
- **Version**: 2.0
|
|
658
764
|
- **Status**: activated
|
|
659
|
-
- **Severity**:
|
|
765
|
+
- **Severity**: critical
|
|
660
766
|
|
|
661
767
|
### 📘 Rule S037 – Set anti-cache headers to prevent sensitive data leakage
|
|
662
768
|
|
|
@@ -700,23 +806,30 @@
|
|
|
700
806
|
- **Status**: activated
|
|
701
807
|
- **Severity**: medium
|
|
702
808
|
|
|
703
|
-
### 📘 Rule S039 –
|
|
809
|
+
### 📘 Rule S039 – TLS clients must validate server certificates
|
|
704
810
|
|
|
705
|
-
- **Objective**:
|
|
811
|
+
- **Objective**: Ensure TLS clients validate certificates received from servers before establishing secure communication to prevent MITM attacks.
|
|
706
812
|
- **Details**:
|
|
707
|
-
-
|
|
708
|
-
-
|
|
709
|
-
-
|
|
710
|
-
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
-
|
|
813
|
+
- **Required certificate validation**:
|
|
814
|
+
- Verify certificate is signed by trusted CA
|
|
815
|
+
- Check certificate chain up to root CA
|
|
816
|
+
- Validate certificate has not expired
|
|
817
|
+
- Confirm hostname matches certificate CN/SAN
|
|
818
|
+
- **Do NOT disable validation**:
|
|
819
|
+
- Never set `rejectUnauthorized: false` (Node.js)
|
|
820
|
+
- Never set `verify=False` (Python requests)
|
|
821
|
+
- Never set `InsecureSkipVerify: true` (Go)
|
|
822
|
+
- Never ignore SSL errors in production
|
|
823
|
+
- **Certificate revocation**:
|
|
824
|
+
- Check CRL or OCSP when possible
|
|
825
|
+
- Consider OCSP stapling for performance
|
|
826
|
+
- For development/testing only: use self-signed certs with explicit trust, not disabled validation.
|
|
714
827
|
- **Applies to**: All languages
|
|
715
|
-
- **Tools**:
|
|
716
|
-
- **Principles**: SECURITY
|
|
717
|
-
- **Version**:
|
|
828
|
+
- **Tools**: SSL Labs, testssl.sh, Static Analysis, Manual Code Review
|
|
829
|
+
- **Principles**: CODE_QUALITY, SECURITY
|
|
830
|
+
- **Version**: 2.0
|
|
718
831
|
- **Status**: activated
|
|
719
|
-
- **Severity**:
|
|
832
|
+
- **Severity**: critical
|
|
720
833
|
|
|
721
834
|
### 📘 Rule S040 – Regenerate Session Token after login to prevent Session Fixation
|
|
722
835
|
|
|
@@ -734,7 +847,7 @@
|
|
|
734
847
|
- **Tools**: Static Analysis, Manual Review, OWASP ZAP, Burp Suite, SonarQube (custom rule)
|
|
735
848
|
- **Principles**: SECURITY
|
|
736
849
|
- **Version**: 1.1
|
|
737
|
-
- **Status**:
|
|
850
|
+
- **Status**: activated
|
|
738
851
|
- **Severity**: high
|
|
739
852
|
|
|
740
853
|
### 📘 Rule S041 – Session Tokens must be invalidated after logout or expiration
|
|
@@ -787,7 +900,7 @@
|
|
|
787
900
|
- **Tools**: Manual Review, Static Analysis (Token Revocation Logic), SonarQube (custom rule)
|
|
788
901
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
789
902
|
- **Version**: 1.1
|
|
790
|
-
- **Status**:
|
|
903
|
+
- **Status**: activated
|
|
791
904
|
- **Severity**: medium
|
|
792
905
|
|
|
793
906
|
### 📘 Rule S044 – Require re-authentication before modifying critical information
|
|
@@ -823,61 +936,86 @@
|
|
|
823
936
|
- **Status**: activated
|
|
824
937
|
- **Severity**: medium
|
|
825
938
|
|
|
826
|
-
### 📘 Rule S046 –
|
|
939
|
+
### 📘 Rule S046 – Use algorithm allowlist for self-contained tokens
|
|
827
940
|
|
|
828
|
-
- **Objective**:
|
|
941
|
+
- **Objective**: Prevent algorithm confusion and downgrade attacks by restricting token signing/verification to an explicit allowlist of algorithms.
|
|
829
942
|
- **Details**:
|
|
830
|
-
-
|
|
831
|
-
-
|
|
832
|
-
-
|
|
833
|
-
-
|
|
834
|
-
-
|
|
835
|
-
|
|
836
|
-
|
|
943
|
+
- **Must use algorithm allowlist**:
|
|
944
|
+
- Define permitted algorithms explicitly for each context
|
|
945
|
+
- Validate algorithm before processing token
|
|
946
|
+
- Reject tokens using algorithms not in allowlist
|
|
947
|
+
- **Critical requirement**:
|
|
948
|
+
- **Never** allow the `none` algorithm
|
|
949
|
+
- Prefer either symmetric OR asymmetric algorithms, not both
|
|
950
|
+
- **If both symmetric and asymmetric needed**:
|
|
951
|
+
- Implement key type validation
|
|
952
|
+
- Prevent key confusion attacks (using symmetric key as asymmetric)
|
|
953
|
+
- Use separate key stores for different algorithm types
|
|
954
|
+
- **Recommended algorithms**:
|
|
955
|
+
- Symmetric: HS256, HS384, HS512
|
|
956
|
+
- Asymmetric: RS256, RS384, RS512, ES256, ES384, ES512
|
|
957
|
+
- Validate algorithm in token header matches expected algorithm before verification.
|
|
837
958
|
- **Applies to**: All languages
|
|
838
|
-
- **Tools**:
|
|
959
|
+
- **Tools**: JWT Debugger, Static Analysis, Manual Code Review, Security Test
|
|
839
960
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
840
|
-
- **Version**:
|
|
841
|
-
- **Status**:
|
|
842
|
-
- **Severity**:
|
|
961
|
+
- **Version**: 2.0
|
|
962
|
+
- **Status**: activated
|
|
963
|
+
- **Severity**: critical
|
|
843
964
|
|
|
844
|
-
### 📘 Rule S047 –
|
|
965
|
+
### 📘 Rule S047 – Protect OAuth code flow against CSRF attacks
|
|
845
966
|
|
|
846
|
-
- **Objective**:
|
|
967
|
+
- **Objective**: Prevent browser-based CSRF attacks that could trigger unauthorized OAuth token requests by implementing PKCE or state parameter validation.
|
|
847
968
|
- **Details**:
|
|
848
|
-
-
|
|
849
|
-
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
969
|
+
- **OAuth code flow CSRF protection methods**:
|
|
970
|
+
- **PKCE (Proof Key for Code Exchange)** - Recommended:
|
|
971
|
+
- Generate cryptographically random `code_verifier`
|
|
972
|
+
- Send `code_challenge` (hash of verifier) in authorization request
|
|
973
|
+
- Send `code_verifier` in token request
|
|
974
|
+
- Server validates challenge matches verifier
|
|
975
|
+
- **State parameter**:
|
|
976
|
+
- Generate unique, unpredictable `state` value
|
|
977
|
+
- Send `state` in authorization request
|
|
978
|
+
- Validate `state` in callback matches sent value
|
|
979
|
+
- Bind state to user session
|
|
980
|
+
- **Requirements**:
|
|
981
|
+
- Use PKCE for all public clients (SPAs, mobile apps)
|
|
982
|
+
- Use state parameter as minimum for confidential clients
|
|
983
|
+
- Never reuse state or PKCE values
|
|
984
|
+
- Reject authorization responses without valid state/PKCE.
|
|
858
985
|
- **Applies to**: All languages
|
|
859
|
-
- **Tools**:
|
|
986
|
+
- **Tools**: OAuth Security Testing, Manual Code Review, OWASP ZAP
|
|
860
987
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
861
|
-
- **Version**:
|
|
988
|
+
- **Version**: 2.0
|
|
862
989
|
- **Status**: activated
|
|
863
990
|
- **Severity**: high
|
|
864
991
|
|
|
865
|
-
### 📘 Rule S048 –
|
|
992
|
+
### 📘 Rule S048 – Validate OAuth redirect URIs with exact string comparison
|
|
866
993
|
|
|
867
|
-
- **Objective**:
|
|
994
|
+
- **Objective**: Prevent OAuth redirect attacks by validating redirect URIs against a client-specific allowlist using exact string comparison, not pattern matching.
|
|
868
995
|
- **Details**:
|
|
869
|
-
- **
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
-
|
|
873
|
-
|
|
874
|
-
|
|
996
|
+
- **Redirect URI validation requirements**:
|
|
997
|
+
- Use exact string comparison (no wildcards, no patterns)
|
|
998
|
+
- Validate against pre-registered URIs only
|
|
999
|
+
- Each OAuth client must have its own allowlist
|
|
1000
|
+
- **Do NOT allow**:
|
|
1001
|
+
- Wildcard redirects (`*.example.com`)
|
|
1002
|
+
- Partial matching (`example.com/callback*`)
|
|
1003
|
+
- Open redirects to any URL
|
|
1004
|
+
- Localhost in production (except for development clients)
|
|
1005
|
+
- **Pre-registration process**:
|
|
1006
|
+
- Register all valid redirect URIs during client creation
|
|
1007
|
+
- Require admin approval for URI changes
|
|
1008
|
+
- Audit redirect URI changes
|
|
1009
|
+
- **Common attack patterns blocked**:
|
|
1010
|
+
- Subdomain takeover (`attacker.example.com`)
|
|
1011
|
+
- Path traversal in redirect
|
|
1012
|
+
- Parameter injection in URI
|
|
875
1013
|
- **Applies to**: All languages
|
|
876
|
-
- **Tools**: Manual Review, Penetration
|
|
877
|
-
- **Principles**: SECURITY
|
|
878
|
-
- **Version**:
|
|
1014
|
+
- **Tools**: OAuth Security Testing, Manual Config Review, Penetration Testing
|
|
1015
|
+
- **Principles**: CODE_QUALITY, SECURITY
|
|
1016
|
+
- **Version**: 2.0
|
|
879
1017
|
- **Status**: activated
|
|
880
|
-
- **Severity**:
|
|
1018
|
+
- **Severity**: critical
|
|
881
1019
|
|
|
882
1020
|
### 📘 Rule S049 – Authentication codes must expire quickly
|
|
883
1021
|
|
|
@@ -896,26 +1034,32 @@
|
|
|
896
1034
|
- **Status**: activated
|
|
897
1035
|
- **Severity**: medium
|
|
898
1036
|
|
|
899
|
-
### 📘 Rule S050 –
|
|
1037
|
+
### 📘 Rule S050 – Reference tokens must be unique with 128-bit entropy using CSPRNG
|
|
900
1038
|
|
|
901
|
-
- **Objective**:
|
|
1039
|
+
- **Objective**: Ensure reference tokens (session tokens, opaque tokens) are unpredictable and resistant to brute-force attacks by using cryptographically secure generation.
|
|
902
1040
|
- **Details**:
|
|
903
|
-
-
|
|
904
|
-
|
|
905
|
-
-
|
|
906
|
-
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
-
|
|
910
|
-
-
|
|
911
|
-
|
|
912
|
-
-
|
|
1041
|
+
- **Token requirements**:
|
|
1042
|
+
- Generated using CSPRNG (Cryptographically Secure Pseudo-Random Number Generator)
|
|
1043
|
+
- Minimum **128 bits of entropy** (recommended: 256 bits)
|
|
1044
|
+
- Must be unique across all active sessions
|
|
1045
|
+
- **Secure generation methods**:
|
|
1046
|
+
- Node.js: `crypto.randomBytes(32)`
|
|
1047
|
+
- Python: `secrets.token_hex(32)`
|
|
1048
|
+
- Java: `SecureRandom`
|
|
1049
|
+
- Go: `crypto/rand`
|
|
1050
|
+
- **Do NOT use**:
|
|
1051
|
+
- `Math.random()` or similar non-cryptographic RNG
|
|
1052
|
+
- Sequential or predictable patterns
|
|
1053
|
+
- User-derivable values (username, timestamp alone)
|
|
1054
|
+
- Short tokens (< 128 bits)
|
|
1055
|
+
- Store tokens securely (hashed if possible) and transmit only over TLS.
|
|
1056
|
+
- Implement token rotation and expiration policies.
|
|
913
1057
|
- **Applies to**: All languages
|
|
914
|
-
- **Tools**:
|
|
1058
|
+
- **Tools**: Static Analysis, Security Audit, CSPRNG Verification, Manual Code Review
|
|
915
1059
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
916
|
-
- **Version**:
|
|
1060
|
+
- **Version**: 2.0
|
|
917
1061
|
- **Status**: activated
|
|
918
|
-
- **Severity**:
|
|
1062
|
+
- **Severity**: high
|
|
919
1063
|
|
|
920
1064
|
### 📘 Rule S051 – Support 12–64 character passwords; reject >128 characters
|
|
921
1065
|
|
|
@@ -949,25 +1093,31 @@
|
|
|
949
1093
|
- **Status**: activated
|
|
950
1094
|
- **Severity**: medium
|
|
951
1095
|
|
|
952
|
-
### 📘 Rule S053 –
|
|
1096
|
+
### 📘 Rule S053 – Return generic error messages, hide internal details
|
|
953
1097
|
|
|
954
|
-
- **Objective**:
|
|
1098
|
+
- **Objective**: Prevent exposure of sensitive internal system data by returning generic error messages to consumers when unexpected or security-sensitive errors occur.
|
|
955
1099
|
- **Details**:
|
|
956
|
-
- **
|
|
957
|
-
-
|
|
958
|
-
-
|
|
959
|
-
|
|
960
|
-
-
|
|
961
|
-
-
|
|
962
|
-
-
|
|
963
|
-
-
|
|
964
|
-
|
|
1100
|
+
- **Never expose to consumers**:
|
|
1101
|
+
- Stack traces or exception details
|
|
1102
|
+
- Database queries or SQL errors
|
|
1103
|
+
- Secret keys, tokens, or credentials
|
|
1104
|
+
- Internal file paths or system configuration
|
|
1105
|
+
- Server version or technology stack details
|
|
1106
|
+
- **Return generic messages**:
|
|
1107
|
+
- "An unexpected error occurred. Please try again later."
|
|
1108
|
+
- "Request could not be processed."
|
|
1109
|
+
- Use error codes for support reference (e.g., `ERR-12345`)
|
|
1110
|
+
- **Internal handling**:
|
|
1111
|
+
- Log full error details server-side for debugging
|
|
1112
|
+
- Include correlation IDs in logs for traceability
|
|
1113
|
+
- Use structured logging with proper log levels
|
|
1114
|
+
- Differentiate between client errors (4xx) and server errors (5xx) without leaking details.
|
|
965
1115
|
- **Applies to**: All languages
|
|
966
|
-
- **Tools**:
|
|
1116
|
+
- **Tools**: Static Analysis, Penetration Testing, Error Response Audit, Manual Code Review
|
|
967
1117
|
- **Principles**: CODE_QUALITY, SECURITY
|
|
968
|
-
- **Version**:
|
|
1118
|
+
- **Version**: 2.0
|
|
969
1119
|
- **Status**: activated
|
|
970
|
-
- **Severity**:
|
|
1120
|
+
- **Severity**: high
|
|
971
1121
|
|
|
972
1122
|
### 📘 Rule S054 – Avoid using default accounts like "admin", "root", "sa"
|
|
973
1123
|
|
|
@@ -1050,19 +1200,57 @@
|
|
|
1050
1200
|
- **Status**: activated
|
|
1051
1201
|
- **Severity**: medium
|
|
1052
1202
|
|
|
1053
|
-
### 📘 Rule S059 –
|
|
1203
|
+
### 📘 Rule S059 – Disable debug modes in production environments
|
|
1054
1204
|
|
|
1055
|
-
- **Objective**:
|
|
1205
|
+
- **Objective**: Prevent exposure of debugging features and information leakage by ensuring all debug modes are disabled in production environments.
|
|
1056
1206
|
- **Details**:
|
|
1057
|
-
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
-
|
|
1061
|
-
-
|
|
1062
|
-
|
|
1207
|
+
- **Debug features to disable in production**:
|
|
1208
|
+
- Framework debug modes (Django `DEBUG=False`, Flask `debug=False`)
|
|
1209
|
+
- Detailed error pages with stack traces
|
|
1210
|
+
- Debug endpoints (`/debug`, `/trace`, `/actuator`)
|
|
1211
|
+
- SQL query logging to responses
|
|
1212
|
+
- Verbose logging that exposes sensitive data
|
|
1213
|
+
- **Common debug indicators to check**:
|
|
1214
|
+
- `DEBUG=true` in environment variables
|
|
1215
|
+
- Development server warnings in logs
|
|
1216
|
+
- Source maps exposed in frontend
|
|
1217
|
+
- Test/mock endpoints accessible
|
|
1218
|
+
- **Verification steps**:
|
|
1219
|
+
- Audit configuration files for debug settings
|
|
1220
|
+
- Test error responses for information leakage
|
|
1221
|
+
- Check HTTP headers for debug information
|
|
1222
|
+
- Review CI/CD pipelines for proper environment separation
|
|
1223
|
+
- Use environment-specific configurations, never deploy development configs to production.
|
|
1063
1224
|
- **Applies to**: All languages
|
|
1064
|
-
- **Tools**:
|
|
1065
|
-
- **Principles**: SECURITY
|
|
1066
|
-
- **Version**:
|
|
1067
|
-
- **Status**:
|
|
1068
|
-
- **Severity**:
|
|
1225
|
+
- **Tools**: Configuration Audit, Penetration Testing, OWASP ZAP, Environment Checker
|
|
1226
|
+
- **Principles**: CODE_QUALITY, SECURITY
|
|
1227
|
+
- **Version**: 2.0
|
|
1228
|
+
- **Status**: activated
|
|
1229
|
+
- **Severity**: high
|
|
1230
|
+
|
|
1231
|
+
### 📘 Rule S060 – Enforce minimum password length of 8 characters, recommend 15+
|
|
1232
|
+
|
|
1233
|
+
- **Objective**: Ensure user-set passwords meet minimum length requirements to provide adequate security against brute-force and dictionary attacks.
|
|
1234
|
+
- **Details**:
|
|
1235
|
+
- **Minimum requirements**:
|
|
1236
|
+
- Passwords must be at least **8 characters** in length
|
|
1237
|
+
- A minimum of **15 characters is strongly recommended** for better security
|
|
1238
|
+
- **Implementation guidelines**:
|
|
1239
|
+
- Enforce 8-character minimum at registration and password change
|
|
1240
|
+
- Display strength indicator encouraging longer passwords
|
|
1241
|
+
- Show recommendation for 15+ characters without blocking shorter valid passwords
|
|
1242
|
+
- **Rationale**:
|
|
1243
|
+
- 8 characters: baseline protection against common attacks
|
|
1244
|
+
- 15+ characters: significantly increases resistance to brute-force
|
|
1245
|
+
- Longer passwords (passphrases) are easier to remember and more secure
|
|
1246
|
+
- **User experience considerations**:
|
|
1247
|
+
- Provide real-time feedback on password strength
|
|
1248
|
+
- Suggest passphrase approach (e.g., "correct horse battery staple")
|
|
1249
|
+
- Do not impose complex character requirements that reduce usability
|
|
1250
|
+
- Combine with other password policies (breach detection, no common passwords).
|
|
1251
|
+
- **Applies to**: All languages
|
|
1252
|
+
- **Tools**: Static Analysis, Unit Test, Password Strength Libraries (zxcvbn), Manual Review
|
|
1253
|
+
- **Principles**: CODE_QUALITY, SECURITY
|
|
1254
|
+
- **Version**: 2.0
|
|
1255
|
+
- **Status**: activated
|
|
1256
|
+
- **Severity**: medium
|