ferret-scan 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/LICENSE +21 -0
- package/README.md +416 -0
- package/bin/ferret.js +822 -0
- package/dist/__tests__/basic.test.d.ts +6 -0
- package/dist/__tests__/basic.test.js +80 -0
- package/dist/analyzers/AstAnalyzer.d.ts +30 -0
- package/dist/analyzers/AstAnalyzer.js +332 -0
- package/dist/analyzers/CorrelationAnalyzer.d.ts +21 -0
- package/dist/analyzers/CorrelationAnalyzer.js +288 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +22 -0
- package/dist/intelligence/IndicatorMatcher.d.ts +50 -0
- package/dist/intelligence/IndicatorMatcher.js +285 -0
- package/dist/intelligence/ThreatFeed.d.ts +99 -0
- package/dist/intelligence/ThreatFeed.js +296 -0
- package/dist/remediation/Fixer.d.ts +71 -0
- package/dist/remediation/Fixer.js +391 -0
- package/dist/remediation/Quarantine.d.ts +102 -0
- package/dist/remediation/Quarantine.js +329 -0
- package/dist/reporters/ConsoleReporter.d.ts +13 -0
- package/dist/reporters/ConsoleReporter.js +185 -0
- package/dist/reporters/HtmlReporter.d.ts +25 -0
- package/dist/reporters/HtmlReporter.js +604 -0
- package/dist/reporters/SarifReporter.d.ts +86 -0
- package/dist/reporters/SarifReporter.js +117 -0
- package/dist/rules/ai-specific.d.ts +8 -0
- package/dist/rules/ai-specific.js +221 -0
- package/dist/rules/backdoors.d.ts +8 -0
- package/dist/rules/backdoors.js +134 -0
- package/dist/rules/correlationRules.d.ts +8 -0
- package/dist/rules/correlationRules.js +227 -0
- package/dist/rules/credentials.d.ts +8 -0
- package/dist/rules/credentials.js +194 -0
- package/dist/rules/exfiltration.d.ts +8 -0
- package/dist/rules/exfiltration.js +139 -0
- package/dist/rules/index.d.ts +51 -0
- package/dist/rules/index.js +97 -0
- package/dist/rules/injection.d.ts +8 -0
- package/dist/rules/injection.js +136 -0
- package/dist/rules/obfuscation.d.ts +8 -0
- package/dist/rules/obfuscation.js +159 -0
- package/dist/rules/permissions.d.ts +8 -0
- package/dist/rules/permissions.js +129 -0
- package/dist/rules/persistence.d.ts +8 -0
- package/dist/rules/persistence.js +117 -0
- package/dist/rules/semanticRules.d.ts +10 -0
- package/dist/rules/semanticRules.js +212 -0
- package/dist/rules/supply-chain.d.ts +8 -0
- package/dist/rules/supply-chain.js +148 -0
- package/dist/scanner/FileDiscovery.d.ts +24 -0
- package/dist/scanner/FileDiscovery.js +282 -0
- package/dist/scanner/PatternMatcher.d.ts +25 -0
- package/dist/scanner/PatternMatcher.js +206 -0
- package/dist/scanner/Scanner.d.ts +14 -0
- package/dist/scanner/Scanner.js +266 -0
- package/dist/scanner/WatchMode.d.ts +29 -0
- package/dist/scanner/WatchMode.js +195 -0
- package/dist/types.d.ts +332 -0
- package/dist/types.js +53 -0
- package/dist/utils/baseline.d.ts +80 -0
- package/dist/utils/baseline.js +276 -0
- package/dist/utils/config.d.ts +21 -0
- package/dist/utils/config.js +247 -0
- package/dist/utils/ignore.d.ts +18 -0
- package/dist/utils/ignore.js +82 -0
- package/dist/utils/logger.d.ts +32 -0
- package/dist/utils/logger.js +75 -0
- package/package.json +119 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Correlation Security Rules - Multi-file attack pattern detection
|
|
3
|
+
* These rules detect sophisticated attacks that span multiple configuration files
|
|
4
|
+
*/
|
|
5
|
+
export const correlationRules = [
|
|
6
|
+
{
|
|
7
|
+
id: 'CORR-001',
|
|
8
|
+
name: 'Credential Harvesting + Network Transmission',
|
|
9
|
+
category: 'exfiltration',
|
|
10
|
+
severity: 'CRITICAL',
|
|
11
|
+
description: 'Detects credential access in one file combined with network transmission in another',
|
|
12
|
+
patterns: [],
|
|
13
|
+
fileTypes: ['md', 'sh', 'json', 'yaml', 'ts', 'js'],
|
|
14
|
+
components: ['skill', 'agent', 'hook', 'plugin', 'settings'],
|
|
15
|
+
remediation: 'Review credential access patterns and network communications. Ensure credentials are not being exfiltrated.',
|
|
16
|
+
references: [
|
|
17
|
+
'https://attack.mitre.org/tactics/TA0006/',
|
|
18
|
+
'https://attack.mitre.org/techniques/T1041/'
|
|
19
|
+
],
|
|
20
|
+
enabled: true,
|
|
21
|
+
correlationRules: [
|
|
22
|
+
{
|
|
23
|
+
id: 'CORR-001-A',
|
|
24
|
+
description: 'Credential access followed by network transmission',
|
|
25
|
+
filePatterns: ['*'],
|
|
26
|
+
contentPatterns: [
|
|
27
|
+
'SECRET|TOKEN|API_KEY|getenv|process\\.env',
|
|
28
|
+
'fetch|axios|XMLHttpRequest|curl|wget|request'
|
|
29
|
+
],
|
|
30
|
+
maxDistance: 3
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'CORR-002',
|
|
36
|
+
name: 'Permission Escalation + Persistence',
|
|
37
|
+
category: 'persistence',
|
|
38
|
+
severity: 'HIGH',
|
|
39
|
+
description: 'Detects permission changes combined with persistence mechanisms',
|
|
40
|
+
patterns: [],
|
|
41
|
+
fileTypes: ['md', 'sh', 'json', 'yaml'],
|
|
42
|
+
components: ['hook', 'agent', 'settings'],
|
|
43
|
+
remediation: 'Review permission changes and startup hooks. Remove unauthorized persistence mechanisms.',
|
|
44
|
+
references: [
|
|
45
|
+
'https://attack.mitre.org/tactics/TA0004/',
|
|
46
|
+
'https://attack.mitre.org/tactics/TA0003/'
|
|
47
|
+
],
|
|
48
|
+
enabled: true,
|
|
49
|
+
correlationRules: [
|
|
50
|
+
{
|
|
51
|
+
id: 'CORR-002-A',
|
|
52
|
+
description: 'Permission escalation with startup persistence',
|
|
53
|
+
filePatterns: ['*'],
|
|
54
|
+
contentPatterns: [
|
|
55
|
+
'chmod|chown|setuid|sudo|defaultMode.*dontAsk',
|
|
56
|
+
'startup|onload|autostart|service.*enable|systemctl.*enable'
|
|
57
|
+
],
|
|
58
|
+
maxDistance: 2
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'CORR-003',
|
|
64
|
+
name: 'Hook Backdoor + Skill Activation',
|
|
65
|
+
category: 'backdoors',
|
|
66
|
+
severity: 'HIGH',
|
|
67
|
+
description: 'Detects suspicious hooks combined with skill or agent activation patterns',
|
|
68
|
+
patterns: [],
|
|
69
|
+
fileTypes: ['md', 'sh', 'json'],
|
|
70
|
+
components: ['hook', 'skill', 'agent'],
|
|
71
|
+
remediation: 'Review hook and skill interactions. Remove unauthorized backdoor mechanisms.',
|
|
72
|
+
references: [
|
|
73
|
+
'https://attack.mitre.org/techniques/T1546/'
|
|
74
|
+
],
|
|
75
|
+
enabled: true,
|
|
76
|
+
correlationRules: [
|
|
77
|
+
{
|
|
78
|
+
id: 'CORR-003-A',
|
|
79
|
+
description: 'Malicious hook triggering skill execution',
|
|
80
|
+
filePatterns: ['hook', 'skill', 'agent'],
|
|
81
|
+
contentPatterns: [
|
|
82
|
+
'hook.*user-prompt|session.*start|pre.*submit',
|
|
83
|
+
'skill.*activate|agent.*trigger|claude.*invoke'
|
|
84
|
+
],
|
|
85
|
+
maxDistance: 2
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'CORR-004',
|
|
91
|
+
name: 'Configuration Tampering + Obfuscation',
|
|
92
|
+
category: 'obfuscation',
|
|
93
|
+
severity: 'MEDIUM',
|
|
94
|
+
description: 'Detects configuration changes combined with obfuscation techniques',
|
|
95
|
+
patterns: [],
|
|
96
|
+
fileTypes: ['md', 'json', 'yaml'],
|
|
97
|
+
components: ['settings', 'ai-config-md', 'mcp'],
|
|
98
|
+
remediation: 'Review configuration changes and encoding patterns. Remove obfuscated malicious content.',
|
|
99
|
+
references: [
|
|
100
|
+
'https://attack.mitre.org/techniques/T1027/'
|
|
101
|
+
],
|
|
102
|
+
enabled: true,
|
|
103
|
+
correlationRules: [
|
|
104
|
+
{
|
|
105
|
+
id: 'CORR-004-A',
|
|
106
|
+
description: 'Settings modification with hidden content',
|
|
107
|
+
filePatterns: ['settings', 'config', 'claude'],
|
|
108
|
+
contentPatterns: [
|
|
109
|
+
'settings|configuration|preferences',
|
|
110
|
+
'base64|atob|btoa|\\\\x|\\\\u|obfus|encode'
|
|
111
|
+
],
|
|
112
|
+
maxDistance: 1
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 'CORR-005',
|
|
118
|
+
name: 'AI Model Bypass + Data Collection',
|
|
119
|
+
category: 'ai-specific',
|
|
120
|
+
severity: 'HIGH',
|
|
121
|
+
description: 'Detects AI model safeguard bypass combined with data collection patterns',
|
|
122
|
+
patterns: [],
|
|
123
|
+
fileTypes: ['md', 'json', 'yaml', 'ts', 'js'],
|
|
124
|
+
components: ['skill', 'agent', 'ai-config-md'],
|
|
125
|
+
remediation: 'Review AI model interactions and data handling. Remove bypass attempts and unauthorized data collection.',
|
|
126
|
+
references: [
|
|
127
|
+
'https://owasp.org/www-project-top-ten-for-large-language-model-applications/'
|
|
128
|
+
],
|
|
129
|
+
enabled: true,
|
|
130
|
+
correlationRules: [
|
|
131
|
+
{
|
|
132
|
+
id: 'CORR-005-A',
|
|
133
|
+
description: 'AI safeguard bypass with data harvesting',
|
|
134
|
+
filePatterns: ['*'],
|
|
135
|
+
contentPatterns: [
|
|
136
|
+
'ignore.*previous.*instruction|forget.*safeguard|bypass.*filter',
|
|
137
|
+
'conversation.*history|user.*data|personal.*information|collect.*data'
|
|
138
|
+
],
|
|
139
|
+
maxDistance: 2
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 'CORR-006',
|
|
145
|
+
name: 'Supply Chain + Network Communication',
|
|
146
|
+
category: 'supply-chain',
|
|
147
|
+
severity: 'HIGH',
|
|
148
|
+
description: 'Detects suspicious package installations combined with network communications',
|
|
149
|
+
patterns: [],
|
|
150
|
+
fileTypes: ['md', 'sh', 'json', 'yaml'],
|
|
151
|
+
components: ['plugin', 'mcp', 'settings'],
|
|
152
|
+
remediation: 'Review package installations and network communications. Verify legitimacy of external dependencies.',
|
|
153
|
+
references: [
|
|
154
|
+
'https://attack.mitre.org/techniques/T1195/'
|
|
155
|
+
],
|
|
156
|
+
enabled: true,
|
|
157
|
+
correlationRules: [
|
|
158
|
+
{
|
|
159
|
+
id: 'CORR-006-A',
|
|
160
|
+
description: 'Package installation with network communication',
|
|
161
|
+
filePatterns: ['*'],
|
|
162
|
+
contentPatterns: [
|
|
163
|
+
'npm.*install|pip.*install|wget.*http|curl.*http|git.*clone',
|
|
164
|
+
'http://|https://|fetch\\(|axios|request\\(|XMLHttpRequest'
|
|
165
|
+
],
|
|
166
|
+
maxDistance: 2
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: 'CORR-007',
|
|
172
|
+
name: 'File System Access + Network Transmission',
|
|
173
|
+
category: 'exfiltration',
|
|
174
|
+
severity: 'MEDIUM',
|
|
175
|
+
description: 'Detects file system access patterns combined with network transmission',
|
|
176
|
+
patterns: [],
|
|
177
|
+
fileTypes: ['md', 'ts', 'js', 'sh'],
|
|
178
|
+
components: ['skill', 'agent', 'hook'],
|
|
179
|
+
remediation: 'Review file system access and network patterns. Ensure sensitive files are not being exfiltrated.',
|
|
180
|
+
references: [
|
|
181
|
+
'https://attack.mitre.org/techniques/T1005/',
|
|
182
|
+
'https://attack.mitre.org/techniques/T1041/'
|
|
183
|
+
],
|
|
184
|
+
enabled: true,
|
|
185
|
+
correlationRules: [
|
|
186
|
+
{
|
|
187
|
+
id: 'CORR-007-A',
|
|
188
|
+
description: 'File access with network transmission',
|
|
189
|
+
filePatterns: ['*'],
|
|
190
|
+
contentPatterns: [
|
|
191
|
+
'readFile|writeFile|fs\\.|glob|find.*-name',
|
|
192
|
+
'fetch\\(|axios|post|put|XMLHttpRequest'
|
|
193
|
+
],
|
|
194
|
+
maxDistance: 1
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: 'CORR-008',
|
|
200
|
+
name: 'Authentication Bypass + Privilege Access',
|
|
201
|
+
category: 'permissions',
|
|
202
|
+
severity: 'CRITICAL',
|
|
203
|
+
description: 'Detects authentication bypass attempts combined with privileged operations',
|
|
204
|
+
patterns: [],
|
|
205
|
+
fileTypes: ['md', 'json', 'sh'],
|
|
206
|
+
components: ['settings', 'hook', 'plugin'],
|
|
207
|
+
remediation: 'Review authentication mechanisms and privileged operations. Strengthen access controls.',
|
|
208
|
+
references: [
|
|
209
|
+
'https://attack.mitre.org/techniques/T1078/'
|
|
210
|
+
],
|
|
211
|
+
enabled: true,
|
|
212
|
+
correlationRules: [
|
|
213
|
+
{
|
|
214
|
+
id: 'CORR-008-A',
|
|
215
|
+
description: 'Authentication bypass with privileged access',
|
|
216
|
+
filePatterns: ['*'],
|
|
217
|
+
contentPatterns: [
|
|
218
|
+
'auth.*bypass|no.*auth|skip.*login|admin.*access',
|
|
219
|
+
'sudo|root|administrator|privileged|elevated'
|
|
220
|
+
],
|
|
221
|
+
maxDistance: 2
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
];
|
|
226
|
+
export default correlationRules;
|
|
227
|
+
//# sourceMappingURL=correlationRules.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential Harvesting Detection Rules
|
|
3
|
+
* Detects attempts to collect API keys, tokens, or credentials
|
|
4
|
+
*/
|
|
5
|
+
import type { Rule } from '../types.js';
|
|
6
|
+
export declare const credentialRules: Rule[];
|
|
7
|
+
export default credentialRules;
|
|
8
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential Harvesting Detection Rules
|
|
3
|
+
* Detects attempts to collect API keys, tokens, or credentials
|
|
4
|
+
*/
|
|
5
|
+
export const credentialRules = [
|
|
6
|
+
{
|
|
7
|
+
id: 'CRED-001',
|
|
8
|
+
name: 'Environment Variable Credential Access',
|
|
9
|
+
category: 'credentials',
|
|
10
|
+
severity: 'CRITICAL',
|
|
11
|
+
description: 'Detects access to environment variables that commonly contain credentials',
|
|
12
|
+
patterns: [
|
|
13
|
+
/\$\{?[A-Z_]*(_KEY|_TOKEN|_SECRET|_PASSWORD|_CREDENTIAL)[}\s]/gi,
|
|
14
|
+
/process\.env\.(API|SECRET|TOKEN|KEY|PASSWORD|CREDENTIAL)/gi,
|
|
15
|
+
/\$\{?ANTHROPIC_API_KEY[}\s]/gi,
|
|
16
|
+
/\$\{?OPENAI_API_KEY[}\s]/gi,
|
|
17
|
+
/\$\{?AWS_SECRET_ACCESS_KEY[}\s]/gi,
|
|
18
|
+
/\$\{?GITHUB_TOKEN[}\s]/gi,
|
|
19
|
+
],
|
|
20
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md', 'json'],
|
|
21
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'settings', 'plugin'],
|
|
22
|
+
remediation: 'Never access or expose credential environment variables in configuration files.',
|
|
23
|
+
references: [
|
|
24
|
+
'https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_credentials',
|
|
25
|
+
],
|
|
26
|
+
enabled: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'CRED-002',
|
|
30
|
+
name: 'SSH Key Access',
|
|
31
|
+
category: 'credentials',
|
|
32
|
+
severity: 'CRITICAL',
|
|
33
|
+
description: 'Detects attempts to access SSH private keys',
|
|
34
|
+
patterns: [
|
|
35
|
+
/~\/\.ssh\/id_/gi,
|
|
36
|
+
/\/\.ssh\/id_(rsa|ed25519|ecdsa|dsa)/gi,
|
|
37
|
+
/cat\s+.*\.ssh\/id_/gi,
|
|
38
|
+
/read.*\.ssh\/id_/gi,
|
|
39
|
+
],
|
|
40
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md'],
|
|
41
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'plugin'],
|
|
42
|
+
remediation: 'Never access SSH private keys from configuration files.',
|
|
43
|
+
references: [],
|
|
44
|
+
enabled: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'CRED-003',
|
|
48
|
+
name: 'AWS Credentials Access',
|
|
49
|
+
category: 'credentials',
|
|
50
|
+
severity: 'CRITICAL',
|
|
51
|
+
description: 'Detects attempts to access AWS credential files',
|
|
52
|
+
patterns: [
|
|
53
|
+
/\.aws\/credentials/gi,
|
|
54
|
+
/\.aws\/config/gi,
|
|
55
|
+
/cat\s+.*\.aws\/(credentials|config)/gi,
|
|
56
|
+
/AWS_ACCESS_KEY_ID/gi,
|
|
57
|
+
/AWS_SECRET_ACCESS_KEY/gi,
|
|
58
|
+
],
|
|
59
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md', 'json'],
|
|
60
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'plugin', 'settings'],
|
|
61
|
+
remediation: 'Never access AWS credentials from configuration files.',
|
|
62
|
+
references: [],
|
|
63
|
+
enabled: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'CRED-004',
|
|
67
|
+
name: 'Environment File Access',
|
|
68
|
+
category: 'credentials',
|
|
69
|
+
severity: 'HIGH',
|
|
70
|
+
description: 'Detects attempts to read .env or credential files',
|
|
71
|
+
patterns: [
|
|
72
|
+
/cat\s+.*\.(env|credentials|pem|key|crt)/gi,
|
|
73
|
+
/read.*\.(env|credentials)/gi,
|
|
74
|
+
/source\s+.*\.env/gi,
|
|
75
|
+
/\.\s+.*\.env/gi,
|
|
76
|
+
],
|
|
77
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md'],
|
|
78
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'plugin'],
|
|
79
|
+
remediation: 'Avoid reading .env or credential files in hooks and skills.',
|
|
80
|
+
references: [],
|
|
81
|
+
enabled: true,
|
|
82
|
+
// Filter out documentation about .env file handling
|
|
83
|
+
excludePatterns: [
|
|
84
|
+
/\.env\.example/gi, // References to example files
|
|
85
|
+
/\.env\s+(file\s+)?(configuration|handling|detection)/gi,
|
|
86
|
+
/if\s+.*\.env.*exists/gi, // Conditional checks in docs
|
|
87
|
+
/warns?\s+(if|when).*\.env/gi, // Warning descriptions
|
|
88
|
+
],
|
|
89
|
+
excludeContext: [
|
|
90
|
+
/auto[- ]?detect/gi,
|
|
91
|
+
/environment\s+(from|detection|configuration)/gi,
|
|
92
|
+
/documentation|readme/gi,
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 'CRED-005',
|
|
97
|
+
name: 'Hardcoded API Keys',
|
|
98
|
+
category: 'credentials',
|
|
99
|
+
severity: 'CRITICAL',
|
|
100
|
+
description: 'Detects potentially hardcoded API keys or secrets',
|
|
101
|
+
patterns: [
|
|
102
|
+
/api[_-]?key\s*[:=]\s*["'][a-zA-Z0-9]{20,}/gi,
|
|
103
|
+
/secret[_-]?key\s*[:=]\s*["'][a-zA-Z0-9]{20,}/gi,
|
|
104
|
+
/password\s*[:=]\s*["'][^"']{8,}/gi,
|
|
105
|
+
/sk-[a-zA-Z0-9]{20,}/gi, // OpenAI API key pattern
|
|
106
|
+
/ghp_[a-zA-Z0-9]{36}/gi, // GitHub personal access token
|
|
107
|
+
/gho_[a-zA-Z0-9]{36}/gi, // GitHub OAuth token
|
|
108
|
+
/glpat-[a-zA-Z0-9\-_]{20,}/gi, // GitLab personal access token
|
|
109
|
+
],
|
|
110
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md', 'json', 'yaml', 'yml'],
|
|
111
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'settings', 'plugin', 'mcp'],
|
|
112
|
+
remediation: 'Never hardcode API keys or secrets. Use environment variables or secret management.',
|
|
113
|
+
references: [],
|
|
114
|
+
enabled: true,
|
|
115
|
+
// Filter out test passwords, validation messages, and placeholders
|
|
116
|
+
excludePatterns: [
|
|
117
|
+
/password\s*[:=]\s*["'](test|example|demo|sample|fake|dummy|placeholder)/gi,
|
|
118
|
+
/password\s*[:=]\s*["'].*required/gi, // "Password is required"
|
|
119
|
+
/password\s*[:=]\s*["'].*must\s+(be|have|contain)/gi, // Validation messages
|
|
120
|
+
/password\s*[:=]\s*["'].*at\s+least/gi, // "must be at least 8 chars"
|
|
121
|
+
/password\s*[:=]\s*["'].*characters?/gi, // Length validation messages
|
|
122
|
+
/password\s*[:=]\s*["'].*invalid/gi, // "Invalid password"
|
|
123
|
+
/password\s*[:=]\s*["'].*enter/gi, // "Please enter password"
|
|
124
|
+
/password\s*[:=]\s*["']your[_\s]?password/gi, // Placeholder text
|
|
125
|
+
/password\s*[:=]\s*["']<[^>]+>/gi, // Placeholder like <password>
|
|
126
|
+
/password\s*[:=]\s*["']\*{3,}/gi, // Masked passwords like ****
|
|
127
|
+
/password\s*[:=]\s*["']x{8,}/gi, // Placeholder like xxxxxxxx
|
|
128
|
+
/api[_-]?key\s*[:=]\s*["'](test|example|demo|your[_-]?api[_-]?key)/gi,
|
|
129
|
+
/secret[_-]?key\s*[:=]\s*["'](test|example|demo|your[_-]?secret)/gi,
|
|
130
|
+
],
|
|
131
|
+
excludeContext: [
|
|
132
|
+
/\b(test|spec|mock|fixture|example|sample)\b/gi,
|
|
133
|
+
/validation\s+(message|error|text)/gi,
|
|
134
|
+
/error\s+message/gi,
|
|
135
|
+
/placeholder/gi,
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: 'CRED-006',
|
|
140
|
+
name: 'Credential Harvesting Instructions',
|
|
141
|
+
category: 'credentials',
|
|
142
|
+
severity: 'CRITICAL',
|
|
143
|
+
description: 'Detects markdown instructions to collect or expose credentials',
|
|
144
|
+
patterns: [
|
|
145
|
+
/collect\s+.*(api[_-]?key|token|secret|password|credential)/gi,
|
|
146
|
+
/extract\s+.*(api[_-]?key|token|secret|password|credential)/gi,
|
|
147
|
+
/find\s+.*(api[_-]?key|token|secret|password|credential)/gi,
|
|
148
|
+
/show\s+(me\s+)?(the\s+)?(api[_-]?key|token|secret|password|credential)/gi,
|
|
149
|
+
/output\s+.*(api[_-]?key|token|secret|password|credential)/gi,
|
|
150
|
+
],
|
|
151
|
+
fileTypes: ['md'],
|
|
152
|
+
components: ['skill', 'agent', 'ai-config-md'],
|
|
153
|
+
remediation: 'Remove instructions that direct credential collection or exposure.',
|
|
154
|
+
references: [],
|
|
155
|
+
enabled: true,
|
|
156
|
+
// Filter out UI elements, security scanning descriptions, and form field documentation
|
|
157
|
+
excludePatterns: [
|
|
158
|
+
/show\s+password\s+(toggle|field|input|icon|button)/gi,
|
|
159
|
+
/password\s+(toggle|field|input|visibility)/gi,
|
|
160
|
+
/find\s+(leaked|exposed).*credential/gi, // Security scanning descriptions
|
|
161
|
+
/token\s+(usage|count|limit)/gi, // Token metrics, not harvesting
|
|
162
|
+
],
|
|
163
|
+
excludeContext: [
|
|
164
|
+
/\bUI\b|user\s+interface/gi,
|
|
165
|
+
/form\s+(field|element|input|design)/gi,
|
|
166
|
+
/toggle\s+(button|icon|visibility)/gi,
|
|
167
|
+
/security\s+(scan|audit|check|detection)/gi,
|
|
168
|
+
/secret\s+detection/gi,
|
|
169
|
+
/eye\s+icon/gi,
|
|
170
|
+
/input\s+(field|element)/gi,
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
id: 'CRED-007',
|
|
175
|
+
name: 'Keychain/Keyring Access',
|
|
176
|
+
category: 'credentials',
|
|
177
|
+
severity: 'CRITICAL',
|
|
178
|
+
description: 'Detects attempts to access system keychains or password stores',
|
|
179
|
+
patterns: [
|
|
180
|
+
/security\s+find-generic-password/gi,
|
|
181
|
+
/security\s+find-internet-password/gi,
|
|
182
|
+
/keychain/gi,
|
|
183
|
+
/secret-tool/gi,
|
|
184
|
+
/pass\s+show/gi,
|
|
185
|
+
],
|
|
186
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md'],
|
|
187
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'plugin'],
|
|
188
|
+
remediation: 'Never access system keychains from configuration files.',
|
|
189
|
+
references: [],
|
|
190
|
+
enabled: true,
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
export default credentialRules;
|
|
194
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Exfiltration Detection Rules
|
|
3
|
+
* Detects attempts to send sensitive data to external servers
|
|
4
|
+
*/
|
|
5
|
+
import type { Rule } from '../types.js';
|
|
6
|
+
export declare const exfiltrationRules: Rule[];
|
|
7
|
+
export default exfiltrationRules;
|
|
8
|
+
//# sourceMappingURL=exfiltration.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Exfiltration Detection Rules
|
|
3
|
+
* Detects attempts to send sensitive data to external servers
|
|
4
|
+
*/
|
|
5
|
+
export const exfiltrationRules = [
|
|
6
|
+
{
|
|
7
|
+
id: 'EXFIL-001',
|
|
8
|
+
name: 'Network Exfiltration via curl',
|
|
9
|
+
category: 'exfiltration',
|
|
10
|
+
severity: 'CRITICAL',
|
|
11
|
+
description: 'Detects curl commands that may exfiltrate sensitive data including API keys, tokens, or environment variables',
|
|
12
|
+
patterns: [
|
|
13
|
+
/curl\s+.*\$\{?[A-Z_]*(KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL)/gi,
|
|
14
|
+
/curl\s+.*-d\s+.*\$\(/gi,
|
|
15
|
+
/curl\s+.*--data.*\$\{?[A-Z_]*(KEY|TOKEN|SECRET)/gi,
|
|
16
|
+
/curl\s+.*-X\s+POST.*\$\(/gi,
|
|
17
|
+
/curl\s+.*\$\(env\)/gi,
|
|
18
|
+
/curl\s+.*\$ENV/gi,
|
|
19
|
+
],
|
|
20
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md'],
|
|
21
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'plugin'],
|
|
22
|
+
remediation: 'Remove external data transmission commands. Never send environment variables or secrets to external endpoints.',
|
|
23
|
+
references: [
|
|
24
|
+
'https://owasp.org/www-community/attacks/Data_Exfiltration',
|
|
25
|
+
],
|
|
26
|
+
enabled: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'EXFIL-002',
|
|
30
|
+
name: 'Network Exfiltration via wget',
|
|
31
|
+
category: 'exfiltration',
|
|
32
|
+
severity: 'CRITICAL',
|
|
33
|
+
description: 'Detects wget commands that may exfiltrate sensitive data via POST requests',
|
|
34
|
+
patterns: [
|
|
35
|
+
/wget\s+.*--post-data.*\$\{?[A-Z_]*(KEY|TOKEN|SECRET|PASSWORD)/gi,
|
|
36
|
+
/wget\s+.*--post-file/gi,
|
|
37
|
+
/wget\s+.*-O\s*-.*\|/gi,
|
|
38
|
+
],
|
|
39
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md'],
|
|
40
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'plugin'],
|
|
41
|
+
remediation: 'Remove wget commands that transmit data externally.',
|
|
42
|
+
references: [],
|
|
43
|
+
enabled: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'EXFIL-003',
|
|
47
|
+
name: 'Netcat Data Transmission',
|
|
48
|
+
category: 'exfiltration',
|
|
49
|
+
severity: 'CRITICAL',
|
|
50
|
+
description: 'Detects netcat (nc) commands that may establish reverse connections or transmit data',
|
|
51
|
+
patterns: [
|
|
52
|
+
/nc\s+.*-e\s+\/bin/gi,
|
|
53
|
+
/nc\s+.*\d+\.\d+\.\d+\.\d+\s+\d+/gi,
|
|
54
|
+
/netcat\s+.*-e/gi,
|
|
55
|
+
/ncat\s+.*-e/gi,
|
|
56
|
+
],
|
|
57
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md'],
|
|
58
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'plugin'],
|
|
59
|
+
remediation: 'Remove netcat commands. These are commonly used for data exfiltration and reverse shells.',
|
|
60
|
+
references: [],
|
|
61
|
+
enabled: true,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'EXFIL-004',
|
|
65
|
+
name: 'Base64 Encoded Exfiltration',
|
|
66
|
+
category: 'exfiltration',
|
|
67
|
+
severity: 'HIGH',
|
|
68
|
+
description: 'Detects base64 encoding piped to network commands, a common exfiltration technique',
|
|
69
|
+
patterns: [
|
|
70
|
+
/base64\s+.*\|\s*curl/gi,
|
|
71
|
+
/base64\s+.*\|\s*wget/gi,
|
|
72
|
+
/\|\s*base64\s+.*\|\s*curl/gi,
|
|
73
|
+
/cat\s+.*\|\s*base64\s+.*\|\s*(curl|wget)/gi,
|
|
74
|
+
],
|
|
75
|
+
fileTypes: ['sh', 'bash', 'zsh', 'md'],
|
|
76
|
+
components: ['hook', 'skill', 'agent', 'ai-config-md', 'plugin'],
|
|
77
|
+
remediation: 'Remove base64 encoding combined with network transmission.',
|
|
78
|
+
references: [],
|
|
79
|
+
enabled: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: 'EXFIL-005',
|
|
83
|
+
name: 'Markdown Exfiltration Instructions',
|
|
84
|
+
category: 'exfiltration',
|
|
85
|
+
severity: 'CRITICAL',
|
|
86
|
+
description: 'Detects instructions in markdown files that direct Claude to exfiltrate data',
|
|
87
|
+
patterns: [
|
|
88
|
+
/send\s+.*\s+to\s+.*(webhook|endpoint|server|api|url)/gi,
|
|
89
|
+
/exfiltrate\s+.*(key|token|secret|credential|password|data)/gi,
|
|
90
|
+
/upload\s+.*(key|token|secret|credential|password)\s+to/gi,
|
|
91
|
+
/POST\s+.*containing\s+.*(environment|env|secret|key|token)/gi,
|
|
92
|
+
/transmit\s+.*(secret|key|token|credential)\s+to/gi,
|
|
93
|
+
/leak\s+.*(data|secret|key|token|credential)/gi,
|
|
94
|
+
],
|
|
95
|
+
fileTypes: ['md'],
|
|
96
|
+
components: ['skill', 'agent', 'ai-config-md'],
|
|
97
|
+
remediation: 'Remove instructions that direct data to be sent to external endpoints.',
|
|
98
|
+
references: [],
|
|
99
|
+
enabled: true,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'EXFIL-006',
|
|
103
|
+
name: 'DNS Exfiltration',
|
|
104
|
+
category: 'exfiltration',
|
|
105
|
+
severity: 'HIGH',
|
|
106
|
+
description: 'Detects potential DNS-based data exfiltration techniques',
|
|
107
|
+
patterns: [
|
|
108
|
+
/dig\s+.*\$\{?[A-Z_]/gi,
|
|
109
|
+
/nslookup\s+.*\$\{?[A-Z_]/gi,
|
|
110
|
+
/host\s+.*\$\{?[A-Z_]/gi,
|
|
111
|
+
],
|
|
112
|
+
fileTypes: ['sh', 'bash', 'zsh'],
|
|
113
|
+
components: ['hook', 'plugin'],
|
|
114
|
+
remediation: 'Remove DNS lookups that include variable data. DNS can be used for data exfiltration.',
|
|
115
|
+
references: [],
|
|
116
|
+
enabled: true,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'EXFIL-007',
|
|
120
|
+
name: 'Webhook Data Transmission',
|
|
121
|
+
category: 'exfiltration',
|
|
122
|
+
severity: 'HIGH',
|
|
123
|
+
description: 'Detects webhook URLs being used to transmit potentially sensitive data',
|
|
124
|
+
patterns: [
|
|
125
|
+
/WEBHOOK.*=.*http/gi,
|
|
126
|
+
/webhook.*url.*=.*http/gi,
|
|
127
|
+
/discord\.com\/api\/webhooks/gi,
|
|
128
|
+
/hooks\.slack\.com/gi,
|
|
129
|
+
/webhook\.site/gi,
|
|
130
|
+
],
|
|
131
|
+
fileTypes: ['sh', 'bash', 'zsh', 'json', 'md'],
|
|
132
|
+
components: ['hook', 'settings', 'skill', 'agent', 'ai-config-md'],
|
|
133
|
+
remediation: 'Review webhook usage. Ensure no sensitive data is being transmitted to external webhooks.',
|
|
134
|
+
references: [],
|
|
135
|
+
enabled: true,
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
export default exfiltrationRules;
|
|
139
|
+
//# sourceMappingURL=exfiltration.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule Registry - Manages all security detection rules
|
|
3
|
+
*/
|
|
4
|
+
import type { Rule, ThreatCategory, Severity } from '../types.js';
|
|
5
|
+
import { exfiltrationRules } from './exfiltration.js';
|
|
6
|
+
import { credentialRules } from './credentials.js';
|
|
7
|
+
import { injectionRules } from './injection.js';
|
|
8
|
+
import { backdoorRules } from './backdoors.js';
|
|
9
|
+
import { obfuscationRules } from './obfuscation.js';
|
|
10
|
+
import { permissionRules } from './permissions.js';
|
|
11
|
+
import { persistenceRules } from './persistence.js';
|
|
12
|
+
import { supplyChainRules } from './supply-chain.js';
|
|
13
|
+
import { aiSpecificRules } from './ai-specific.js';
|
|
14
|
+
import { semanticRules } from './semanticRules.js';
|
|
15
|
+
import { correlationRules } from './correlationRules.js';
|
|
16
|
+
/**
|
|
17
|
+
* Get all rules
|
|
18
|
+
*/
|
|
19
|
+
export declare function getAllRules(): Rule[];
|
|
20
|
+
/**
|
|
21
|
+
* Get rules filtered by categories
|
|
22
|
+
*/
|
|
23
|
+
export declare function getRulesByCategories(categories: ThreatCategory[]): Rule[];
|
|
24
|
+
/**
|
|
25
|
+
* Get rules filtered by severity
|
|
26
|
+
*/
|
|
27
|
+
export declare function getRulesBySeverity(severities: Severity[]): Rule[];
|
|
28
|
+
/**
|
|
29
|
+
* Get a specific rule by ID
|
|
30
|
+
*/
|
|
31
|
+
export declare function getRuleById(id: string): Rule | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Get enabled rules only
|
|
34
|
+
*/
|
|
35
|
+
export declare function getEnabledRules(): Rule[];
|
|
36
|
+
/**
|
|
37
|
+
* Get rules for scanning with filters applied
|
|
38
|
+
*/
|
|
39
|
+
export declare function getRulesForScan(categories: ThreatCategory[], severities: Severity[]): Rule[];
|
|
40
|
+
/**
|
|
41
|
+
* Get rule statistics
|
|
42
|
+
*/
|
|
43
|
+
export declare function getRuleStats(): {
|
|
44
|
+
total: number;
|
|
45
|
+
enabled: number;
|
|
46
|
+
byCategory: Record<ThreatCategory, number>;
|
|
47
|
+
bySeverity: Record<Severity, number>;
|
|
48
|
+
};
|
|
49
|
+
export { exfiltrationRules, credentialRules, injectionRules, backdoorRules, obfuscationRules, permissionRules, persistenceRules, supplyChainRules, aiSpecificRules, semanticRules, correlationRules, };
|
|
50
|
+
export default getAllRules;
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|