@yagyeshvyas/vibeguard 1.3.0 → 1.11.1
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/.vibeguard-mcp.example.json +51 -0
- package/CHANGELOG.md +604 -216
- package/MCP-FIREWALL.md +296 -0
- package/README.md +355 -31
- package/bin/cli.js +355 -27
- package/bin/cmd-agent-monitor.js +45 -0
- package/bin/cmd-agent-risk.js +64 -0
- package/bin/cmd-gif.js +62 -0
- package/bin/cmd-git-scan.js +74 -0
- package/bin/cmd-llm-proxy.js +164 -0
- package/bin/cmd-mcp-firewall.js +191 -0
- package/bin/cmd-pentest.js +103 -0
- package/bin/cmd-platform.js +137 -0
- package/bin/cmd-pr-scan.js +135 -0
- package/bin/cmd-sbom-diff.js +38 -0
- package/bin/cmd-skill-scan.js +35 -0
- package/docs/AISVS.md +25 -0
- package/docs/ARCHITECTURE.md +81 -0
- package/docs/INSTALLATION.md +139 -0
- package/docs/WINDOWS.md +74 -0
- package/docs/security-policy.strict.example.json +134 -0
- package/docs/security-policy.strict.example.pub.pem +3 -0
- package/package.json +45 -7
- package/src/.vibeguard/cache/file-hashes.json +60 -0
- package/src/.vibeguard/latest-snapshot.json +36 -0
- package/src/.vibeguard/mcp-pins.json +1 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +279 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +151 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +65 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +2051 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +150 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +1611 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +164 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +292 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +144 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +37 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +2055 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +279 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +151 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +65 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +2055 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +150 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +1611 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +164 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +292 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +144 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +279 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +151 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +65 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +2054 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +150 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +1611 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +164 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +292 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +144 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +37 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +2055 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +33 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +2055 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +1611 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +292 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +220 -0
- package/src/.vibeguard-baseline.json +5226 -0
- package/src/action-guard.js +84 -6
- package/src/agent-monitor.js +262 -0
- package/src/agent-policy.js +642 -0
- package/src/agent-risk.js +271 -0
- package/src/agentic.js +1513 -0
- package/src/ast.js +165 -7
- package/src/audit-trail.js +212 -67
- package/src/auto.js +427 -427
- package/src/autofix.js +11 -4
- package/src/bundles.js +198 -0
- package/src/daemon.js +343 -343
- package/src/dashboard.js +278 -278
- package/src/engine.js +3 -0
- package/src/entropy.js +187 -0
- package/src/firewall.js +19 -3
- package/src/gif.js +134 -0
- package/src/gitscan.js +282 -0
- package/src/hook.js +151 -151
- package/src/injection-decode.js +136 -0
- package/src/install.js +298 -280
- package/src/integrity.js +16 -1
- package/src/integrity.json +43 -13
- package/src/interceptor.js +12 -9
- package/src/llm-proxy.js +986 -0
- package/src/mcp-audit.js +61 -5
- package/src/mcp-firewall.js +971 -0
- package/src/mcp-server.js +2500 -2047
- package/src/obfuscation.js +315 -0
- package/src/owasp-agentic.js +314 -0
- package/src/pentest.js +589 -0
- package/src/pii.js +4 -0
- package/src/platform/aisvs.js +38 -0
- package/src/platform/approval.js +187 -0
- package/src/platform/canonical.js +73 -0
- package/src/platform/contracts.js +158 -0
- package/src/platform/delegation.js +73 -0
- package/src/platform/http-gateway.js +177 -0
- package/src/platform/identity.js +253 -0
- package/src/platform/jwt.js +86 -0
- package/src/platform/mcp-http-bridge.js +199 -0
- package/src/platform/memory-guard.js +64 -0
- package/src/platform/os-sandbox.js +144 -0
- package/src/platform/policy.js +332 -0
- package/src/platform/sandbox-manager.js +92 -0
- package/src/platform/signed-audit.js +357 -0
- package/src/platform/ssrf.js +129 -0
- package/src/plugin.js +182 -168
- package/src/pre-deploy.js +170 -55
- package/src/privacy-audit.js +272 -272
- package/src/repl.js +150 -150
- package/src/report.js +7 -1
- package/src/routes.js +1210 -0
- package/src/rules-2026.js +1407 -0
- package/src/rules-pack.js +3068 -3019
- package/src/rules.js +376 -60
- package/src/sandbox.js +200 -10
- package/src/sbom.js +193 -164
- package/src/scanner.js +189 -33
- package/src/shell-guard.js +11 -0
- package/src/skill-scan.js +477 -0
- package/src/slopsquat.js +144 -144
- package/src/surface.js +408 -0
- package/src/taint-ast.js +204 -37
- package/src/taint.js +15 -3
- package/src/tokenlean.js +579 -0
- package/src/trace.js +220 -220
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Obfuscation / backdoor analysis.
|
|
5
|
+
*
|
|
6
|
+
* Regex rule packs detect visible sinks (`eval(`…). They do not decode a payload,
|
|
7
|
+
* correlate behaviour, or notice that a "minified helper" contains a network
|
|
8
|
+
* client, the environment, and a shell. This pass does the reverse: it looks for
|
|
9
|
+
* hidden code and for capability combinations that no honest file needs.
|
|
10
|
+
*
|
|
11
|
+
* Everything is local, deterministic and bounded (decode at most 3 layers, cap
|
|
12
|
+
* payload size). It runs per file and returns ordinary findings.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const MAX_DECODE = 3;
|
|
16
|
+
const MAX_BLOB = 64 * 1024;
|
|
17
|
+
|
|
18
|
+
// Dangerous capabilities inside a decoded payload.
|
|
19
|
+
const DANGER = [
|
|
20
|
+
{ re: /require\(\s*['"]child_process['"]\s*\)|from\s+['"]child_process['"]|execSync|exec\(|spawn\(/, label: 'process execution', weight: 3 },
|
|
21
|
+
{ re: /\brequire\(\s*['"](?:http|https|net|tls|dgram)['"]\s*\)|from\s+['"](?:http|https|net|dgram)['"]|fetch\(|axios\./, label: 'network access', weight: 2 },
|
|
22
|
+
{ re: /process\.env|os\.environ|getenv/, label: 'environment access', weight: 2 },
|
|
23
|
+
{ re: /fs\.(?:readFile|writeFile|appendFile|unlink|readdir)|os\.remove|shutil\.rmtree/, label: 'filesystem access', weight: 2 },
|
|
24
|
+
{ re: /\beval\b|\bFunction\s*\(|vm\.runIn|new\s+Function/, label: 'dynamic code', weight: 3 },
|
|
25
|
+
{ re: /\.ssh|id_rsa|authorized_keys|ssh-rsa/, label: 'SSH credential access', weight: 4 },
|
|
26
|
+
{ re: /\/etc\/passwd|\/etc\/shadow|crontab|launchctl|schtasks|reg\s+add|systemd/, label: 'persistence', weight: 4 },
|
|
27
|
+
{ re: /wallet|mnemonic|bitcoin|ethereum|privateKey|keystore/, label: 'wallet/credential theft', weight: 4 },
|
|
28
|
+
{ re: /powershell|cmd\.exe|\bwscript\b|\bcscript\b|mshta/, label: 'Windows execution', weight: 3 },
|
|
29
|
+
{ re: /base64|atob\(|btoa\(/, label: 'second-layer encoding', weight: 1 },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
// Names that look like obfuscator.io output.
|
|
33
|
+
const OBFUSCATOR_MARKERS = [
|
|
34
|
+
{ re: /\b_0x[0-9a-f]{4,}\b/g, label: '_0x identifiers', min: 12 },
|
|
35
|
+
{ re: /while\s*\(\s*!!\s*\[\s*\]\s*\)/, label: 'string-array rotation', min: 1 },
|
|
36
|
+
{ re: /\b(?:var|let|const)\s+\w+\s*=\s*\[\s*(?:'\\x[0-9a-f]{2}'|"\\x[0-9a-f]{2}")(?:\s*,\s*(?:'\\x[0-9a-f]{2}'|"\\x[0-9a-f]{2}")){4,}\s*\]/i, label: 'hex string array', min: 1 },
|
|
37
|
+
{ re: /\}\s*\(\s*\d{3,}\s*\)\s*\)\s*\)?\s*;?\s*$/, label: 'decoder IIFE', min: 1 },
|
|
38
|
+
{ re: /\[\s*!!\s*\[\s*\]\s*\]\s*\+/, label: 'JSFuck coercion', min: 1 },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const SKIP_FILE = /(?:\.min\.(?:js|css)|\.map|(?:^|\/)node_modules\/|(?:^|\/)dist\/|(?:^|\/)vendor\/|(?:package-lock\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock))$/i;
|
|
42
|
+
|
|
43
|
+
function isSkippable(relPath) {
|
|
44
|
+
return SKIP_FILE.test(String(relPath || ''));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function lineOf(content, index) {
|
|
48
|
+
return content.slice(0, index).split('\n').length;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function colOf(content, index) {
|
|
52
|
+
const before = content.slice(0, index);
|
|
53
|
+
return index - before.lastIndexOf('\n');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function snippetOf(content, index, match) {
|
|
57
|
+
const start = content.lastIndexOf('\n', index) + 1;
|
|
58
|
+
const end = content.indexOf('\n', index);
|
|
59
|
+
const line = content.slice(start, end === -1 ? undefined : end).trim();
|
|
60
|
+
return (match ? line.split(match).join(match.slice(0, 6) + '…') : line).slice(0, 160);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --- decoding ---------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
function tryBase64(s) {
|
|
66
|
+
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(s) || s.length < 40 || s.length % 4 !== 0) return null;
|
|
67
|
+
try {
|
|
68
|
+
const out = Buffer.from(s, 'base64').toString('utf8');
|
|
69
|
+
let printable = 0;
|
|
70
|
+
for (let i = 0; i < out.length; i++) {
|
|
71
|
+
const c = out.charCodeAt(i);
|
|
72
|
+
if (c >= 32 || c === 10 || c === 9 || c === 13) printable++;
|
|
73
|
+
}
|
|
74
|
+
// Binary decoded base64 is not a payload we can judge.
|
|
75
|
+
if (out.length < 12 || printable / out.length < 0.85) return null;
|
|
76
|
+
return out;
|
|
77
|
+
} catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function tryHexEscapes(s) {
|
|
83
|
+
if (!/(?:\\x[0-9a-fA-F]{2}){6,}/.test(s)) return null;
|
|
84
|
+
try {
|
|
85
|
+
const unescaped = s.replace(/\\x([0-9a-fA-F]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));
|
|
86
|
+
return unescaped;
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function tryUnicodeEscapes(s) {
|
|
93
|
+
if (!/(?:\\u[0-9a-fA-F]{4}){6,}/.test(s)) return null;
|
|
94
|
+
try {
|
|
95
|
+
return s.replace(/\\u([0-9a-fA-F]{4})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));
|
|
96
|
+
} catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function tryFromCharCode(s) {
|
|
102
|
+
const m = /String\.fromCharCode\(\s*((?:\d{1,3}\s*,\s*){5,})\d{1,3}\s*\)/.exec(s);
|
|
103
|
+
if (!m) return null;
|
|
104
|
+
const codes = (m[0].match(/\d{1,3}/g) || []).map(Number).filter((n) => n > 8 && n < 0x10ffff);
|
|
105
|
+
if (codes.length < 6) return null;
|
|
106
|
+
try {
|
|
107
|
+
return String.fromCharCode(...codes);
|
|
108
|
+
} catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function tryRot13(s) {
|
|
114
|
+
if (!/rot13|rot-13/i.test(s)) return null;
|
|
115
|
+
return s.replace(/[a-zA-Z]/g, (c) => {
|
|
116
|
+
const base = c <= 'Z' ? 65 : 97;
|
|
117
|
+
return String.fromCharCode(((c.charCodeAt(0) - base + 13) % 26) + base);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function dangerousTokens(text) {
|
|
122
|
+
const hits = [];
|
|
123
|
+
for (const d of DANGER) if (d.re.test(text)) hits.push({ label: d.label, weight: d.weight });
|
|
124
|
+
return hits;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function decodeLayers(text) {
|
|
128
|
+
let cur = text;
|
|
129
|
+
const techniques = [];
|
|
130
|
+
for (let i = 0; i < MAX_DECODE; i++) {
|
|
131
|
+
const blob = (cur.match(/[A-Za-z0-9+/=]{40,}/) || [''])[0];
|
|
132
|
+
const candidates = [
|
|
133
|
+
['hex escapes', tryHexEscapes(cur)],
|
|
134
|
+
['unicode escapes', tryUnicodeEscapes(cur)],
|
|
135
|
+
['String.fromCharCode', tryFromCharCode(cur)],
|
|
136
|
+
['base64', tryBase64(blob)],
|
|
137
|
+
['rot13', tryRot13(cur)],
|
|
138
|
+
];
|
|
139
|
+
const hit = candidates.find(([, v]) => v && v !== cur);
|
|
140
|
+
if (!hit) break;
|
|
141
|
+
cur = hit[1];
|
|
142
|
+
techniques.push(hit[0]);
|
|
143
|
+
}
|
|
144
|
+
return { decoded: cur, techniques: [...new Set(techniques)] };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// --- main analysis ----------------------------------------------------------
|
|
148
|
+
|
|
149
|
+
function makeFinding(relPath, content, index, ruleId, severity, confidence, title, message, fix, snippet) {
|
|
150
|
+
return {
|
|
151
|
+
ruleId,
|
|
152
|
+
severity,
|
|
153
|
+
confidence,
|
|
154
|
+
title,
|
|
155
|
+
message,
|
|
156
|
+
fix,
|
|
157
|
+
file: relPath,
|
|
158
|
+
line: lineOf(content, index),
|
|
159
|
+
column: colOf(content, index),
|
|
160
|
+
snippet: snippet || snippetOf(content, index),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function analyzeObfuscation(content, relPath) {
|
|
165
|
+
if (!content || isSkippable(relPath)) return [];
|
|
166
|
+
const findings = [];
|
|
167
|
+
const safePush = (f) => {
|
|
168
|
+
if (findings.length >= 40) return;
|
|
169
|
+
findings.push(f);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// 1. Executable-position encoded payloads ---------------------------------
|
|
173
|
+
// eval(atob(...)) / Function(Buffer.from(...,'base64')) / import(decodedUrl)
|
|
174
|
+
const execEncoded = [
|
|
175
|
+
/\beval\s*\(\s*(?:atob|Buffer\.from|decodeURIComponent|unescape)\s*\(/,
|
|
176
|
+
/new\s+Function\s*\(\s*(?:atob|Buffer\.from|decodeURIComponent)\s*\(/,
|
|
177
|
+
/(?:exec|execSync|spawn|spawnSync)\s*\(\s*(?:atob|Buffer\.from|decodeURIComponent)\s*\(/,
|
|
178
|
+
/\bimport\s*\(\s*(?:atob|Buffer\.from|decodeURIComponent)\s*\(/,
|
|
179
|
+
];
|
|
180
|
+
for (const re of execEncoded) {
|
|
181
|
+
const m = re.exec(content);
|
|
182
|
+
if (!m) continue;
|
|
183
|
+
// Decode the literal if we can find one in the call.
|
|
184
|
+
const around = content.slice(m.index, m.index + 400);
|
|
185
|
+
const blob = /(?:['"`])([A-Za-z0-9+/=\\x0-9a-f]{20,})(?:['"`])/.exec(around);
|
|
186
|
+
const decoded = blob ? decodeLayers(blob[1]).decoded : '';
|
|
187
|
+
const tokens = decoded ? dangerousTokens(decoded) : [];
|
|
188
|
+
if (tokens.length === 0) continue; // encoded but harmless-looking: not worth a finding
|
|
189
|
+
safePush(
|
|
190
|
+
makeFinding(relPath, content, m.index, 'obf.exec-encoded-payload', 'critical', 'high',
|
|
191
|
+
'Encoded payload executed at runtime',
|
|
192
|
+
`Executable code is decoded and run here. The decoded payload contains: ${tokens.map((t) => t.label).join(', ')}. Payloads hidden this way bypass code review and text scanners.`,
|
|
193
|
+
'Remove the loader. If the library is legitimate, vendor it as readable source and update by version; never execute remote/encoded strings.',
|
|
194
|
+
undefined)
|
|
195
|
+
);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 2. Dangerous decode cascade anywhere ------------------------------------
|
|
200
|
+
// Long base64/hex blobs whose decoded form carries dangerous capability.
|
|
201
|
+
const blobRe = /(?:['"`])([A-Za-z0-9+/]{60,}={0,2})(?:['"`])/g;
|
|
202
|
+
let bm;
|
|
203
|
+
let blobCount = 0;
|
|
204
|
+
while ((bm = blobRe.exec(content)) !== null && blobCount < 6) {
|
|
205
|
+
const decoded = tryBase64(bm[1]);
|
|
206
|
+
if (!decoded) continue;
|
|
207
|
+
const tokens = dangerousTokens(decoded);
|
|
208
|
+
if (tokens.length === 0) continue;
|
|
209
|
+
const weight = tokens.reduce((s, t) => s + t.weight, 0);
|
|
210
|
+
if (weight < 3) continue;
|
|
211
|
+
blobCount++;
|
|
212
|
+
safePush(
|
|
213
|
+
makeFinding(relPath, content, bm.index, 'obf.encoded-dangerous-payload', weight >= 6 ? 'critical' : 'high',
|
|
214
|
+
'medium', 'Encoded payload with dangerous capability',
|
|
215
|
+
`A base64 blob decodes to text that can ${tokens.map((t) => t.label).join(', ')}. Legitimate code rarely ships executable capability as an encoded string.`,
|
|
216
|
+
'Decode and review the payload. Replace with readable source or remove; pin the dependency that introduced it.',
|
|
217
|
+
undefined)
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 3. Obfuscator fingerprints ----------------------------------------------
|
|
222
|
+
const marks = OBFUSCATOR_MARKERS.filter((m) => {
|
|
223
|
+
const count = (content.match(m.re) || []).length;
|
|
224
|
+
return count >= m.min;
|
|
225
|
+
});
|
|
226
|
+
if (marks.length >= 2) {
|
|
227
|
+
const idx = Math.max(0, content.search(/_0x[0-9a-f]{4,}/));
|
|
228
|
+
safePush(
|
|
229
|
+
makeFinding(relPath, content, idx, 'obf.javascript-obfuscator', 'high', 'medium',
|
|
230
|
+
'Heavily obfuscated JavaScript',
|
|
231
|
+
`This file carries ${marks.map((m) => m.label).join(', ')} — the signature of javascript-obfuscator/obfuscator.io. Obfuscation in application code hides behaviour from review; it is normal only in third-party minified bundles.`,
|
|
232
|
+
'Replace the obfuscated file with the original package (installed from the registry, pinned) or vendor readable source. Never ship hand-obfuscated first-party code.',
|
|
233
|
+
undefined)
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// 4. Behavioural co-occurrence (dropper / exfiltration) --------------------
|
|
238
|
+
const has = (re) => re.test(content);
|
|
239
|
+
const net = has(/\b(?:fetch\s*\(|axios\.|https?\.request\s*\(|net\.connect\s*\(|new\s+WebSocket\s*\()/);
|
|
240
|
+
const exec = has(/\b(?:child_process|execSync\s*\(|exec\s*\(|spawn\s*\(|os\.system\s*\()/);
|
|
241
|
+
const env = has(/process\.env|os\.environ|os\.getenv/);
|
|
242
|
+
const fsx = has(/\bfs\.(?:readFile|writeFile|readdir|unlink|appendFile)/);
|
|
243
|
+
const cryptoBlob = has(/crypto\.createCipheriv|createDecipheriv|subtle\.encrypt/);
|
|
244
|
+
|
|
245
|
+
if (net && exec && env) {
|
|
246
|
+
safePush(
|
|
247
|
+
makeFinding(relPath, content, Math.max(0, content.search(/fetch\s*\(|https?\.request/)), 'obf.dropper-behavior', 'high', 'medium',
|
|
248
|
+
'File combines process execution, environment access and outbound network',
|
|
249
|
+
'This file can spawn processes, read the environment (tokens, cloud credentials) and talk to the network. That combination is a loader/exfiltration primitive — legitimate build tooling isolates these behind explicit APIs.',
|
|
250
|
+
'Split the responsibilities: a tool that runs commands must not also fetch arbitrary URLs. Review who introduced this file and pin its origin.',
|
|
251
|
+
undefined)
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
if (net && env && !exec && (fsx || cryptoBlob)) {
|
|
255
|
+
const idx = Math.max(0, content.search(/fetch\s*\(|https?\.request/));
|
|
256
|
+
safePush(
|
|
257
|
+
makeFinding(relPath, content, idx, 'obf.env-exfil-behavior', 'medium', 'medium',
|
|
258
|
+
'Credential-exfiltration pattern (env + filesystem/crypto + network)',
|
|
259
|
+
'The file reads the environment (and files/keys) and sends data over the network. If this is not the payment/auth integration itself, it is an exfiltration path for tokens and PII.',
|
|
260
|
+
'Move secret handling to the server process that needs it; log/egress only through an allowlisted client. Audit the reviewer who added the network call.',
|
|
261
|
+
undefined)
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// 5. Encoded/remote execution primitives ----------------------------------
|
|
266
|
+
const primitives = [
|
|
267
|
+
{ re: /\bimport\s*\(\s*['"`]https?:\/\//, id: 'obf.remote-module-import', sev: 'high', title: 'Remote module loaded at runtime', msg: 'A module is imported from a URL. The remote server — not this repository — decides what code runs, and the reviewed version is not the executed version.', fix: 'Bundle/pin the dependency locally. Remote imports bypass review, SRI and lockfiles.' },
|
|
268
|
+
{ re: /\brequire\s*\(\s*['"`]https?:\/\//, id: 'obf.remote-require', sev: 'high', title: 'Remote module required at runtime', msg: 'require() from a URL loads unreviewed remote code into the process.', fix: 'Install and pin the package; never require over HTTP(S).' },
|
|
269
|
+
{ re: /powershell(?:\.exe)?\s+[^;\n]*(?:-enc|-encodedcommand)\s+[A-Za-z0-9+/=]{20,}/i, id: 'obf.powershell-encoded-command', sev: 'critical', title: 'PowerShell encoded command', msg: 'A base64 -EncodedCommand blob executes a hidden PowerShell script — the standard payload-delivery form.', fix: 'Remove it. Legitimate installers use signed MSI/exe or readable scripts checked into the repo.' },
|
|
270
|
+
{ re: /(?:curl|wget)[^;\n|]{0,160}\|\s*(?:sh|bash|zsh|python|node)\b/i, id: 'obf.curl-pipe-shell', sev: 'critical', title: 'Downloaded code piped into a shell', msg: 'A network response is executed directly. The downloaded content can change after review and is not pinned by any hash.', fix: 'Download, verify a published checksum/signature, then run a pinned file. Prefer a package registry.' },
|
|
271
|
+
{ re: /fetch\s*\([^)]*\)\s*\.then\s*\([^)]*\)\s*\.then\s*\(\s*(?:eval|Function|window\.eval)/, id: 'obf.fetch-then-eval', sev: 'critical', title: 'Fetched content passed to eval', msg: 'A network response is evaluated as code. Whoever controls the endpoint (or the DNS) controls this process.', fix: 'Parse data (JSON.parse) and switch on validated fields; never eval a response.' },
|
|
272
|
+
{ re: /\.toString\(\s*['"]base64['"]\s*\)[^;\n]{0,80}(?:exec|spawn|Function|eval)\b/, id: 'obf.base64-to-exec', sev: 'critical', title: 'Base64 payload piped into execution', msg: 'A base64-decoded string is executed — classic encoded dropper.', fix: 'Remove; replace with explicit, reviewable logic.' },
|
|
273
|
+
];
|
|
274
|
+
for (const p of primitives) {
|
|
275
|
+
const m = p.re.exec(content);
|
|
276
|
+
if (!m) continue;
|
|
277
|
+
safePush(makeFinding(relPath, content, m.index, p.id, p.sev, 'high', p.title, p.msg, p.fix, undefined));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// 6. Anti-analysis in application code ------------------------------------
|
|
281
|
+
const anti = [
|
|
282
|
+
{ re: /Error\.prepareStackTrace\s*=/, id: 'obf.stack-sanity-off', sev: 'medium', title: 'Stack-trace formatting overridden', msg: 'prepareStackTrace is replaced, hiding the call path from logs and debuggers.', fix: 'Remove it; use a logging library with redaction instead.' },
|
|
283
|
+
{ re: /Function\.prototype\.toString\s*=/, id: 'obf.function-tostring-override', sev: 'high', title: 'Function.prototype.toString overridden', msg: 'Overriding function source text defeats "show me the code" inspection and some integrity checks.', fix: 'Remove the override.' },
|
|
284
|
+
{ re: /\bdebugger\s*;/, id: 'obf.debugger-statement', sev: 'low', title: 'debugger statement left in code', msg: 'A debugger statement pauses execution when devtools is open — noise in production, and used to frustrate analysis.', fix: 'Remove debugger statements before shipping (lint rule no-debugger).' },
|
|
285
|
+
];
|
|
286
|
+
for (const a of anti) {
|
|
287
|
+
const m = a.re.exec(content);
|
|
288
|
+
if (!m) continue;
|
|
289
|
+
// Skip tests/dev fixtures; debugger in a test helper is harmless.
|
|
290
|
+
if (/(?:^|\/)(?:test|tests|__tests__|fixtures)\//.test(relPath)) continue;
|
|
291
|
+
safePush(makeFinding(relPath, content, m.index, a.id, a.sev, 'medium', a.title, a.msg, a.fix, undefined));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// 7. Unicode concealment ---------------------------------------------------
|
|
295
|
+
const zw = (content.match(/[\u200b-\u200f\u2060-\u2064\u2066-\u2069\u202a-\u202e]/g) || []).length;
|
|
296
|
+
if (zw >= 6) {
|
|
297
|
+
const idx = content.search(/[\u200b-\u200f\u2060-\u2064\u2066-\u2069\u202a-\u202e]/);
|
|
298
|
+
safePush(
|
|
299
|
+
makeFinding(relPath, content, idx, 'obf.unicode-concealment', 'medium', 'high',
|
|
300
|
+
'Zero-width / bidi characters in source',
|
|
301
|
+
`${zw} invisible or direction-override characters are present. They render as nothing to a reviewer but reach tokens, prompts and logs — the Trojan-Source class (CVE-2021-42574) used to hide instructions from AI review.`,
|
|
302
|
+
'Strip all format-control characters (U+200B–U+200F, U+202A–U+202E, U+2066–U+2069) from source and prompt files; add a pre-commit check.',
|
|
303
|
+
undefined)
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return findings;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
module.exports = {
|
|
311
|
+
analyzeObfuscation,
|
|
312
|
+
decodeLayers,
|
|
313
|
+
dangerousTokens,
|
|
314
|
+
isSkippable,
|
|
315
|
+
};
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* src/owasp-agentic.js — OWASP coverage map for agent and MCP security.
|
|
5
|
+
*
|
|
6
|
+
* Two frameworks, one question: "which of these risks does VibeGuard actually
|
|
7
|
+
* do something about, and what exactly does it do?"
|
|
8
|
+
*
|
|
9
|
+
* - OWASP Top 10 for Agentic Applications
|
|
10
|
+
* - OWASP MCP Top 10
|
|
11
|
+
* - OWASP Top 10 for LLM Applications (bonus, because MCP sits under it)
|
|
12
|
+
*
|
|
13
|
+
* Coverage here means a concrete control exists in this codebase: a scanner,
|
|
14
|
+
* a runtime gate, a monitor, or a tamper-evident log. It does NOT mean the
|
|
15
|
+
* risk is eliminated. The status vocabulary says which:
|
|
16
|
+
*
|
|
17
|
+
* enforced — a runtime control can block the action (firewall/policy/sandbox)
|
|
18
|
+
* detected — a scanner reports it before it ships
|
|
19
|
+
* monitored — behavior and audit data expose it after the fact
|
|
20
|
+
* advisory — guidance/config guidance only
|
|
21
|
+
*
|
|
22
|
+
* 100% local. Zero dependencies.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const AGENTIC = {
|
|
26
|
+
id: 'OWASP-AGENTIC',
|
|
27
|
+
name: 'OWASP Top 10 for Agentic Applications',
|
|
28
|
+
items: [
|
|
29
|
+
{ id: 'ASI01', name: 'Agent Goal Hijack' },
|
|
30
|
+
{ id: 'ASI02', name: 'Tool Misuse and Exploitation' },
|
|
31
|
+
{ id: 'ASI03', name: 'Identity and Privilege Abuse' },
|
|
32
|
+
{ id: 'ASI04', name: 'Agentic Supply Chain Vulnerabilities' },
|
|
33
|
+
{ id: 'ASI05', name: 'Unexpected Code Execution' },
|
|
34
|
+
{ id: 'ASI06', name: 'Memory and Context Poisoning' },
|
|
35
|
+
{ id: 'ASI07', name: 'Insecure Inter-Agent Communication' },
|
|
36
|
+
{ id: 'ASI08', name: 'Cascading Failures' },
|
|
37
|
+
{ id: 'ASI09', name: 'Human-Agent Trust Exploitation' },
|
|
38
|
+
{ id: 'ASI10', name: 'Rogue Agents' },
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const MCP = {
|
|
43
|
+
id: 'OWASP-MCP',
|
|
44
|
+
name: 'OWASP MCP Top 10',
|
|
45
|
+
items: [
|
|
46
|
+
{ id: 'MCP01', name: 'Token Mismanagement and Secret Exposure' },
|
|
47
|
+
{ id: 'MCP02', name: 'Privilege Escalation via Scope Creep' },
|
|
48
|
+
{ id: 'MCP03', name: 'Tool Poisoning' },
|
|
49
|
+
{ id: 'MCP04', name: 'Software Supply Chain Attacks and Dependency Tampering' },
|
|
50
|
+
{ id: 'MCP05', name: 'Command Injection and Execution' },
|
|
51
|
+
{ id: 'MCP06', name: 'Intent Flow Subversion' },
|
|
52
|
+
{ id: 'MCP07', name: 'Insufficient Authentication and Authorization' },
|
|
53
|
+
{ id: 'MCP08', name: 'Lack of Audit and Telemetry' },
|
|
54
|
+
{ id: 'MCP09', name: 'Shadow MCP Servers' },
|
|
55
|
+
{ id: 'MCP10', name: 'Context Injection and Over-Sharing' },
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const LLM = {
|
|
60
|
+
id: 'OWASP-LLM',
|
|
61
|
+
name: 'OWASP Top 10 for LLM Applications (2025)',
|
|
62
|
+
items: [
|
|
63
|
+
{ id: 'LLM01', name: 'Prompt Injection' },
|
|
64
|
+
{ id: 'LLM02', name: 'Sensitive Information Disclosure' },
|
|
65
|
+
{ id: 'LLM03', name: 'Supply Chain' },
|
|
66
|
+
{ id: 'LLM04', name: 'Data and Model Poisoning' },
|
|
67
|
+
{ id: 'LLM05', name: 'Improper Output Handling' },
|
|
68
|
+
{ id: 'LLM06', name: 'Excessive Agency' },
|
|
69
|
+
{ id: 'LLM07', name: 'System Prompt Leakage' },
|
|
70
|
+
{ id: 'LLM08', name: 'Vector and Embedding Weaknesses' },
|
|
71
|
+
{ id: 'LLM09', name: 'Misinformation' },
|
|
72
|
+
{ id: 'LLM10', name: 'Unbounded Consumption' },
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const FRAMEWORKS = { agentic: AGENTIC, mcp: MCP, llm: LLM };
|
|
77
|
+
|
|
78
|
+
// Every check names the code that implements it. Keep module/file names here
|
|
79
|
+
// so an operator can audit the claim instead of trusting a badge.
|
|
80
|
+
const CHECKS = [
|
|
81
|
+
{
|
|
82
|
+
id: 'mcp.firewall.tool-poisoning',
|
|
83
|
+
module: 'src/mcp-firewall.js + src/agent-policy.js',
|
|
84
|
+
capability: 'MCP firewall',
|
|
85
|
+
status: 'enforced',
|
|
86
|
+
description: 'Scans tool names, descriptions and schemas for injection, concealment, forced invocation, encoded payloads and readOnly lies; removes poisoned tools from tools/list.',
|
|
87
|
+
controls: { agentic: ['ASI01', 'ASI02', 'ASI06'], mcp: ['MCP03', 'MCP06'], llm: ['LLM01'] },
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'mcp.audit.config',
|
|
91
|
+
module: 'src/mcp-audit.js',
|
|
92
|
+
capability: 'MCP config audit',
|
|
93
|
+
status: 'detected',
|
|
94
|
+
description: 'Audits configured servers for injection, unpinned auto-install, remote-code commands, secrets in env, over-broad filesystem grants, duplicate (shadow) servers and definition drift.',
|
|
95
|
+
controls: { agentic: ['ASI02', 'ASI04', 'ASI07'], mcp: ['MCP02', 'MCP04', 'MCP07', 'MCP09'], llm: ['LLM03'] },
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'mcp.firewall.permissions',
|
|
99
|
+
module: 'src/agent-policy.js + src/mcp-firewall.js',
|
|
100
|
+
capability: 'Agent permission enforcement',
|
|
101
|
+
status: 'enforced',
|
|
102
|
+
description: 'Per-tool allow/deny/approval rules, capability gates, project-scoped filesystem access, denied credential paths, egress allowlist, metadata-host block, argument size and call-rate limits.',
|
|
103
|
+
controls: { agentic: ['ASI02', 'ASI03', 'ASI08'], mcp: ['MCP02', 'MCP07'], llm: ['LLM06'] },
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 'mcp.firewall.secrets',
|
|
107
|
+
module: 'src/mcp-firewall.js + src/action-guard.js',
|
|
108
|
+
capability: 'Credential and secret exfiltration prevention',
|
|
109
|
+
status: 'enforced',
|
|
110
|
+
description: 'Blocks secrets in tool arguments, credential-plus-destination exfiltration shapes, secrets in URLs, credential-store paths, and redacts secrets/PII from tool results before they reach the model.',
|
|
111
|
+
controls: { agentic: ['ASI03', 'ASI07'], mcp: ['MCP01', 'MCP10'], llm: ['LLM02'] },
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: 'agent.policy.command-guard',
|
|
115
|
+
module: 'src/shell-guard.js + src/agent-policy.js',
|
|
116
|
+
capability: 'Command injection / destructive command prevention',
|
|
117
|
+
status: 'enforced',
|
|
118
|
+
description: 'Normalizes obfuscation (base64, env indirection, subshells, quoting, $IFS) and blocks destructive or exfiltrating shell commands before an MCP shell tool runs them.',
|
|
119
|
+
controls: { agentic: ['ASI05'], mcp: ['MCP05'], llm: ['LLM05'] },
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: 'sandbox.execution',
|
|
123
|
+
module: 'src/sandbox.js',
|
|
124
|
+
capability: 'Sandboxed code execution',
|
|
125
|
+
status: 'enforced',
|
|
126
|
+
description: 'Executes AI-generated JavaScript with a blocked-global vm, a process-permission mode on Node 20+, stripped environment, timeout, memory cap and an audit of every blocked access attempt.',
|
|
127
|
+
controls: { agentic: ['ASI05'], mcp: ['MCP05'], llm: ['LLM05'] },
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: 'skill.scan',
|
|
131
|
+
module: 'src/skill-scan.js',
|
|
132
|
+
capability: 'Malicious package and skill detection',
|
|
133
|
+
status: 'detected',
|
|
134
|
+
description: 'Scans SKILL.md, AGENTS.md, CLAUDE.md, Cursor rules, Claude plugins, marketplaces and embedded MCP configs for injection, hidden Unicode, exfiltration, credential access, destructive commands, remote code and permission bypass.',
|
|
135
|
+
controls: { agentic: ['ASI01', 'ASI04', 'ASI06'], mcp: ['MCP03', 'MCP04'], llm: ['LLM01', 'LLM03', 'LLM04'] },
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: 'supply.packages',
|
|
139
|
+
module: 'src/supply-firewall.js + src/slopsquat.js + src/deps.js + src/firewall.js',
|
|
140
|
+
capability: 'Package supply chain',
|
|
141
|
+
status: 'detected',
|
|
142
|
+
description: 'Checks package names for typosquat/slopsquat/malicious names, lockfile and package.json install scripts, unpinned dependencies, license risk and known CVEs.',
|
|
143
|
+
controls: { agentic: ['ASI04'], mcp: ['MCP04'], llm: ['LLM03'] },
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: 'runtime.behavior',
|
|
147
|
+
module: 'src/behavior.js + src/agent-monitor.js',
|
|
148
|
+
capability: 'Autonomous agent behavior monitoring',
|
|
149
|
+
status: 'monitored',
|
|
150
|
+
description: 'Scores tool-call sessions for trust-building, data-gathering-before-egress, slow exfiltration, privilege escalation, repeated blocks, rapid-fire and off-hours access; surfaces them from the live firewall log.',
|
|
151
|
+
controls: { agentic: ['ASI08', 'ASI09', 'ASI10'], mcp: ['MCP08'], llm: ['LLM06', 'LLM10'] },
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: 'audit.trail',
|
|
155
|
+
module: 'src/audit-trail.js',
|
|
156
|
+
capability: 'Security audit logs and risk scoring',
|
|
157
|
+
status: 'enforced',
|
|
158
|
+
description: 'Append-only SHA-256 hash-chained JSONL log of every allowed, warned and blocked action; verification detects edits and deletions; agent-risk aggregates the log into a 0-100 score and A-F grade.',
|
|
159
|
+
controls: { agentic: ['ASI09', 'ASI10'], mcp: ['MCP08'], llm: [] },
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: 'agent.risk',
|
|
163
|
+
module: 'src/agent-risk.js',
|
|
164
|
+
capability: 'Risk scoring',
|
|
165
|
+
status: 'enforced',
|
|
166
|
+
description: 'Combines MCP config, skills, runtime firewall decisions, behavioral anomalies, permission scope and audit coverage into per-domain scores and an overall A-F grade.',
|
|
167
|
+
controls: { agentic: ['ASI02', 'ASI08', 'ASI10'], mcp: ['MCP02', 'MCP08'], llm: ['LLM06'] },
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: 'agent.prompt-guard',
|
|
171
|
+
module: 'src/firewall.js + src/secure-prompt.js + src/llm-proxy.js',
|
|
172
|
+
capability: 'Prompt injection detection',
|
|
173
|
+
status: 'enforced',
|
|
174
|
+
description: 'Regex + semantic classifier for instruction override, role hijack, system-prompt extraction, encoded payloads, jailbreaks and PII; can proxy an LLM API and redact/block in flight.',
|
|
175
|
+
controls: { agentic: ['ASI01', 'ASI06'], mcp: ['MCP06'], llm: ['LLM01', 'LLM07'] },
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: 'agent.output-sinks',
|
|
179
|
+
module: 'src/agentic.js + src/rules-2026.js + src/crosstaint.js',
|
|
180
|
+
capability: 'LLM output handling',
|
|
181
|
+
status: 'detected',
|
|
182
|
+
description: 'Detects LLM output flowing into exec/eval/SQL/HTML, tool-result injection, memory poisoning, uncapped loops, missing max_tokens and sandbox-disabled flags.',
|
|
183
|
+
controls: { agentic: ['ASI05', 'ASI06', 'ASI08'], mcp: ['MCP06'], llm: ['LLM05', 'LLM06', 'LLM10'] },
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: 'agent.secrets.static',
|
|
187
|
+
module: 'src/scanner.js + src/entropy.js + src/gitscan.js',
|
|
188
|
+
capability: 'Secret detection',
|
|
189
|
+
status: 'detected',
|
|
190
|
+
description: 'Scans source, build artifacts and git history for known secret formats, high-entropy tokens and committed-then-removed credentials.',
|
|
191
|
+
controls: { agentic: ['ASI03'], mcp: ['MCP01'], llm: ['LLM02'] },
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: 'agent.env-lock',
|
|
195
|
+
module: 'src/interceptor.js + src/vault.js',
|
|
196
|
+
capability: 'Credential isolation',
|
|
197
|
+
status: 'enforced',
|
|
198
|
+
description: 'Hides sensitive environment variables from the agent process, sanitizes AI responses, detects tamper attempts and provides an encrypted local vault.',
|
|
199
|
+
controls: { agentic: ['ASI03'], mcp: ['MCP01'], llm: ['LLM02'] },
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 'compliance.mapping',
|
|
203
|
+
module: 'src/compliance.js',
|
|
204
|
+
capability: 'Control mapping',
|
|
205
|
+
status: 'advisory',
|
|
206
|
+
description: 'Maps findings to SOC2, PCI-DSS, HIPAA, GDPR, ISO27001, NIST CSF/800-53, CIS and EU AI Act for reporting.',
|
|
207
|
+
controls: { agentic: ['ASI09'], mcp: ['MCP08'], llm: [] },
|
|
208
|
+
},
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
const STATUS_RANK = { none: 0, advisory: 1, monitored: 2, detected: 3, enforced: 4 };
|
|
212
|
+
|
|
213
|
+
function checksForFramework(frameworkKey) {
|
|
214
|
+
return CHECKS.filter((check) => (check.controls[frameworkKey] || []).length > 0);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function mapFindings(findings) {
|
|
218
|
+
// Findings from the scanners carry mcp/agentic ids when we know them. This
|
|
219
|
+
// gives the report a per-control hit count without inventing precision.
|
|
220
|
+
const counts = {};
|
|
221
|
+
for (const f of findings || []) {
|
|
222
|
+
const ids = Array.isArray(f.owasp) ? f.owasp : [];
|
|
223
|
+
for (const id of ids) counts[id] = (counts[id] || 0) + 1;
|
|
224
|
+
if (f.id && /^MCP\d+$/i.test(f.id)) counts[f.id.toUpperCase()] = (counts[f.id.toUpperCase()] || 0) + 1;
|
|
225
|
+
}
|
|
226
|
+
return counts;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// opts: { frameworks: ['agentic','mcp','llm'], findings, enabled: { mcpFirewall: bool, ... } }
|
|
230
|
+
function coverageReport(opts = {}) {
|
|
231
|
+
const selected = opts.frameworks && opts.frameworks.length ? opts.frameworks : ['agentic', 'mcp'];
|
|
232
|
+
const findingCounts = mapFindings(opts.findings || []);
|
|
233
|
+
const frameworks = [];
|
|
234
|
+
|
|
235
|
+
for (const key of selected) {
|
|
236
|
+
const framework = FRAMEWORKS[key];
|
|
237
|
+
if (!framework) continue;
|
|
238
|
+
const checks = checksForFramework(key);
|
|
239
|
+
const items = framework.items.map((item) => {
|
|
240
|
+
const related = checks.filter((c) => (c.controls[key] || []).includes(item.id));
|
|
241
|
+
const status = related.reduce((best, c) => (STATUS_RANK[c.status] > STATUS_RANK[best] ? c.status : best), 'none');
|
|
242
|
+
return {
|
|
243
|
+
...item,
|
|
244
|
+
covered: related.length > 0,
|
|
245
|
+
status,
|
|
246
|
+
checks: related.map((c) => c.id),
|
|
247
|
+
findings: findingCounts[item.id] || 0,
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
const covered = items.filter((i) => i.covered).length;
|
|
251
|
+
frameworks.push({
|
|
252
|
+
id: framework.id,
|
|
253
|
+
name: framework.name,
|
|
254
|
+
total: items.length,
|
|
255
|
+
covered,
|
|
256
|
+
percent: Math.round((covered / items.length) * 100),
|
|
257
|
+
items,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const totalItems = frameworks.reduce((n, f) => n + f.total, 0);
|
|
262
|
+
const totalCovered = frameworks.reduce((n, f) => n + f.covered, 0);
|
|
263
|
+
return {
|
|
264
|
+
generatedAt: new Date().toISOString(),
|
|
265
|
+
frameworks,
|
|
266
|
+
totalItems,
|
|
267
|
+
totalCovered,
|
|
268
|
+
percent: totalItems ? Math.round((totalCovered / totalItems) * 100) : 0,
|
|
269
|
+
checks: CHECKS.map((c) => ({ id: c.id, capability: c.capability, status: c.status, module: c.module, description: c.description, controls: c.controls })),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function renderCoverage(report) {
|
|
274
|
+
const C = { red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', cyan: '\x1b[36m', dim: '\x1b[2m', bold: '\x1b[1m', reset: '\x1b[0m' };
|
|
275
|
+
const statusColor = {
|
|
276
|
+
enforced: C.green,
|
|
277
|
+
detected: C.cyan,
|
|
278
|
+
monitored: C.yellow,
|
|
279
|
+
advisory: C.dim,
|
|
280
|
+
none: C.red,
|
|
281
|
+
};
|
|
282
|
+
const lines = [
|
|
283
|
+
`${C.bold}VibeGuard — OWASP agent + MCP coverage${C.reset}`,
|
|
284
|
+
`${C.dim}${'─'.repeat(68)}${C.reset}`,
|
|
285
|
+
'',
|
|
286
|
+
];
|
|
287
|
+
for (const framework of report.frameworks) {
|
|
288
|
+
lines.push(`${C.bold}${framework.name}${C.reset} ${framework.covered}/${framework.total} (${framework.percent}%)`);
|
|
289
|
+
for (const item of framework.items) {
|
|
290
|
+
const label = (item.status === 'none' ? 'GAP' : item.status.toUpperCase()).padEnd(10);
|
|
291
|
+
lines.push(` ${item.id.padEnd(6)} ${statusColor[item.status]}${label}${C.reset} ${item.name}`);
|
|
292
|
+
}
|
|
293
|
+
lines.push('');
|
|
294
|
+
}
|
|
295
|
+
lines.push(`${C.bold}Overall: ${report.totalCovered}/${report.totalItems} controls mapped${C.reset}`);
|
|
296
|
+
return lines.join('\n');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function coverageSummary(report) {
|
|
300
|
+
return report.frameworks.map((f) => `${f.id}: ${f.covered}/${f.total} (${f.percent}%)`).join(' · ');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
module.exports = {
|
|
304
|
+
AGENTIC,
|
|
305
|
+
MCP,
|
|
306
|
+
LLM,
|
|
307
|
+
FRAMEWORKS,
|
|
308
|
+
CHECKS,
|
|
309
|
+
coverageReport,
|
|
310
|
+
coverageSummary,
|
|
311
|
+
renderCoverage,
|
|
312
|
+
mapFindings,
|
|
313
|
+
checksForFramework,
|
|
314
|
+
};
|