muaddib-scanner 2.4.13 → 2.4.15
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/LICENSE +20 -20
- package/iocs/builtin.yaml +131 -131
- package/iocs/packages.yaml +276 -276
- package/package.json +2 -3
- package/src/canary-tokens.js +184 -184
- package/src/ioc/bootstrap.js +181 -181
- package/src/ioc/yaml-loader.js +223 -223
- package/src/maintainer-change.js +224 -224
- package/src/output-formatter.js +192 -192
- package/src/publish-anomaly.js +206 -206
- package/src/report.js +230 -230
- package/src/sarif.js +96 -96
- package/src/scanner/ai-config.js +183 -183
- package/src/scanner/dependencies.js +223 -223
- package/src/scanner/hash.js +118 -118
- package/src/scanner/npm-registry.js +128 -128
- package/src/scanner/python.js +442 -442
- package/src/shared/analyze-helper.js +49 -49
- package/src/temporal-analysis.js +260 -260
- package/src/temporal-runner.js +139 -139
- package/src/utils.js +327 -327
- package/src/watch.js +55 -55
package/src/scanner/ai-config.js
CHANGED
|
@@ -1,183 +1,183 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI Config Injection Scanner
|
|
3
|
-
*
|
|
4
|
-
* Detects prompt injection attacks hidden in AI agent configuration files:
|
|
5
|
-
* .cursorrules, CLAUDE.md, AGENT.md, .github/copilot-instructions.md,
|
|
6
|
-
* copilot-setup-steps.yml, .cursorignore, .windsurfrules, etc.
|
|
7
|
-
*
|
|
8
|
-
* These files are designed to be read by AI coding assistants and may contain
|
|
9
|
-
* hidden instructions to execute shell commands, exfiltrate secrets, or
|
|
10
|
-
* download and run remote payloads.
|
|
11
|
-
*
|
|
12
|
-
* References:
|
|
13
|
-
* - ToxicSkills (Snyk, Feb 2026)
|
|
14
|
-
* - NVIDIA AI agent security guidance
|
|
15
|
-
* - arxiv 2601.17548 (prompt injection in AI agents)
|
|
16
|
-
* - Clinejection (Snyk, Feb 2026)
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const fs = require('fs');
|
|
20
|
-
const path = require('path');
|
|
21
|
-
|
|
22
|
-
// AI agent config files to scan (relative to project root)
|
|
23
|
-
const AI_CONFIG_FILES = [
|
|
24
|
-
'.cursorrules',
|
|
25
|
-
'.cursorignore',
|
|
26
|
-
'.windsurfrules',
|
|
27
|
-
'CLAUDE.md',
|
|
28
|
-
'AGENT.md',
|
|
29
|
-
'.github/copilot-instructions.md',
|
|
30
|
-
'copilot-setup-steps.yml',
|
|
31
|
-
'.github/copilot-setup-steps.yml'
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
// Dangerous shell command patterns in AI config files
|
|
35
|
-
const SHELL_COMMAND_PATTERNS = [
|
|
36
|
-
// Download and execute
|
|
37
|
-
{ regex: /curl\s+[^\n]*\|\s*(sh|bash|zsh)\b/i, label: 'curl pipe to shell', critical: true },
|
|
38
|
-
{ regex: /wget\s+[^\n]*\|\s*(sh|bash|zsh)\b/i, label: 'wget pipe to shell', critical: true },
|
|
39
|
-
{ regex: /curl\s+-[sS]*L?\s+https?:\/\/[^\s"']+\s*\|\s*(sh|bash)/i, label: 'curl download and execute', critical: true },
|
|
40
|
-
{ regex: /wget\s+-[qQ]*O?-?\s+https?:\/\/[^\s"']+\s*\|\s*(sh|bash)/i, label: 'wget download and execute', critical: true },
|
|
41
|
-
|
|
42
|
-
// Direct shell execution
|
|
43
|
-
{ regex: /\beval\s*\(/i, label: 'eval() call', critical: false },
|
|
44
|
-
{ regex: /\bexec\s*\(/i, label: 'exec() call', critical: false },
|
|
45
|
-
{ regex: /\bsource\s+\.env\b/i, label: 'source .env', critical: false },
|
|
46
|
-
{ regex: /\bsh\s+-c\s+["']/i, label: 'sh -c execution', critical: false },
|
|
47
|
-
{ regex: /\bbash\s+-c\s+["']/i, label: 'bash -c execution', critical: false },
|
|
48
|
-
{ regex: /\bnode\s+-e\s+["']/i, label: 'node -e inline execution', critical: false },
|
|
49
|
-
{ regex: /\bpython[3]?\s+-c\s+["']/i, label: 'python -c inline execution', critical: false }
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
// Exfiltration patterns — sending data to external endpoints
|
|
53
|
-
const EXFIL_PATTERNS = [
|
|
54
|
-
{ regex: /curl\s+[^\n]*-X\s*POST\s+[^\n]*https?:\/\/(?!api\.github\.com|registry\.npmjs\.org)[^\s"']+/i, label: 'curl POST to external endpoint' },
|
|
55
|
-
{ regex: /curl\s+[^\n]*-d\s+[^\n]*https?:\/\/(?!api\.github\.com|registry\.npmjs\.org)[^\s"']+/i, label: 'curl data upload to external endpoint' },
|
|
56
|
-
{ regex: /curl\s+[^\n]*https?:\/\/(?!api\.github\.com|registry\.npmjs\.org)[^\s"']+[^\n]*-d\s/i, label: 'curl data upload to external endpoint' },
|
|
57
|
-
{ regex: /\|\s*curl\s+[^\n]*https?:\/\/(?!api\.github\.com|registry\.npmjs\.org)/i, label: 'pipe output to curl' },
|
|
58
|
-
{ regex: /\|\s*base64\s*\|\s*curl/i, label: 'base64 encode and send via curl' }
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
// Credential access patterns — reading sensitive files/vars
|
|
62
|
-
const CREDENTIAL_ACCESS_PATTERNS = [
|
|
63
|
-
{ regex: /cat\s+~?\/?\.ssh\/id_/i, label: 'read SSH private key' },
|
|
64
|
-
{ regex: /cat\s+~?\/?\.npmrc/i, label: 'read .npmrc tokens' },
|
|
65
|
-
{ regex: /cat\s+~?\/?\.aws\/credentials/i, label: 'read AWS credentials' },
|
|
66
|
-
{ regex: /cat\s+~?\/?\.env\b/i, label: 'read .env file' },
|
|
67
|
-
{ regex: /cat\s+~?\/?\.gnupg\//i, label: 'read GPG keys' },
|
|
68
|
-
{ regex: /\$GITHUB_TOKEN|\$GH_TOKEN|\$NPM_TOKEN|\$AWS_SECRET_ACCESS_KEY|\$DISCORD_TOKEN/i, label: 'reference to secret env var' },
|
|
69
|
-
{ regex: /grep\s+[^\n]*(TOKEN|KEY|SECRET|PASSWORD|CREDENTIAL)[^\n]*/i, label: 'grep for secrets' },
|
|
70
|
-
{ regex: /env\s*\|\s*grep\s+[^\n]*(TOKEN|KEY|SECRET|PASSWORD)/i, label: 'env grep for secrets' }
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
// Instruction patterns — AI prompt injection directives
|
|
74
|
-
const INJECTION_INSTRUCTION_PATTERNS = [
|
|
75
|
-
{ regex: /before\s+(reviewing|running|any|code|generating)[^\n]*(run|execute|source):/i, label: 'instruction to execute before review' },
|
|
76
|
-
{ regex: /always\s+run\s+[^\n]*(before|first|initially)/i, label: 'instruction to always run command' },
|
|
77
|
-
{ regex: /send\s+(contents?|data|output|results?)\s+(to|via)\s+https?:\/\//i, label: 'instruction to send data to URL' },
|
|
78
|
-
{ regex: /upload\s+[^\n]*(to|via)\s+https?:\/\//i, label: 'instruction to upload to URL' },
|
|
79
|
-
{ regex: /do\s+not\s+(display|show|output|mention|tell)/i, label: 'instruction to hide activity' }
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Scan AI config files for prompt injection
|
|
84
|
-
*/
|
|
85
|
-
function scanAIConfig(targetPath) {
|
|
86
|
-
const threats = [];
|
|
87
|
-
|
|
88
|
-
for (const configFile of AI_CONFIG_FILES) {
|
|
89
|
-
const filePath = path.join(targetPath, configFile);
|
|
90
|
-
|
|
91
|
-
if (!fs.existsSync(filePath)) continue;
|
|
92
|
-
|
|
93
|
-
let content;
|
|
94
|
-
try {
|
|
95
|
-
const stat = fs.statSync(filePath);
|
|
96
|
-
if (stat.size > 1024 * 1024) continue; // Skip files > 1MB
|
|
97
|
-
content = fs.readFileSync(filePath, 'utf8');
|
|
98
|
-
} catch {
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const relPath = configFile;
|
|
103
|
-
const fileThreats = analyzeAIConfigFile(content, relPath);
|
|
104
|
-
threats.push(...fileThreats);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return threats;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Analyze a single AI config file for prompt injection patterns
|
|
112
|
-
*/
|
|
113
|
-
function analyzeAIConfigFile(content, relPath) {
|
|
114
|
-
const threats = [];
|
|
115
|
-
let hasShellCommand = false;
|
|
116
|
-
let hasExfiltration = false;
|
|
117
|
-
let hasCredentialAccess = false;
|
|
118
|
-
|
|
119
|
-
// Check shell command patterns
|
|
120
|
-
for (const pattern of SHELL_COMMAND_PATTERNS) {
|
|
121
|
-
if (pattern.regex.test(content)) {
|
|
122
|
-
hasShellCommand = true;
|
|
123
|
-
threats.push({
|
|
124
|
-
type: pattern.critical ? 'ai_config_injection_critical' : 'ai_config_injection',
|
|
125
|
-
severity: pattern.critical ? 'CRITICAL' : 'HIGH',
|
|
126
|
-
message: `AI config prompt injection: ${pattern.label} in ${relPath}`,
|
|
127
|
-
file: relPath
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Check exfiltration patterns
|
|
133
|
-
for (const pattern of EXFIL_PATTERNS) {
|
|
134
|
-
if (pattern.regex.test(content)) {
|
|
135
|
-
hasExfiltration = true;
|
|
136
|
-
threats.push({
|
|
137
|
-
type: 'ai_config_injection_critical',
|
|
138
|
-
severity: 'CRITICAL',
|
|
139
|
-
message: `AI config exfiltration: ${pattern.label} in ${relPath}`,
|
|
140
|
-
file: relPath
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Check credential access patterns
|
|
146
|
-
for (const pattern of CREDENTIAL_ACCESS_PATTERNS) {
|
|
147
|
-
if (pattern.regex.test(content)) {
|
|
148
|
-
hasCredentialAccess = true;
|
|
149
|
-
threats.push({
|
|
150
|
-
type: 'ai_config_injection',
|
|
151
|
-
severity: 'HIGH',
|
|
152
|
-
message: `AI config credential access: ${pattern.label} in ${relPath}`,
|
|
153
|
-
file: relPath
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Check injection instruction patterns
|
|
159
|
-
for (const pattern of INJECTION_INSTRUCTION_PATTERNS) {
|
|
160
|
-
if (pattern.regex.test(content)) {
|
|
161
|
-
threats.push({
|
|
162
|
-
type: 'ai_config_injection',
|
|
163
|
-
severity: 'HIGH',
|
|
164
|
-
message: `AI config prompt injection: ${pattern.label} in ${relPath}`,
|
|
165
|
-
file: relPath
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Compound detection: shell + exfil or credential access → escalate
|
|
171
|
-
if (hasShellCommand && (hasExfiltration || hasCredentialAccess)) {
|
|
172
|
-
threats.push({
|
|
173
|
-
type: 'ai_config_injection_critical',
|
|
174
|
-
severity: 'CRITICAL',
|
|
175
|
-
message: `AI config compound attack: shell commands + ${hasExfiltration ? 'exfiltration' : 'credential access'} in ${relPath} — ToxicSkills/Clinejection pattern.`,
|
|
176
|
-
file: relPath
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return threats;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
module.exports = { scanAIConfig };
|
|
1
|
+
/**
|
|
2
|
+
* AI Config Injection Scanner
|
|
3
|
+
*
|
|
4
|
+
* Detects prompt injection attacks hidden in AI agent configuration files:
|
|
5
|
+
* .cursorrules, CLAUDE.md, AGENT.md, .github/copilot-instructions.md,
|
|
6
|
+
* copilot-setup-steps.yml, .cursorignore, .windsurfrules, etc.
|
|
7
|
+
*
|
|
8
|
+
* These files are designed to be read by AI coding assistants and may contain
|
|
9
|
+
* hidden instructions to execute shell commands, exfiltrate secrets, or
|
|
10
|
+
* download and run remote payloads.
|
|
11
|
+
*
|
|
12
|
+
* References:
|
|
13
|
+
* - ToxicSkills (Snyk, Feb 2026)
|
|
14
|
+
* - NVIDIA AI agent security guidance
|
|
15
|
+
* - arxiv 2601.17548 (prompt injection in AI agents)
|
|
16
|
+
* - Clinejection (Snyk, Feb 2026)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
// AI agent config files to scan (relative to project root)
|
|
23
|
+
const AI_CONFIG_FILES = [
|
|
24
|
+
'.cursorrules',
|
|
25
|
+
'.cursorignore',
|
|
26
|
+
'.windsurfrules',
|
|
27
|
+
'CLAUDE.md',
|
|
28
|
+
'AGENT.md',
|
|
29
|
+
'.github/copilot-instructions.md',
|
|
30
|
+
'copilot-setup-steps.yml',
|
|
31
|
+
'.github/copilot-setup-steps.yml'
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
// Dangerous shell command patterns in AI config files
|
|
35
|
+
const SHELL_COMMAND_PATTERNS = [
|
|
36
|
+
// Download and execute
|
|
37
|
+
{ regex: /curl\s+[^\n]*\|\s*(sh|bash|zsh)\b/i, label: 'curl pipe to shell', critical: true },
|
|
38
|
+
{ regex: /wget\s+[^\n]*\|\s*(sh|bash|zsh)\b/i, label: 'wget pipe to shell', critical: true },
|
|
39
|
+
{ regex: /curl\s+-[sS]*L?\s+https?:\/\/[^\s"']+\s*\|\s*(sh|bash)/i, label: 'curl download and execute', critical: true },
|
|
40
|
+
{ regex: /wget\s+-[qQ]*O?-?\s+https?:\/\/[^\s"']+\s*\|\s*(sh|bash)/i, label: 'wget download and execute', critical: true },
|
|
41
|
+
|
|
42
|
+
// Direct shell execution
|
|
43
|
+
{ regex: /\beval\s*\(/i, label: 'eval() call', critical: false },
|
|
44
|
+
{ regex: /\bexec\s*\(/i, label: 'exec() call', critical: false },
|
|
45
|
+
{ regex: /\bsource\s+\.env\b/i, label: 'source .env', critical: false },
|
|
46
|
+
{ regex: /\bsh\s+-c\s+["']/i, label: 'sh -c execution', critical: false },
|
|
47
|
+
{ regex: /\bbash\s+-c\s+["']/i, label: 'bash -c execution', critical: false },
|
|
48
|
+
{ regex: /\bnode\s+-e\s+["']/i, label: 'node -e inline execution', critical: false },
|
|
49
|
+
{ regex: /\bpython[3]?\s+-c\s+["']/i, label: 'python -c inline execution', critical: false }
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
// Exfiltration patterns — sending data to external endpoints
|
|
53
|
+
const EXFIL_PATTERNS = [
|
|
54
|
+
{ regex: /curl\s+[^\n]*-X\s*POST\s+[^\n]*https?:\/\/(?!api\.github\.com|registry\.npmjs\.org)[^\s"']+/i, label: 'curl POST to external endpoint' },
|
|
55
|
+
{ regex: /curl\s+[^\n]*-d\s+[^\n]*https?:\/\/(?!api\.github\.com|registry\.npmjs\.org)[^\s"']+/i, label: 'curl data upload to external endpoint' },
|
|
56
|
+
{ regex: /curl\s+[^\n]*https?:\/\/(?!api\.github\.com|registry\.npmjs\.org)[^\s"']+[^\n]*-d\s/i, label: 'curl data upload to external endpoint' },
|
|
57
|
+
{ regex: /\|\s*curl\s+[^\n]*https?:\/\/(?!api\.github\.com|registry\.npmjs\.org)/i, label: 'pipe output to curl' },
|
|
58
|
+
{ regex: /\|\s*base64\s*\|\s*curl/i, label: 'base64 encode and send via curl' }
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
// Credential access patterns — reading sensitive files/vars
|
|
62
|
+
const CREDENTIAL_ACCESS_PATTERNS = [
|
|
63
|
+
{ regex: /cat\s+~?\/?\.ssh\/id_/i, label: 'read SSH private key' },
|
|
64
|
+
{ regex: /cat\s+~?\/?\.npmrc/i, label: 'read .npmrc tokens' },
|
|
65
|
+
{ regex: /cat\s+~?\/?\.aws\/credentials/i, label: 'read AWS credentials' },
|
|
66
|
+
{ regex: /cat\s+~?\/?\.env\b/i, label: 'read .env file' },
|
|
67
|
+
{ regex: /cat\s+~?\/?\.gnupg\//i, label: 'read GPG keys' },
|
|
68
|
+
{ regex: /\$GITHUB_TOKEN|\$GH_TOKEN|\$NPM_TOKEN|\$AWS_SECRET_ACCESS_KEY|\$DISCORD_TOKEN/i, label: 'reference to secret env var' },
|
|
69
|
+
{ regex: /grep\s+[^\n]*(TOKEN|KEY|SECRET|PASSWORD|CREDENTIAL)[^\n]*/i, label: 'grep for secrets' },
|
|
70
|
+
{ regex: /env\s*\|\s*grep\s+[^\n]*(TOKEN|KEY|SECRET|PASSWORD)/i, label: 'env grep for secrets' }
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
// Instruction patterns — AI prompt injection directives
|
|
74
|
+
const INJECTION_INSTRUCTION_PATTERNS = [
|
|
75
|
+
{ regex: /before\s+(reviewing|running|any|code|generating)[^\n]*(run|execute|source):/i, label: 'instruction to execute before review' },
|
|
76
|
+
{ regex: /always\s+run\s+[^\n]*(before|first|initially)/i, label: 'instruction to always run command' },
|
|
77
|
+
{ regex: /send\s+(contents?|data|output|results?)\s+(to|via)\s+https?:\/\//i, label: 'instruction to send data to URL' },
|
|
78
|
+
{ regex: /upload\s+[^\n]*(to|via)\s+https?:\/\//i, label: 'instruction to upload to URL' },
|
|
79
|
+
{ regex: /do\s+not\s+(display|show|output|mention|tell)/i, label: 'instruction to hide activity' }
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Scan AI config files for prompt injection
|
|
84
|
+
*/
|
|
85
|
+
function scanAIConfig(targetPath) {
|
|
86
|
+
const threats = [];
|
|
87
|
+
|
|
88
|
+
for (const configFile of AI_CONFIG_FILES) {
|
|
89
|
+
const filePath = path.join(targetPath, configFile);
|
|
90
|
+
|
|
91
|
+
if (!fs.existsSync(filePath)) continue;
|
|
92
|
+
|
|
93
|
+
let content;
|
|
94
|
+
try {
|
|
95
|
+
const stat = fs.statSync(filePath);
|
|
96
|
+
if (stat.size > 1024 * 1024) continue; // Skip files > 1MB
|
|
97
|
+
content = fs.readFileSync(filePath, 'utf8');
|
|
98
|
+
} catch {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const relPath = configFile;
|
|
103
|
+
const fileThreats = analyzeAIConfigFile(content, relPath);
|
|
104
|
+
threats.push(...fileThreats);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return threats;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Analyze a single AI config file for prompt injection patterns
|
|
112
|
+
*/
|
|
113
|
+
function analyzeAIConfigFile(content, relPath) {
|
|
114
|
+
const threats = [];
|
|
115
|
+
let hasShellCommand = false;
|
|
116
|
+
let hasExfiltration = false;
|
|
117
|
+
let hasCredentialAccess = false;
|
|
118
|
+
|
|
119
|
+
// Check shell command patterns
|
|
120
|
+
for (const pattern of SHELL_COMMAND_PATTERNS) {
|
|
121
|
+
if (pattern.regex.test(content)) {
|
|
122
|
+
hasShellCommand = true;
|
|
123
|
+
threats.push({
|
|
124
|
+
type: pattern.critical ? 'ai_config_injection_critical' : 'ai_config_injection',
|
|
125
|
+
severity: pattern.critical ? 'CRITICAL' : 'HIGH',
|
|
126
|
+
message: `AI config prompt injection: ${pattern.label} in ${relPath}`,
|
|
127
|
+
file: relPath
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Check exfiltration patterns
|
|
133
|
+
for (const pattern of EXFIL_PATTERNS) {
|
|
134
|
+
if (pattern.regex.test(content)) {
|
|
135
|
+
hasExfiltration = true;
|
|
136
|
+
threats.push({
|
|
137
|
+
type: 'ai_config_injection_critical',
|
|
138
|
+
severity: 'CRITICAL',
|
|
139
|
+
message: `AI config exfiltration: ${pattern.label} in ${relPath}`,
|
|
140
|
+
file: relPath
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Check credential access patterns
|
|
146
|
+
for (const pattern of CREDENTIAL_ACCESS_PATTERNS) {
|
|
147
|
+
if (pattern.regex.test(content)) {
|
|
148
|
+
hasCredentialAccess = true;
|
|
149
|
+
threats.push({
|
|
150
|
+
type: 'ai_config_injection',
|
|
151
|
+
severity: 'HIGH',
|
|
152
|
+
message: `AI config credential access: ${pattern.label} in ${relPath}`,
|
|
153
|
+
file: relPath
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Check injection instruction patterns
|
|
159
|
+
for (const pattern of INJECTION_INSTRUCTION_PATTERNS) {
|
|
160
|
+
if (pattern.regex.test(content)) {
|
|
161
|
+
threats.push({
|
|
162
|
+
type: 'ai_config_injection',
|
|
163
|
+
severity: 'HIGH',
|
|
164
|
+
message: `AI config prompt injection: ${pattern.label} in ${relPath}`,
|
|
165
|
+
file: relPath
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Compound detection: shell + exfil or credential access → escalate
|
|
171
|
+
if (hasShellCommand && (hasExfiltration || hasCredentialAccess)) {
|
|
172
|
+
threats.push({
|
|
173
|
+
type: 'ai_config_injection_critical',
|
|
174
|
+
severity: 'CRITICAL',
|
|
175
|
+
message: `AI config compound attack: shell commands + ${hasExfiltration ? 'exfiltration' : 'credential access'} in ${relPath} — ToxicSkills/Clinejection pattern.`,
|
|
176
|
+
file: relPath
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return threats;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
module.exports = { scanAIConfig };
|