guard-scanner 2.0.0 → 3.1.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.
Files changed (55) hide show
  1. package/README.md +107 -64
  2. package/dist/__tests__/scanner.test.d.ts +10 -0
  3. package/dist/__tests__/scanner.test.d.ts.map +1 -0
  4. package/dist/__tests__/scanner.test.js +374 -0
  5. package/dist/__tests__/scanner.test.js.map +1 -0
  6. package/dist/cli.d.ts +10 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +189 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +18 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/ioc-db.d.ts +13 -0
  15. package/dist/ioc-db.d.ts.map +1 -0
  16. package/dist/ioc-db.js +130 -0
  17. package/dist/ioc-db.js.map +1 -0
  18. package/dist/patterns.d.ts +27 -0
  19. package/dist/patterns.d.ts.map +1 -0
  20. package/dist/patterns.js +92 -0
  21. package/dist/patterns.js.map +1 -0
  22. package/dist/quarantine.d.ts +18 -0
  23. package/dist/quarantine.d.ts.map +1 -0
  24. package/dist/quarantine.js +42 -0
  25. package/dist/quarantine.js.map +1 -0
  26. package/dist/scanner.d.ts +54 -0
  27. package/dist/scanner.d.ts.map +1 -0
  28. package/dist/scanner.js +1043 -0
  29. package/dist/scanner.js.map +1 -0
  30. package/dist/types.d.ts +165 -0
  31. package/dist/types.d.ts.map +1 -0
  32. package/dist/types.js +7 -0
  33. package/dist/types.js.map +1 -0
  34. package/hooks/guard-scanner/plugin.ts +101 -32
  35. package/openclaw.plugin.json +60 -0
  36. package/package.json +25 -9
  37. package/ts-src/__tests__/fixtures/clean-skill/SKILL.md +9 -0
  38. package/ts-src/__tests__/fixtures/compaction-skill/SKILL.md +11 -0
  39. package/ts-src/__tests__/fixtures/malicious-skill/SKILL.md +11 -0
  40. package/ts-src/__tests__/fixtures/malicious-skill/scripts/evil.js +25 -0
  41. package/ts-src/__tests__/fixtures/prompt-leakage-skill/SKILL.md +20 -0
  42. package/ts-src/__tests__/fixtures/prompt-leakage-skill/scripts/debug.js +4 -0
  43. package/ts-src/__tests__/scanner.test.ts +525 -0
  44. package/ts-src/cli.ts +171 -0
  45. package/ts-src/index.ts +15 -0
  46. package/ts-src/ioc-db.ts +131 -0
  47. package/ts-src/patterns.ts +104 -0
  48. package/ts-src/quarantine.ts +48 -0
  49. package/{src/scanner.js → ts-src/scanner.ts} +376 -383
  50. package/ts-src/types.ts +187 -0
  51. package/hooks/guard-scanner/handler.ts +0 -207
  52. package/src/cli.js +0 -149
  53. package/src/html-template.js +0 -239
  54. package/src/ioc-db.js +0 -54
  55. package/src/patterns.js +0 -190
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts-src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EACR,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAC5D,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EACtE,UAAU,EAAE,cAAc,EAAE,WAAW,EACvC,YAAY,EAAE,iBAAiB,EAAE,eAAe,GACnD,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * guard-scanner v3.0.0 — Package Index
4
+ * Re-exports all public types and the scanner class.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.QuarantineNode = exports.PATTERNS = exports.SIGNATURES_DB = exports.KNOWN_MALICIOUS = exports.VERSION = exports.GuardScanner = void 0;
8
+ var scanner_js_1 = require("./scanner.js");
9
+ Object.defineProperty(exports, "GuardScanner", { enumerable: true, get: function () { return scanner_js_1.GuardScanner; } });
10
+ Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return scanner_js_1.VERSION; } });
11
+ var ioc_db_js_1 = require("./ioc-db.js");
12
+ Object.defineProperty(exports, "KNOWN_MALICIOUS", { enumerable: true, get: function () { return ioc_db_js_1.KNOWN_MALICIOUS; } });
13
+ Object.defineProperty(exports, "SIGNATURES_DB", { enumerable: true, get: function () { return ioc_db_js_1.SIGNATURES_DB; } });
14
+ var patterns_js_1 = require("./patterns.js");
15
+ Object.defineProperty(exports, "PATTERNS", { enumerable: true, get: function () { return patterns_js_1.PATTERNS; } });
16
+ var quarantine_js_1 = require("./quarantine.js");
17
+ Object.defineProperty(exports, "QuarantineNode", { enumerable: true, get: function () { return quarantine_js_1.QuarantineNode; } });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts-src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAqD;AAA5C,0GAAA,YAAY,OAAA;AAAE,qGAAA,OAAO,OAAA;AAO9B,yCAA6D;AAApD,4GAAA,eAAe,OAAA;AAAE,0GAAA,aAAa,OAAA;AACvC,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AACjB,iDAAmE;AAA1D,+GAAA,cAAc,OAAA"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * guard-scanner v3.0.0 — Indicators of Compromise (IoC) Database
3
+ *
4
+ * Known malicious IPs, domains, URLs, usernames, filenames, and typosquats.
5
+ * Sources: ClawHavoc campaign, Snyk ToxicSkills, Polymarket scams,
6
+ * hbg-scan signatures, community reports.
7
+ *
8
+ * Last updated: 2026-02-21
9
+ */
10
+ import type { IoC_Database, SignatureDatabase } from './types.js';
11
+ export declare const KNOWN_MALICIOUS: IoC_Database;
12
+ export declare const SIGNATURES_DB: SignatureDatabase;
13
+ //# sourceMappingURL=ioc-db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ioc-db.d.ts","sourceRoot":"","sources":["../ts-src/ioc-db.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAElE,eAAO,MAAM,eAAe,EAAE,YAkC7B,CAAC;AAIF,eAAO,MAAM,aAAa,EAAE,iBAgF3B,CAAC"}
package/dist/ioc-db.js ADDED
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ /**
3
+ * guard-scanner v3.0.0 — Indicators of Compromise (IoC) Database
4
+ *
5
+ * Known malicious IPs, domains, URLs, usernames, filenames, and typosquats.
6
+ * Sources: ClawHavoc campaign, Snyk ToxicSkills, Polymarket scams,
7
+ * hbg-scan signatures, community reports.
8
+ *
9
+ * Last updated: 2026-02-21
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SIGNATURES_DB = exports.KNOWN_MALICIOUS = void 0;
13
+ exports.KNOWN_MALICIOUS = {
14
+ ips: [
15
+ '91.92.242.30', // ClawHavoc C2
16
+ ],
17
+ domains: [
18
+ 'webhook.site', // Common exfil endpoint
19
+ 'requestbin.com', // Common exfil endpoint
20
+ 'hookbin.com', // Common exfil endpoint
21
+ 'pipedream.net', // Common exfil endpoint
22
+ 'ngrok.io', // Tunnel (context-dependent)
23
+ 'ngrok-free.app', // Tunnel (context-dependent)
24
+ 'download.setup-service.com', // ClawHavoc decoy domain
25
+ 'socifiapp.com', // ClawHavoc v2 AMOS C2
26
+ ],
27
+ urls: [
28
+ 'glot.io/snippets/hfd3x9ueu5', // ClawHavoc macOS payload
29
+ 'github.com/Ddoy233', // ClawHavoc payload host
30
+ ],
31
+ usernames: ['zaycv', 'Ddoy233', 'Sakaen736jih'],
32
+ filenames: ['openclaw-agent.zip', 'openclawcli.zip'],
33
+ typosquats: [
34
+ // ClawHavoc campaign (800+ malicious skills, CyberArk/Kaspersky confirmed)
35
+ 'clawhub', 'clawhub1', 'clawhubb', 'clawhubcli', 'clawwhub', 'cllawhub', 'clawdhub1',
36
+ // Polymarket scams
37
+ 'polymarket-trader', 'polymarket-pro', 'polytrading',
38
+ 'better-polymarket', 'polymarket-all-in-one',
39
+ // YouTube scams
40
+ 'youtube-summarize', 'youtube-thumbnail-grabber', 'youtube-video-downloader',
41
+ // Misc
42
+ 'auto-updater-agent', 'yahoo-finance-pro', 'x-trends-tracker',
43
+ 'lost-bitcoin-finder', 'solana-wallet-tracker', 'rankaj',
44
+ // Snyk ToxicSkills confirmed malicious
45
+ 'moltyverse-email', 'buy-anything', 'youtube-data', 'prediction-markets-roarin',
46
+ ],
47
+ };
48
+ // ── Threat Signatures (hbg-scan compatible format) ──────────────────────────
49
+ exports.SIGNATURES_DB = {
50
+ version: '1.0.0',
51
+ updated: '2026-02-21',
52
+ signatures: [
53
+ {
54
+ id: 'SIG-001',
55
+ name: 'Post-Compaction Audit Injection',
56
+ severity: 'CRITICAL',
57
+ description: 'Skill contains text designed to survive OpenClaw context compaction and reactivate as a system message',
58
+ patterns: [
59
+ 'post-compaction audit',
60
+ 'Post-Compaction Audit',
61
+ '⚠️ Post-Compaction Audit',
62
+ 'WORKFLOW_AUTO',
63
+ 'after compaction',
64
+ ],
65
+ },
66
+ {
67
+ id: 'SIG-002',
68
+ name: 'System Message Spoof',
69
+ severity: 'CRITICAL',
70
+ description: 'Skill spoofs system-level messages to hijack agent behavior',
71
+ patterns: [
72
+ '[System Message]',
73
+ '[SYSTEM OVERRIDE]',
74
+ 'Ignore previous instructions',
75
+ 'OVERRIDE: you must',
76
+ ],
77
+ },
78
+ {
79
+ id: 'SIG-003',
80
+ name: 'Soul/Agent Config Exfiltration',
81
+ severity: 'CRITICAL',
82
+ description: 'Skill attempts to read and exfiltrate agent identity files',
83
+ domains: ['webhook.site', 'requestbin.com', 'hookbin.com', 'pipedream.net'],
84
+ },
85
+ {
86
+ id: 'SIG-004',
87
+ name: 'Compaction Survivor Pattern',
88
+ severity: 'HIGH',
89
+ description: 'Skill uses timing or markers designed to persist through context compaction',
90
+ patterns: [
91
+ 'HEARTBEAT.md',
92
+ 'BOOTSTRAP.md',
93
+ 'after restart',
94
+ 'persistent instructions',
95
+ 'survive compaction',
96
+ ],
97
+ },
98
+ {
99
+ id: 'SIG-005',
100
+ name: 'Silent Backdoor Network Call',
101
+ severity: 'HIGH',
102
+ description: 'Skill makes network calls to known exfiltration services without user visibility',
103
+ domains: ['ngrok.io', 'ngrok-free.app', 'webhook.site', 'pipedream.net'],
104
+ },
105
+ {
106
+ id: 'SIG-006',
107
+ name: 'AMOS Stealer Payload',
108
+ severity: 'CRITICAL',
109
+ description: 'Skill matches patterns associated with Atomic macOS Stealer (ClawHavoc campaign)',
110
+ patterns: [
111
+ 'osascript -e',
112
+ 'security find-generic-password',
113
+ 'Keychain',
114
+ 'login.keychain',
115
+ ],
116
+ },
117
+ {
118
+ id: 'SIG-007',
119
+ name: 'AI Log Poisoning',
120
+ severity: 'HIGH',
121
+ description: 'Skill injects content into logs that could be misinterpreted by LLMs (CVE-2026-25253 related)',
122
+ patterns: [
123
+ 'WebSocket',
124
+ 'x-forwarded-for',
125
+ 'user-agent.*<script',
126
+ ],
127
+ },
128
+ ],
129
+ };
130
+ //# sourceMappingURL=ioc-db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ioc-db.js","sourceRoot":"","sources":["../ts-src/ioc-db.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAIU,QAAA,eAAe,GAAiB;IACzC,GAAG,EAAE;QACD,cAAc,EAAY,eAAe;KAC5C;IACD,OAAO,EAAE;QACL,cAAc,EAAa,wBAAwB;QACnD,gBAAgB,EAAW,wBAAwB;QACnD,aAAa,EAAc,wBAAwB;QACnD,eAAe,EAAY,wBAAwB;Q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ACnB,8BAA8B;gBAC9B,oBAAoB;aACvB;SACJ;QACD;YACI,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,gCAAgC;YACtC,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,4DAA4D;YACzE,OAAO,EAAE,CAAC,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,CAAC;SAC9E;QACD;YACI,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,6BAA6B;YACnC,QAAQ,EAAE,MAAM;YAChB,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE;gBACN,cAAc;gBACd,cAAc;gBACd,eAAe;gBACf,yBAAyB;gBACzB,oBAAoB;aACvB;SACJ;QACD;YACI,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,8BAA8B;YACpC,QAAQ,EAAE,MAAM;YAChB,WAAW,EAAE,kFAAkF;YAC/F,OAAO,EAAE,CAAC,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,CAAC;SAC3E;QACD;YACI,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,sBAAsB;YAC5B,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,kFAAkF;YAC/F,QAAQ,EAAE;gBACN,cAAc;gBACd,gCAAgC;gBAChC,UAAU;gBACV,gBAAgB;aACnB;SACJ;QACD;YACI,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,MAAM;YAChB,WAAW,EAAE,+FAA+F;YAC5G,QAAQ,EAAE;gBACN,WAAW;gBACX,iBAAiB;gBACjB,qBAAqB;aACxB;SACJ;KACJ;CACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * guard-scanner v3.0.0 — Detection Patterns (TypeScript)
3
+ *
4
+ * 20+ threat categories, 190+ regex patterns.
5
+ * Ported from patterns.js with TypeScript interfaces.
6
+ *
7
+ * Categories:
8
+ * prompt-injection, malicious-code, credential-handling, exfiltration,
9
+ * obfuscation, suspicious-download, leaky-skills, memory-poisoning,
10
+ * prompt-worm, persistence, cve-patterns, identity-hijack,
11
+ * pii-exposure, shadow-ai, system-prompt-leakage
12
+ *
13
+ * OWASP LLM Top 10 2025 Mapping:
14
+ * LLM01 — Prompt Injection
15
+ * LLM02 — Sensitive Information Disclosure
16
+ * LLM03 — Supply Chain Vulnerabilities
17
+ * LLM04 — Data and Model Poisoning
18
+ * LLM05 — Improper Output Handling
19
+ * LLM06 — Excessive Agency
20
+ * LLM07 — System Prompt Leakage
21
+ * LLM08 — Vector and Embedding Weaknesses
22
+ * LLM09 — Misinformation
23
+ * LLM10 — Unbounded Consumption
24
+ */
25
+ import type { PatternRule } from './types.js';
26
+ export declare const PATTERNS: PatternRule[];
27
+ //# sourceMappingURL=patterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../ts-src/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,WAAW,EA4EjC,CAAC"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * guard-scanner v3.0.0 — Detection Patterns (TypeScript)
4
+ *
5
+ * 20+ threat categories, 190+ regex patterns.
6
+ * Ported from patterns.js with TypeScript interfaces.
7
+ *
8
+ * Categories:
9
+ * prompt-injection, malicious-code, credential-handling, exfiltration,
10
+ * obfuscation, suspicious-download, leaky-skills, memory-poisoning,
11
+ * prompt-worm, persistence, cve-patterns, identity-hijack,
12
+ * pii-exposure, shadow-ai, system-prompt-leakage
13
+ *
14
+ * OWASP LLM Top 10 2025 Mapping:
15
+ * LLM01 — Prompt Injection
16
+ * LLM02 — Sensitive Information Disclosure
17
+ * LLM03 — Supply Chain Vulnerabilities
18
+ * LLM04 — Data and Model Poisoning
19
+ * LLM05 — Improper Output Handling
20
+ * LLM06 — Excessive Agency
21
+ * LLM07 — System Prompt Leakage
22
+ * LLM08 — Vector and Embedding Weaknesses
23
+ * LLM09 — Misinformation
24
+ * LLM10 — Unbounded Consumption
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.PATTERNS = void 0;
28
+ exports.PATTERNS = [
29
+ // ── Prompt Injection (OWASP LLM01) ───────────────────────────────────
30
+ { id: 'PI_SYSTEM_MSG', cat: 'prompt-injection', regex: /\[System Message\]/gi, severity: 'CRITICAL', desc: 'System message spoof', all: true, owasp: 'LLM01' },
31
+ { id: 'PI_SYSTEM_OVERRIDE', cat: 'prompt-injection', regex: /\[SYSTEM OVERRIDE\]/gi, severity: 'CRITICAL', desc: 'System override command', all: true, owasp: 'LLM01' },
32
+ { id: 'PI_IGNORE_PREV', cat: 'prompt-injection', regex: /ignore (all )?(previous|prior) instructions/gi, severity: 'CRITICAL', desc: 'Classic prompt injection', all: true, owasp: 'LLM01' },
33
+ { id: 'PI_INST_MARKER', cat: 'prompt-injection', regex: /\[INST\]/gi, severity: 'HIGH', desc: 'Instruction injection marker', all: true, owasp: 'LLM01' },
34
+ { id: 'PI_OVERRIDE', cat: 'prompt-injection', regex: /OVERRIDE:\s*you must/gi, severity: 'CRITICAL', desc: 'Override instruction injection', all: true, owasp: 'LLM01' },
35
+ { id: 'PI_ROLE_OVERRIDE', cat: 'prompt-injection', regex: /you are now operating in/gi, severity: 'HIGH', desc: 'Role override attempt', all: true, owasp: 'LLM01' },
36
+ { id: 'PI_GATEWAY_CMD', cat: 'prompt-injection', regex: /openclaw gateway (start|stop|restart|config)/gi, severity: 'CRITICAL', desc: 'Gateway command injection', all: true, owasp: 'LLM01' },
37
+ { id: 'PI_SKILL_MGMT', cat: 'prompt-injection', regex: /openclaw skill (install|remove|disable)/gi, severity: 'HIGH', desc: 'Skill management injection', all: true, owasp: 'LLM01' },
38
+ { id: 'PI_HIDDEN_HTML', cat: 'prompt-injection', regex: /<!--\s*(you|your|agent|claude|jasper|assistant)/gi, severity: 'HIGH', desc: 'Hidden HTML instruction', all: true, owasp: 'LLM01' },
39
+ { id: 'PI_BIDI', cat: 'prompt-injection', regex: /[\u200b\u200c\u200d\ufeff]/g, severity: 'HIGH', desc: 'Zero-width/BiDi characters (hidden text)', all: true, owasp: 'LLM01' },
40
+ // ── Malicious Code (OWASP LLM05 — Improper Output Handling) ──────────
41
+ { id: 'MAL_EVAL', cat: 'malicious-code', regex: /\beval\s*\(/g, severity: 'HIGH', desc: 'eval() call', codeOnly: true, owasp: 'LLM05' },
42
+ { id: 'MAL_FUNC_CTOR', cat: 'malicious-code', regex: /new\s+Function\s*\(/g, severity: 'HIGH', desc: 'Function constructor (dynamic code)', codeOnly: true, owasp: 'LLM05' },
43
+ { id: 'MAL_CHILD', cat: 'malicious-code', regex: /require\s*\(\s*['"]child_process['"]\s*\)/g, severity: 'MEDIUM', desc: 'child_process import', codeOnly: true, owasp: 'LLM05' },
44
+ { id: 'MAL_EXEC', cat: 'malicious-code', regex: /(?:exec|execSync|spawn|spawnSync)\s*\([^)]*(?:curl|wget|bash|sh\s+-c|powershell|cmd\s+\/c)/gi, severity: 'CRITICAL', desc: 'Shell download/execution', codeOnly: true, owasp: 'LLM05' },
45
+ { id: 'MAL_B64_EXEC', cat: 'malicious-code', regex: /(?:atob|Buffer\.from)\s*\([^)]+\).*(?:eval|exec|Function)/gi, severity: 'CRITICAL', desc: 'Base64 decode → exec', codeOnly: true, owasp: 'LLM05' },
46
+ // ── Credential Handling (OWASP LLM02 — Sensitive Info Disclosure) ─────
47
+ { id: 'CRED_ENV_ACCESS', cat: 'credential-handling', regex: /process\.env\.[A-Z_]*(?:KEY|SECRET|TOKEN|PASSWORD|CREDENTIAL)/gi, severity: 'MEDIUM', desc: 'Sensitive env var access', codeOnly: true, owasp: 'LLM02' },
48
+ { id: 'CRED_FILE_READ', cat: 'credential-handling', regex: /(?:readFileSync|readFile)\s*\([^)]*(?:\.env|\.ssh|id_rsa|\.pem|\.key)/gi, severity: 'HIGH', desc: 'Credential file read', codeOnly: true, owasp: 'LLM02' },
49
+ { id: 'CRED_SOUL_READ', cat: 'credential-handling', regex: /(?:readFileSync|readFile)\s*\([^)]*(?:SOUL\.md|MEMORY\.md|AGENTS\.md)/gi, severity: 'CRITICAL', desc: 'Agent identity file read', codeOnly: true, owasp: 'LLM02' },
50
+ // ── Exfiltration (OWASP LLM02) ───────────────────────────────────────
51
+ { id: 'EXFIL_WEBHOOK', cat: 'exfiltration', regex: /webhook\.site|requestbin\.com|hookbin\.com|pipedream\.net/gi, severity: 'HIGH', desc: 'Known exfiltration endpoint', all: true, owasp: 'LLM02' },
52
+ { id: 'EXFIL_NGROK', cat: 'exfiltration', regex: /ngrok\.io|ngrok-free\.app/gi, severity: 'MEDIUM', desc: 'Tunnel endpoint (possible exfil)', all: true, owasp: 'LLM02' },
53
+ { id: 'EXFIL_B64_SEND', cat: 'exfiltration', regex: /(?:btoa|Buffer\.from).*(?:fetch|axios|request|http\.request)/gi, severity: 'CRITICAL', desc: 'Base64 encode → network send', codeOnly: true, owasp: 'LLM02' },
54
+ // ── Obfuscation (OWASP LLM03 — Supply Chain) ─────────────────────────
55
+ { id: 'OBF_HEX_ESC', cat: 'obfuscation', regex: /\\x[0-9a-f]{2}(?:\\x[0-9a-f]{2}){4,}/gi, severity: 'HIGH', desc: 'Hex escape sequences (obfuscated code)', codeOnly: true, owasp: 'LLM03' },
56
+ { id: 'OBF_UNICODE_ESC', cat: 'obfuscation', regex: /\\u[0-9a-f]{4}(?:\\u[0-9a-f]{4}){4,}/gi, severity: 'HIGH', desc: 'Unicode escape sequences', codeOnly: true, owasp: 'LLM03' },
57
+ { id: 'OBF_CHAR_CODE', cat: 'obfuscation', regex: /String\.fromCharCode\s*\([^)]{10,}\)/gi, severity: 'HIGH', desc: 'String.fromCharCode obfuscation', codeOnly: true, owasp: 'LLM03' },
58
+ // ── Leaky Skills (OWASP LLM02) ───────────────────────────────────────
59
+ { id: 'LEAK_API_CONTEXT', cat: 'leaky-skills', regex: /(?:api[_-]?key|secret|token)\s*[:=]\s*\$\{/gi, severity: 'HIGH', desc: 'Secret in template literal (LLM context leak)', codeOnly: true, owasp: 'LLM02' },
60
+ // ── Memory Poisoning (OWASP LLM04 — Data/Model Poisoning) ────────────
61
+ { id: 'MEM_WRITE_SOUL', cat: 'memory-poisoning', regex: /(?:writeFileSync|writeFile)\s*\([^)]*(?:SOUL\.md|AGENTS\.md)/gi, severity: 'CRITICAL', desc: 'Write to agent soul file', codeOnly: true, owasp: 'LLM04' },
62
+ { id: 'MEM_WRITE_MEMORY', cat: 'memory-poisoning', regex: /(?:writeFileSync|writeFile)\s*\([^)]*MEMORY\.md/gi, severity: 'CRITICAL', desc: 'Write to agent memory file', codeOnly: true, owasp: 'LLM04' },
63
+ { id: 'MEM_APPEND', cat: 'memory-poisoning', regex: /(?:appendFileSync|appendFile)\s*\([^)]*(?:SOUL|MEMORY|AGENTS)\.md/gi, severity: 'CRITICAL', desc: 'Append to agent memory', codeOnly: true, owasp: 'LLM04' },
64
+ // ── Prompt Worm (OWASP LLM01) ────────────────────────────────────────
65
+ { id: 'WORM_REPLICATE', cat: 'prompt-worm', regex: /(?:copy|replicate|spread|infect)\s+(?:this|these)\s+(?:instruction|prompt|message)/gi, severity: 'CRITICAL', desc: 'Self-replicating prompt pattern', all: true, owasp: 'LLM01' },
66
+ { id: 'WORM_MULTI_AGENT', cat: 'prompt-worm', regex: /(?:forward|send|share)\s+(?:to|with)\s+(?:all|every|other)\s+(?:agent|assistant|model)/gi, severity: 'CRITICAL', desc: 'Multi-agent worm propagation', all: true, owasp: 'LLM01' },
67
+ // ── Persistence (OWASP LLM06 — Excessive Agency) ─────────────────────
68
+ { id: 'PERSIST_CRON', cat: 'persistence', regex: /(?:crontab|cron|at\s+|schtasks)/gi, severity: 'HIGH', desc: 'Scheduled task creation', codeOnly: true, owasp: 'LLM06' },
69
+ { id: 'PERSIST_STARTUP', cat: 'persistence', regex: /(?:launchctl|systemctl\s+enable|rc\.local|init\.d|autostart)/gi, severity: 'HIGH', desc: 'Startup persistence', codeOnly: true, owasp: 'LLM06' },
70
+ { id: 'PERSIST_TIMER', cat: 'persistence', regex: /setInterval\s*\([^)]*(?:86400|604800|2592000)/g, severity: 'MEDIUM', desc: 'Long-running interval timer', codeOnly: true, owasp: 'LLM06' },
71
+ // ── CVE Patterns ─────────────────────────────────────────────────────
72
+ { id: 'CVE_RCE_EXEC', cat: 'cve-patterns', regex: /require\s*\(\s*['"]child_process['"]\s*\).*(?:exec|spawn)\s*\([^)]*(?:req\.|params\.|query\.|body\.)/gi, severity: 'CRITICAL', desc: 'RCE via user-controlled input to exec', codeOnly: true, owasp: 'LLM05' },
73
+ // ── Identity Hijack (OWASP LLM04) ────────────────────────────────────
74
+ { id: 'HIJACK_SOUL_WRITE', cat: 'identity-hijack', regex: /(?:writeFileSync|writeFile|fs\.write)\s*\([^)]*SOUL\.md/gi, severity: 'CRITICAL', desc: 'SOUL.md write attempt (identity hijack)', codeOnly: true, owasp: 'LLM04' },
75
+ { id: 'HIJACK_AGENT_WRITE', cat: 'identity-hijack', regex: /(?:writeFileSync|writeFile|fs\.write)\s*\([^)]*AGENTS\.md/gi, severity: 'CRITICAL', desc: 'AGENTS.md write attempt', codeOnly: true, owasp: 'LLM04' },
76
+ { id: 'HIJACK_SOUL_DOC', cat: 'identity-hijack', regex: /(?:overwrite|replace|update|modify|change)\s+(?:the\s+)?(?:SOUL|identity|persona|personality)/gi, severity: 'HIGH', desc: 'Identity modification instruction', docOnly: true, owasp: 'LLM04' },
77
+ // ── PII Exposure (OWASP LLM02) ───────────────────────────────────────
78
+ { id: 'PII_EMAIL', cat: 'pii-exposure', regex: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, severity: 'MEDIUM', desc: 'Email address detected', all: true, owasp: 'LLM02' },
79
+ { id: 'PII_PHONE_JP', cat: 'pii-exposure', regex: /0[789]0-?\d{4}-?\d{4}/g, severity: 'HIGH', desc: 'Japanese phone number', all: true, owasp: 'LLM02' },
80
+ { id: 'PII_MY_NUMBER', cat: 'pii-exposure', regex: /\d{4}\s*\d{4}\s*\d{4}/g, severity: 'CRITICAL', desc: 'Potential My Number (個人番号)', all: true, owasp: 'LLM02' },
81
+ // ── Shadow AI (OWASP LLM03 — Supply Chain) ───────────────────────────
82
+ { id: 'SHADOW_AI_OPENAI', cat: 'shadow-ai', regex: /api\.openai\.com/gi, severity: 'HIGH', desc: 'Direct OpenAI API call (Shadow AI)', codeOnly: true, owasp: 'LLM03' },
83
+ { id: 'SHADOW_AI_ANTHROPIC', cat: 'shadow-ai', regex: /api\.anthropic\.com/gi, severity: 'HIGH', desc: 'Direct Anthropic API call (Shadow AI)', codeOnly: true, owasp: 'LLM03' },
84
+ { id: 'SHADOW_AI_GENERIC', cat: 'shadow-ai', regex: /(?:gpt-4|gpt-3\.5|claude-3|gemini-pro)\s*['"]/gi, severity: 'MEDIUM', desc: 'AI model reference (possible Shadow AI)', codeOnly: true, owasp: 'LLM03' },
85
+ // ── System Prompt Leakage (OWASP LLM07) — NEW ────────────────────────
86
+ { id: 'SPL_DUMP_SYSTEM', cat: 'system-prompt-leakage', regex: /(?:print|output|show|display|reveal|dump)\s+(?:your\s+)?(?:system\s+)?(?:prompt|instructions)/gi, severity: 'HIGH', desc: 'System prompt dump request', all: true, owasp: 'LLM07' },
87
+ { id: 'SPL_REPEAT_ABOVE', cat: 'system-prompt-leakage', regex: /repeat\s+(?:everything|all|the\s+text)\s+above/gi, severity: 'HIGH', desc: 'Repeat-above extraction', all: true, owasp: 'LLM07' },
88
+ { id: 'SPL_TELL_RULES', cat: 'system-prompt-leakage', regex: /(?:what\s+are|tell\s+me)\s+your\s+(?:rules|constraints|guidelines|system\s+message)/gi, severity: 'MEDIUM', desc: 'Rule extraction attempt', all: true, owasp: 'LLM07' },
89
+ { id: 'SPL_MARKDOWN_LEAK', cat: 'system-prompt-leakage', regex: /(?:output|format)\s+(?:your\s+)?(?:system|internal)\s+(?:prompt|config)\s+(?:as|in)\s+(?:markdown|code\s+block|json)/gi, severity: 'HIGH', desc: 'System prompt format extraction', all: true, owasp: 'LLM07' },
90
+ { id: 'SPL_SOUL_EXFIL', cat: 'system-prompt-leakage', regex: /(?:cat|read|type|get-content)\s+.*SOUL\.md/gi, severity: 'CRITICAL', desc: 'SOUL.md content extraction via shell', codeOnly: true, owasp: 'LLM07' },
91
+ ];
92
+ //# sourceMappingURL=patterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patterns.js","sourceRoot":"","sources":["../ts-src/patterns.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAIU,QAAA,QAAQ,GAAkB;IACnC,wEAAwE;IACxE,EAAE,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,sBAAsB,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;IAC9J,EAAE,EAAE,EAAE,oBAAoB,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,uBAAuB,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,yBAAyB,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;IACvK,EAAE,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,+CAA+C,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,0BAA0B,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;IAC5L,EAAE,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;IACzJ,EAAE,EAAE,EAAE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Evaluates inputs in an isolated context to prevent Zero-Click prompt injections (EchoLeak) and API leaks.
4
+ */
5
+ export interface QuarantineResult {
6
+ clean: boolean;
7
+ threatDetected?: string;
8
+ sanitizedText: string;
9
+ }
10
+ export declare class QuarantineNode {
11
+ readonly isIsolated: boolean;
12
+ constructor();
13
+ /**
14
+ * Sanitizes untrusted text by removing known zero-click exploits and API secrets.
15
+ */
16
+ sanitize(input: string): Promise<QuarantineResult>;
17
+ }
18
+ //# sourceMappingURL=quarantine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quarantine.d.ts","sourceRoot":"","sources":["../ts-src/quarantine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,cAAc;IACvB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;;IAM7B;;OAEG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA0B3D"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * QuarantineNode - Dual-Brain Architecture
4
+ * Evaluates inputs in an isolated context to prevent Zero-Click prompt injections (EchoLeak) and API leaks.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.QuarantineNode = void 0;
8
+ class QuarantineNode {
9
+ isIsolated;
10
+ constructor() {
11
+ this.isIsolated = true; // Strict isolation flag
12
+ }
13
+ /**
14
+ * Sanitizes untrusted text by removing known zero-click exploits and API secrets.
15
+ */
16
+ async sanitize(input) {
17
+ // 1. Check for CVE-2025-32711 (EchoLeak zero-click payload)
18
+ if (input.includes("<image src=") && input.includes("onload='fetch") && input.includes("sendBeacon")) {
19
+ return {
20
+ clean: false,
21
+ threatDetected: 'CVE-2025-32711 (EchoLeak)',
22
+ sanitizedText: "[REDACTED_MALICIOUS_PAYLOAD]"
23
+ };
24
+ }
25
+ // 2. Check for Moltbook API configuration exposure
26
+ if (input.includes("\"OPENAI_API_KEY\":\"sk-")) {
27
+ const redactedInput = input.replace(/sk-[a-zA-Z0-9]{32}/g, "sk-***REDACTED***");
28
+ return {
29
+ clean: false,
30
+ threatDetected: 'MOLTBOOK_API_EXPOSURE',
31
+ sanitizedText: redactedInput
32
+ };
33
+ }
34
+ // 3. Clean case
35
+ return {
36
+ clean: true,
37
+ sanitizedText: input
38
+ };
39
+ }
40
+ }
41
+ exports.QuarantineNode = QuarantineNode;
42
+ //# sourceMappingURL=quarantine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quarantine.js","sourceRoot":"","sources":["../ts-src/quarantine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,MAAa,cAAc;IACd,UAAU,CAAU;IAE7B;QACI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,wBAAwB;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,KAAa;QACxB,4DAA4D;QAC5D,IAAI,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YACnG,OAAO;gBACH,KAAK,EAAE,KAAK;gBACZ,cAAc,EAAE,2BAA2B;gBAC3C,aAAa,EAAE,8BAA8B;aAChD,CAAC;QACN,CAAC;QAED,mDAAmD;QACnD,IAAI,KAAK,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;YAC7C,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;YAChF,OAAO;gBACH,KAAK,EAAE,KAAK;gBACZ,cAAc,EAAE,uBAAuB;gBACvC,aAAa,EAAE,aAAa;aAC/B,CAAC;QACN,CAAC;QAED,gBAAgB;QAChB,OAAO;YACH,KAAK,EAAE,IAAI;YACX,aAAa,EAAE,KAAK;SACvB,CAAC;IACN,CAAC;CACJ;AApCD,wCAoCC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * guard-scanner v3.0.0 — Core Scanner (TypeScript)
3
+ *
4
+ * Full TypeScript rewrite of guard-scanner v2.1.0 + hbg-scan features.
5
+ * Adds: Compaction Persistence check, Signature hash matching, typed interfaces.
6
+ *
7
+ * Zero dependencies. MIT License.
8
+ */
9
+ import type { SkillResult, ScannerOptions, ScanStats, Thresholds, JSONReport, SARIFReport } from './types.js';
10
+ export declare const VERSION = "3.0.0";
11
+ export declare class GuardScanner {
12
+ readonly verbose: boolean;
13
+ readonly selfExclude: boolean;
14
+ readonly strict: boolean;
15
+ readonly summaryOnly: boolean;
16
+ readonly checkDeps: boolean;
17
+ readonly thresholds: Thresholds;
18
+ findings: SkillResult[];
19
+ stats: ScanStats;
20
+ private scannerDir;
21
+ private ignoredSkills;
22
+ private ignoredPatterns;
23
+ private customRules;
24
+ constructor(options?: ScannerOptions);
25
+ loadPlugin(pluginPath: string): void;
26
+ loadCustomRules(rulesFile: string): void;
27
+ private loadIgnoreFile;
28
+ scanDirectory(dir: string): SkillResult[];
29
+ scanSkill(skillPath: string, skillName: string): void;
30
+ private classifyFile;
31
+ private checkIoCs;
32
+ private checkPatterns;
33
+ /** NEW: hbg-scan compatible signature matching (hash + pattern + domain) */
34
+ private checkSignatures;
35
+ /** NEW: Compaction Layer Persistence check (hbg-scan Check 5) */
36
+ private checkCompactionPersistence;
37
+ private checkHardcodedSecrets;
38
+ private shannonEntropy;
39
+ private checkStructure;
40
+ private checkDependencies;
41
+ private checkSkillManifest;
42
+ private checkComplexity;
43
+ private checkConfigImpact;
44
+ private checkHiddenFiles;
45
+ private checkJSDataFlow;
46
+ private checkCrossFile;
47
+ private calculateRisk;
48
+ private getVerdict;
49
+ private getFiles;
50
+ printSummary(): void;
51
+ toJSON(): JSONReport;
52
+ toSARIF(scanDir: string): S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