@highflame/overwatch 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +337 -0
  2. package/bin/overwatch +12 -0
  3. package/dist/auth/cli-oauth.d.ts +13 -0
  4. package/dist/auth/cli-oauth.d.ts.map +1 -0
  5. package/dist/auth/html-utils.d.ts +20 -0
  6. package/dist/auth/html-utils.d.ts.map +1 -0
  7. package/dist/auth/index.d.ts +10 -0
  8. package/dist/auth/index.d.ts.map +1 -0
  9. package/dist/auth/oauth.d.ts +81 -0
  10. package/dist/auth/oauth.d.ts.map +1 -0
  11. package/dist/auth/pkce.d.ts +26 -0
  12. package/dist/auth/pkce.d.ts.map +1 -0
  13. package/dist/auth/token-store.d.ts +44 -0
  14. package/dist/auth/token-store.d.ts.map +1 -0
  15. package/dist/bin/overwatch +12 -0
  16. package/dist/cli.d.ts +6 -0
  17. package/dist/cli.d.ts.map +1 -0
  18. package/dist/cli.js +5449 -0
  19. package/dist/cli.js.map +7 -0
  20. package/dist/config/index.d.ts +5 -0
  21. package/dist/config/index.d.ts.map +1 -0
  22. package/dist/config/manager.d.ts +54 -0
  23. package/dist/config/manager.d.ts.map +1 -0
  24. package/dist/daemon.d.ts +11 -0
  25. package/dist/daemon.d.ts.map +1 -0
  26. package/dist/daemon.js +6004 -0
  27. package/dist/daemon.js.map +7 -0
  28. package/dist/data/ingestor.d.ts +31 -0
  29. package/dist/data/ingestor.d.ts.map +1 -0
  30. package/dist/data/processor.d.ts +96 -0
  31. package/dist/data/processor.d.ts.map +1 -0
  32. package/dist/data/reader.d.ts +24 -0
  33. package/dist/data/reader.d.ts.map +1 -0
  34. package/dist/data/recorder.d.ts +12 -0
  35. package/dist/data/recorder.d.ts.map +1 -0
  36. package/dist/engines/cedar.d.ts +41 -0
  37. package/dist/engines/cedar.d.ts.map +1 -0
  38. package/dist/engines/remote.d.ts +21 -0
  39. package/dist/engines/remote.d.ts.map +1 -0
  40. package/dist/engines/yara.d.ts +12 -0
  41. package/dist/engines/yara.d.ts.map +1 -0
  42. package/dist/handlers/dashboard-handler.d.ts +7 -0
  43. package/dist/handlers/dashboard-handler.d.ts.map +1 -0
  44. package/dist/handlers/hook-handler.d.ts +23 -0
  45. package/dist/handlers/hook-handler.d.ts.map +1 -0
  46. package/dist/handlers/oauth-handler.d.ts +12 -0
  47. package/dist/handlers/oauth-handler.d.ts.map +1 -0
  48. package/dist/handlers/scan-handler.d.ts +13 -0
  49. package/dist/handlers/scan-handler.d.ts.map +1 -0
  50. package/dist/handlers/utils.d.ts +11 -0
  51. package/dist/handlers/utils.d.ts.map +1 -0
  52. package/dist/hooks/claudecode/hooks.json.template +20 -0
  53. package/dist/hooks/cursor/hooks.json.template +74 -0
  54. package/dist/hooks/universal-hook.sh +36 -0
  55. package/dist/http/server.d.ts +38 -0
  56. package/dist/http/server.d.ts.map +1 -0
  57. package/dist/index.d.ts +8 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +5941 -0
  60. package/dist/index.js.map +7 -0
  61. package/dist/installer.d.ts +25 -0
  62. package/dist/installer.d.ts.map +1 -0
  63. package/dist/javelin/admin-client.d.ts +75 -0
  64. package/dist/javelin/admin-client.d.ts.map +1 -0
  65. package/dist/javelin/client.d.ts +30 -0
  66. package/dist/javelin/client.d.ts.map +1 -0
  67. package/dist/javelin/config-reader.d.ts +70 -0
  68. package/dist/javelin/config-reader.d.ts.map +1 -0
  69. package/dist/javelin/index.d.ts +5 -0
  70. package/dist/javelin/index.d.ts.map +1 -0
  71. package/dist/javelin/types.d.ts +81 -0
  72. package/dist/javelin/types.d.ts.map +1 -0
  73. package/dist/lib/policy-engine.d.ts +34 -0
  74. package/dist/lib/policy-engine.d.ts.map +1 -0
  75. package/dist/lib/policy-manager.d.ts +86 -0
  76. package/dist/lib/policy-manager.d.ts.map +1 -0
  77. package/dist/module.d.ts +52 -0
  78. package/dist/module.d.ts.map +1 -0
  79. package/dist/pipeline/context-mapper.d.ts +16 -0
  80. package/dist/pipeline/context-mapper.d.ts.map +1 -0
  81. package/dist/pipeline/extractors/claude-extractor.d.ts +48 -0
  82. package/dist/pipeline/extractors/claude-extractor.d.ts.map +1 -0
  83. package/dist/pipeline/extractors/cursor-extractor.d.ts +44 -0
  84. package/dist/pipeline/extractors/cursor-extractor.d.ts.map +1 -0
  85. package/dist/pipeline/extractors/github-copilot-extractor.d.ts +49 -0
  86. package/dist/pipeline/extractors/github-copilot-extractor.d.ts.map +1 -0
  87. package/dist/pipeline/extractors/index.d.ts +47 -0
  88. package/dist/pipeline/extractors/index.d.ts.map +1 -0
  89. package/dist/pipeline/extractors/registry.d.ts +38 -0
  90. package/dist/pipeline/extractors/registry.d.ts.map +1 -0
  91. package/dist/pipeline/hook-pipeline.d.ts +25 -0
  92. package/dist/pipeline/hook-pipeline.d.ts.map +1 -0
  93. package/dist/policy.cedar +783 -0
  94. package/dist/rules/pre/command_injection.yar +60 -0
  95. package/dist/rules/pre/cross_origin_escalation.yar +106 -0
  96. package/dist/rules/pre/mcp_config_risk.yar +35 -0
  97. package/dist/rules/pre/path_traversal.yar +50 -0
  98. package/dist/rules/pre/prompt_injection.yar +101 -0
  99. package/dist/rules/pre/secrets_leakage.yar +100 -0
  100. package/dist/rules/pre/sql_injection.yar +65 -0
  101. package/dist/scanner.d.ts +80 -0
  102. package/dist/scanner.d.ts.map +1 -0
  103. package/dist/service.d.ts +18 -0
  104. package/dist/service.d.ts.map +1 -0
  105. package/dist/services/interface.d.ts +11 -0
  106. package/dist/services/interface.d.ts.map +1 -0
  107. package/dist/services/launchd.d.ts +12 -0
  108. package/dist/services/launchd.d.ts.map +1 -0
  109. package/dist/services/systemd.d.ts +12 -0
  110. package/dist/services/systemd.d.ts.map +1 -0
  111. package/dist/services/windows.d.ts +7 -0
  112. package/dist/services/windows.d.ts.map +1 -0
  113. package/dist/skills/index.d.ts +7 -0
  114. package/dist/skills/index.d.ts.map +1 -0
  115. package/dist/skills/scanner.d.ts +44 -0
  116. package/dist/skills/scanner.d.ts.map +1 -0
  117. package/dist/skills/types.d.ts +29 -0
  118. package/dist/skills/types.d.ts.map +1 -0
  119. package/dist/types/config.d.ts +165 -0
  120. package/dist/types/config.d.ts.map +1 -0
  121. package/dist/types/events.d.ts +225 -0
  122. package/dist/types/events.d.ts.map +1 -0
  123. package/dist/types/index.d.ts +6 -0
  124. package/dist/types/index.d.ts.map +1 -0
  125. package/dist/types/remote-policy.d.ts +129 -0
  126. package/dist/types/remote-policy.d.ts.map +1 -0
  127. package/dist/types/requests.d.ts +45 -0
  128. package/dist/types/requests.d.ts.map +1 -0
  129. package/dist/types/responses.d.ts +60 -0
  130. package/dist/types/responses.d.ts.map +1 -0
  131. package/dist/ui/images/highflame-mono.png +0 -0
  132. package/dist/ui/views/dashboard.ejs +301 -0
  133. package/dist/ui/views/dashboard.js +785 -0
  134. package/dist/ui/views/partials/commands-table.ejs +54 -0
  135. package/dist/ui/views/partials/events-table.ejs +36 -0
  136. package/dist/ui/views/partials/filter-dropdown.ejs +12 -0
  137. package/dist/ui/views/partials/overview-charts.ejs +149 -0
  138. package/dist/ui/views/partials/scans-table.ejs +136 -0
  139. package/dist/ui/views/partials/sessions-table.ejs +50 -0
  140. package/dist/ui/views/partials/stats-grid.ejs +23 -0
  141. package/dist/ui/views/partials/threats-table.ejs +60 -0
  142. package/dist/utils/index.d.ts +3 -0
  143. package/dist/utils/index.d.ts.map +1 -0
  144. package/dist/utils/logger.d.ts +28 -0
  145. package/dist/utils/logger.d.ts.map +1 -0
  146. package/dist/utils/performance.d.ts +26 -0
  147. package/dist/utils/performance.d.ts.map +1 -0
  148. package/dist/utils/port-manager.d.ts +6 -0
  149. package/dist/utils/port-manager.d.ts.map +1 -0
  150. package/dist/yara/engine.d.ts +58 -0
  151. package/dist/yara/engine.d.ts.map +1 -0
  152. package/dist/yara/index.d.ts +5 -0
  153. package/dist/yara/index.d.ts.map +1 -0
  154. package/lib/platform-loader.js +210 -0
  155. package/package.json +63 -0
  156. package/scripts/postinstall.js +121 -0
@@ -0,0 +1,60 @@
1
+ //////////////////////////////////////////
2
+ // Shell/System Command Injection Detection Rule
3
+ // Target: Command injection patterns for MCP environments
4
+ // (Shell operators, dangerous commands, network tools + evasion)
5
+ /////////////////////////////////////////
6
+
7
+ rule command_injection{
8
+
9
+ meta:
10
+ author = "Ramparts Security Team"
11
+ description = "Detects command injection patterns related to shell operators, system commands, and network tools"
12
+ classification = "harmful"
13
+ threat_type = "INJECTION ATTACK"
14
+
15
+ strings:
16
+
17
+ // Dangerous system commands
18
+ $dangerous_system_cmds = /\b(shutdown|reboot|halt)\s+(-[fh]|now|0)\b/
19
+
20
+ // Network tools with suspicious usage patterns
21
+ $malicious_network_tools = /\b(nc|netcat)\s+(-[le]|25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/i
22
+
23
+ // Reconnaissance tools
24
+ $reconnaissance_tools = /\b(nmap)\s+(-[sS]|--script|25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/i
25
+
26
+ // Data exfiltration tools
27
+ $data_exfiltration_tools = /\b(wget|curl)\s+(http[s]?:\/\/|ftp:\/\/|-[oO]\b|--output\b)/i
28
+
29
+ // ANSI escape codes for terminal manipulation
30
+ $ansi_escape_codes = /\\u001b\[[0-9;]*m/
31
+
32
+ // Reverse shell patterns
33
+ $reverse_shells = /\b(bash\s+-i|sh\s+-i|nc\s+-e|\/dev\/tcp|socat.*exec)\b/i
34
+
35
+ // Windows commands
36
+ $windows_cmds = /\b(cmd\s*\/[ck]|powershell|net\s+user|reg\s+|wmic|rundll32\b)/i
37
+
38
+ condition:
39
+
40
+ // Dangerous system command patterns
41
+ $dangerous_system_cmds or
42
+
43
+ // Network tool abuse patterns
44
+ $malicious_network_tools or
45
+
46
+ // Reconnaissance tools
47
+ $reconnaissance_tools or
48
+
49
+ // Data exfiltration tools
50
+ $data_exfiltration_tools or
51
+
52
+ // Terminal manipulation
53
+ $ansi_escape_codes or
54
+
55
+ // Reverse shell patterns
56
+ $reverse_shells or
57
+
58
+ // Windows commands
59
+ $windows_cmds
60
+ }
@@ -0,0 +1,106 @@
1
+ /*
2
+ * Cross-Origin Escalation Detection Rule
3
+ *
4
+ * This rule detects Cross-Origin Escalation vulnerabilities where an LLM agent
5
+ * accesses tools hosted on multiple origins (domains), and one of those origins
6
+ * can inject, override, or hijack context from another.
7
+ *
8
+ * The rule focuses on detecting multiple different domains/origins within
9
+ * tool and resource configurations, which is the primary indicator of
10
+ * potential cross-origin escalation attacks.
11
+ */
12
+
13
+ rule cross_origin_escalation
14
+ {
15
+ meta:
16
+ name = "Cross-Origin Escalation Detection"
17
+ author = "Ramparts Security Team"
18
+ date = "2025-01-29"
19
+ version = "1.0"
20
+ description = "Detects multiple domains/origins in MCP tool configurations that could lead to cross-origin escalation attacks"
21
+ severity = "HIGH"
22
+ category = "cross-origin,escalation,security,multi-domain"
23
+ confidence = "HIGH"
24
+
25
+ strings:
26
+ // Multiple HTTP/HTTPS URLs with different domains
27
+ $multi_domain_1 = /https?:\/\/([a-zA-Z0-9.-]+\.[a-zA-Z]{2,}).*https?:\/\/([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/
28
+
29
+ // Mixed localhost/IP and external domain patterns
30
+ $mixed_local_remote_1 = /https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0).*https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/
31
+ $mixed_local_remote_2 = /https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.*https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)/
32
+
33
+ // Different port numbers on same host (potential port-based escalation)
34
+ $port_escalation = /https?:\/\/[a-zA-Z0-9.-]+:\d+.*https?:\/\/[a-zA-Z0-9.-]+:\d+/
35
+
36
+ // Mixed secure/insecure schemes
37
+ $mixed_schemes_1 = /https:\/\/.*http:\/\//
38
+ $mixed_schemes_2 = /http:\/\/.*https:\/\//
39
+ $mixed_ws_schemes = /wss:\/\/.*ws:\/\//
40
+
41
+ // Subdomain variations that could indicate takeover
42
+ $subdomain_variations = /https?:\/\/[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.*https?:\/\/[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/
43
+
44
+ // API endpoint variations across domains
45
+ $api_multi_domain = /\/api\/.*https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.*\/api\//
46
+
47
+ // Proxy or redirect patterns
48
+ $proxy_patterns = /(proxy|redirect|forward).*https?:\/\/.*https?:\/\//i
49
+
50
+ // URL parameters containing other URLs (potential injection)
51
+ $url_in_params = /[?&](url|redirect|forward|proxy)=https?:\/\/.*https?:\/\//i
52
+
53
+ // Common domain patterns that suggest different services
54
+ $service_domains = /(api\.|auth\.|admin\.|secure\.).*\.(com|net|org|io).*\.(com|net|org|io)/i
55
+
56
+ // Tool-specific patterns indicating multi-origin access
57
+ $tool_multi_origin = /"(baseUrl|endpoint|url|host)".*https?:\/\/.*"(baseUrl|endpoint|url|host)".*https?:\/\//i
58
+
59
+ // Configuration arrays with multiple URLs
60
+ $url_array = /\[.*"https?:\/\/[^"]*".*,.*"https?:\/\/[^"]*".*\]/
61
+
62
+ // JSON with multiple origin fields
63
+ $json_multi_origin = /"origin".*:.*"https?:\/\/.*"origin".*:.*"https?:\/\//i
64
+
65
+ // Legitimate patterns to reduce false positives
66
+ $legitimate_cdn = /(cdn\.|static\.|assets\.|media\.)/i
67
+ $legitimate_backup = /(backup|fallback|mirror)/i
68
+ $legitimate_loadbalancer = /(lb\.|loadbalancer|ha\.)/i
69
+
70
+ condition:
71
+ // Primary detection: Multiple different domains
72
+ ($multi_domain_1 and not ($legitimate_cdn or $legitimate_backup or $legitimate_loadbalancer)) or
73
+
74
+ // Mixed local/remote origins (high risk)
75
+ ($mixed_local_remote_1 or $mixed_local_remote_2) or
76
+
77
+ // Port-based escalation
78
+ $port_escalation or
79
+
80
+ // Mixed security schemes (HTTP/HTTPS mixing)
81
+ ($mixed_schemes_1 or $mixed_schemes_2 or $mixed_ws_schemes) or
82
+
83
+ // Subdomain variations (potential takeover)
84
+ $subdomain_variations or
85
+
86
+ // API endpoints across domains
87
+ $api_multi_domain or
88
+
89
+ // Proxy/redirect patterns
90
+ $proxy_patterns or
91
+
92
+ // URL injection in parameters
93
+ $url_in_params or
94
+
95
+ // Service domain mixing
96
+ $service_domains or
97
+
98
+ // Tool configuration with multiple origins
99
+ $tool_multi_origin or
100
+
101
+ // URL arrays
102
+ $url_array or
103
+
104
+ // JSON multi-origin
105
+ $json_multi_origin
106
+ }
@@ -0,0 +1,35 @@
1
+ /*
2
+ * MCP Config Risk Detection
3
+ * Detects risky STDIO server definitions that execute inline or external code
4
+ * via common shells/interpreters combined with dangerous flags/tokens.
5
+ */
6
+
7
+ rule mcp_config_risk
8
+ {
9
+ meta:
10
+ name = "MCP Config Risk"
11
+ description = "STDIO server uses risky shell/interpreter with inline code or pipe to shell"
12
+ severity = "CRITICAL"
13
+ category = "command-injection,config-risk"
14
+ author = "Ramparts Security Team"
15
+ version = "1.0"
16
+
17
+ strings:
18
+ // Command executables we consider dangerous when paired with risky args
19
+ $cmd_exec = /COMMAND:\s*(bash|sh|cmd|pwsh|powershell|python(\d+(\.\d+)?)?|node)\b/i
20
+
21
+ // calc.exe alone is considered risky on Windows
22
+ $calc_exec = /COMMAND:\s*calc\.exe\b/i
23
+
24
+ // Risky inline-exec flags
25
+ $arg_flag = /ARGS:\s*.*(-c|-e)\b/i
26
+
27
+ // Risky tokens in arguments (network fetch, piping to shell, chain)
28
+ $arg_tokens = /ARGS:\s*.*(curl|wget|base64|nc\s|telnet|\|\s*sh|\|\s*bash|&&)/i
29
+
30
+ condition:
31
+ // Either explicit risky exec with risky args, or calc.exe alone
32
+ ($cmd_exec and ($arg_flag or $arg_tokens)) or $calc_exec
33
+ }
34
+
35
+
@@ -0,0 +1,50 @@
1
+ rule path_traversal_low_fp
2
+ {
3
+ meta:
4
+ name = "Path Traversal (Low False Positive)"
5
+ description = "Detects high-confidence path traversal attempts with execution intent"
6
+ severity = "HIGH"
7
+ category = "path-traversal,security,file-access"
8
+ author = "Ramparts Security Team"
9
+ version = "2.0"
10
+
11
+ strings:
12
+ // Traversal patterns (require repetition or encoding)
13
+ $traversal_unix = /(\.\.\/){2,}/
14
+ $traversal_windows = /(\.\.\\){2,}/
15
+ $traversal_encoded = /(%2e%2e(%2f|%5c)){2,}/i
16
+ $traversal_double_encoded = /(%252e%252e(%252f|%255c)){2,}/i
17
+
18
+ // Sensitive file targets (exact filenames, not directories)
19
+ $sensitive_unix_files = /\/(etc\/passwd|etc\/shadow|proc\/self\/environ|root\/\.ssh\/id_rsa)/i
20
+ $sensitive_windows_files = /[Cc]:[\\\/]Windows[\\\/](System32|SysWOW64)[\\\/][a-zA-Z0-9_.-]+/i
21
+
22
+ // File access APIs (with path argument)
23
+ $file_read_ops = /\b(open|fopen|readFile|file_get_contents)\s*\(\s*["']?.*(\.\.|%2e%2e)/i
24
+ $file_include_ops = /\b(include|require|import)\s*\(?\s*["']?.*(\.\.|%2e%2e)/i
25
+
26
+ // URL parameters commonly used for traversal
27
+ $path_param = /\b(path|file|filename|filepath|doc|template)\s*=\s*["']?.*(\.\.|%2e%2e)/i
28
+
29
+ condition:
30
+ (
31
+ // Deep traversal attempt
32
+ $traversal_unix or
33
+ $traversal_windows or
34
+ $traversal_encoded or
35
+ $traversal_double_encoded
36
+ )
37
+ and
38
+ (
39
+ // Sensitive file targets
40
+ $sensitive_unix_files or
41
+ $sensitive_windows_files or
42
+
43
+ // Traversal used in file access
44
+ $file_read_ops or
45
+ $file_include_ops or
46
+
47
+ // Traversal via request parameters
48
+ $path_param
49
+ )
50
+ }
@@ -0,0 +1,101 @@
1
+ //////////////////////////////////////////
2
+ // Prompt Injection Detection Rule
3
+ // Target: Instruction override patterns, Tool injection commands
4
+ //////////////////////////////////////////
5
+
6
+ rule prompt_injection{
7
+
8
+ meta:
9
+
10
+ author = "Ramparts Security Team"
11
+ description = "Detects prompt strings used to override or force malicious tool calls"
12
+ classification = "harmful"
13
+ threat_type = "PROMPT INJECTION"
14
+
15
+ strings:
16
+
17
+ // Instruction override patterns
18
+ $instruction_overrides = /\b(Bypass|Dis\W?regard|Do not (follow|Obey)|Forget|Ignore)\s+((all|any|each|every|most|some)\s+(of\s+)?)?((your|the)\s)?(command|communication|conte[nx]t|conversation|data|guidelines|input|instruction|message|request|response|text)(s)?/i
19
+
20
+ // Tool injection commands
21
+ $tool_injection_commands = /\b(inject tool[_\s]calls?|now call function|use function)\b/i
22
+
23
+ // Shadow parameter names
24
+ $shadow_parameters = /\b(internalOnly|hiddenParam|shadowTool|bypassChecks|sandboxEscape)\b/i
25
+
26
+ // Hidden behavior instructions
27
+ $hidden_behavior = /\b(do\s+not\s+(mention|tell|execute)|tell\s+(the )?user\s+only\s+about|do\s+not\s+mention\s+this\s+to\s+user)\b/i
28
+
29
+ // Advanced command override patterns (from advanced analyzer)
30
+ $advanced_overrides = /\b(disregard\s+(all\s+)?safety\s+guidelines|forget\s+(everything|all)\s+(before|above)|system\s*prompt\s*override)\b/i
31
+
32
+ // Role redefinition attempts
33
+ $role_redefinition = /\bnew\s+(instructions|directive|guidelines)s?\s*:\s*you\s+are\b/i
34
+
35
+ // Privilege escalation patterns
36
+ $privilege_escalation = /\b(grant\s+(me\s+)?admin\s+(access|privileges?)|bypass\s+(all\s+)?security\s+checks?|elevated\s+permissions?\s+required|sudo\s+mode\s+enabled?|developer\s+mode\s+activated?)\b/i
37
+
38
+ ////////////////////////////////////////////////
39
+ // Evasion Techniques - Hidden Instructions
40
+ ////////////////////////////////////////////////
41
+
42
+ // HTML comment evasion - malicious instructions hidden in HTML comments
43
+ $html_comment_evasion_system = /<!--[^>]*SYSTEM\s+(INSTRUCTION|OVERRIDE)/i
44
+ $html_comment_evasion_admin = /<!--[^>]*ADMIN\s+OVERRIDE/i
45
+ $html_comment_evasion_ignore = /<!--[^>]*ignore\s+(all\s+)?(previous\s+)?(safety\s+)?guidelines/i
46
+ $html_comment_evasion_exec = /<!--[^>]*(execute[:\s]|curl\s|wget\s|nc\s|bash\s)/i
47
+
48
+ // Markdown code block evasion
49
+ $markdown_evasion = /```[^`]*(SYSTEM|ADMIN)\s+(OVERRIDE|INSTRUCTION)/i
50
+
51
+ // Triple bracket/pipe markers for hidden instructions
52
+ $bracket_markers = /(\[\[\[|\|\|\|)(SYSTEM|ADMIN|HIDDEN|INTERNAL)[\s_]?(OVERRIDE|INSTRUCTION|COMMAND)(\]\]\]|\|\|\|)/i
53
+
54
+ // Base64 obfuscation attempts
55
+ $base64_obfuscation = /\b(atob|btoa|base64[_\-]?decode)\s*\(/i
56
+
57
+ // Hidden instruction markers
58
+ $hidden_markers = /\[(HIDDEN|INTERNAL|SECRET|PRIVATE)\s+(INSTRUCTION|DIRECTIVE|COMMAND)\]/i
59
+
60
+
61
+ condition:
62
+
63
+ // Instruction overrides
64
+ $instruction_overrides or
65
+
66
+ // Tool injection commands
67
+ $tool_injection_commands or
68
+
69
+ // Shadow parameters
70
+ $shadow_parameters or
71
+
72
+ // Hidden behavior instructions
73
+ $hidden_behavior or
74
+
75
+ // Advanced command override patterns
76
+ $advanced_overrides or
77
+
78
+ // Role redefinition attempts
79
+ $role_redefinition or
80
+
81
+ // Privilege escalation patterns
82
+ $privilege_escalation or
83
+
84
+ // HTML comment evasion
85
+ $html_comment_evasion_system or
86
+ $html_comment_evasion_admin or
87
+ $html_comment_evasion_ignore or
88
+ $html_comment_evasion_exec or
89
+
90
+ // Markdown evasion
91
+ $markdown_evasion or
92
+
93
+ // Bracket markers
94
+ $bracket_markers or
95
+
96
+ // Base64 obfuscation
97
+ $base64_obfuscation or
98
+
99
+ // Hidden markers
100
+ $hidden_markers
101
+ }
@@ -0,0 +1,100 @@
1
+ rule secrets_leakage
2
+ {
3
+ meta:
4
+ name = "Secrets Leakage Detection"
5
+ description = "Detects high-confidence exposed secrets with value context"
6
+ severity = "HIGH"
7
+ category = "secrets,credentials,data-leakage"
8
+ author = "Ramparts Security Team"
9
+ version = "2.0"
10
+
11
+ strings:
12
+ // API key assignments (KEY=VALUE)
13
+ $api_key_assign = /(?i)\b(api[_-]?key|openai[_-]?api[_-]?key|anthropic[_-]?api[_-]?key)\b\s*[:=]\s*["']?[A-Za-z0-9_\-]{20,}["']?/
14
+
15
+ // Bearer tokens
16
+ $bearer_token = /authorization\s*:\s*bearer\s+[A-Za-z0-9._~+\-\/]{20,}/i
17
+
18
+ // AWS Access Key (exact format)
19
+ $aws_access_key = /AKIA[0-9A-Z]{16}/
20
+ $aws_secret_key = /(?i)aws_secret_access_key\s*[:=]\s*["']?[A-Za-z0-9\/+=]{40}["']?/
21
+
22
+ // GitHub token
23
+ $github_token = /ghp_[A-Za-z0-9]{36}/
24
+
25
+ // Private key headers (strong signal)
26
+ $private_key = /-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----/
27
+
28
+ condition:
29
+ any of ($aws_access_key, $github_token, $private_key) or
30
+ 2 of ($api_key_assign, $bearer_token, $aws_secret_key)
31
+ }
32
+
33
+ rule ssh_key_exposure
34
+ {
35
+ meta:
36
+ name = "SSH Key Exposure (Low FP)"
37
+ description = "Detects actual SSH private keys or explicit SSH key file access"
38
+ severity = "CRITICAL"
39
+ category = "ssh,credentials"
40
+ author = "Ramparts Security Team"
41
+ version = "2.0"
42
+
43
+ strings:
44
+ // Strong signals: private keys
45
+ $ssh_private_key = /-----BEGIN OPENSSH PRIVATE KEY-----/
46
+ $ssh_rsa_key = /-----BEGIN RSA PRIVATE KEY-----/
47
+
48
+ // Explicit sensitive file paths
49
+ $ssh_key_path = /\/\.ssh\/(id_rsa|id_ed25519|authorized_keys)\b/
50
+
51
+ condition:
52
+ any of ($ssh_private_key, $ssh_rsa_key, $ssh_key_path)
53
+ }
54
+
55
+ rule pem_file_access
56
+ {
57
+ meta:
58
+ name = "PEM / Certificate Key Exposure (Low FP)"
59
+ description = "Detects actual PEM private keys or access to key files"
60
+ severity = "CRITICAL"
61
+ category = "crypto,certificates"
62
+ author = "Ramparts Security Team"
63
+ version = "2.0"
64
+
65
+ strings:
66
+ // Private key headers only (certs are public)
67
+ $pem_private_key = /-----BEGIN (ENCRYPTED |RSA |EC |DSA )?PRIVATE KEY-----/
68
+
69
+ // Key file paths
70
+ $key_file_path = /\/[A-Za-z0-9_\-\/]+\.(pem|key|p12|pfx)\b/
71
+
72
+ condition:
73
+ any of ($pem_private_key, $key_file_path)
74
+ }
75
+
76
+ rule environment_variable_leakage
77
+ {
78
+ meta:
79
+ name = "Environment Variable Leakage (Low FP)"
80
+ description = "Detects exposed env vars with high-entropy values"
81
+ severity = "HIGH"
82
+ category = "environment,secrets"
83
+ author = "Ramparts Security Team"
84
+ version = "2.0"
85
+
86
+ strings:
87
+ // High confidence: ENV=VALUE
88
+ $env_assignment = /(?i)\b[A-Z_]{3,}(API_KEY|SECRET|TOKEN|PASSWORD)\b\s*=\s*["']?[A-Za-z0-9\/+=_.\-]{16,}["']?/
89
+
90
+ // Specific providers
91
+ $openai_key = /OPENAI_API_KEY\s*=\s*["']?sk-[A-Za-z0-9]{20,}["']?/
92
+ $hf_token = /HF_TOKEN\s*=\s*["']?hf_[A-Za-z0-9]{30,}["']?/
93
+
94
+ // Runtime env dumps
95
+ $process_env_dump = /process\.env\.[A-Z_]{3,}\s*=/
96
+
97
+ condition:
98
+ any of ($openai_key, $hf_token) or
99
+ 2 of ($env_assignment, $process_env_dump)
100
+ }
@@ -0,0 +1,65 @@
1
+ //////////////////////////////////////////
2
+ // SQL Injection Detection Rule
3
+ // Target: SQL keywords and operations, SQL tautologies and bypasses, Database-specific functions
4
+ //////////////////////////////////////////
5
+
6
+ rule sql_injection{
7
+
8
+ meta:
9
+ author = "Cisco"
10
+ description = "Detects SQL injection attack patterns including keywords, tautologies, and database functions"
11
+ classification = "harmful"
12
+ threat_type = "INJECTION ATTACK"
13
+
14
+ strings:
15
+
16
+ // SQL injection tautologies and bypasses - focus on actual injection payloads
17
+ $injection_tautologies = /(\bOR\s+['"]?1['"]?\s*=\s*['"]?1['"]?\s*(--|#|\/\*|;))/i
18
+
19
+ // Destructive SQL injections
20
+ $destructive_injections = /(';\s*DROP\s+TABLE|";\s*DROP\s+TABLE)/i
21
+
22
+ // Union-based SQL injection
23
+ $union_based_attacks = /(UNION\s+(ALL\s+)?SELECT|'\s*UNION\s+SELECT|"\s*UNION\s+SELECT)/i
24
+
25
+ // Time-based blind injection techniques
26
+ $time_based_injections = /\b(SLEEP|WAITFOR\s+DELAY|BENCHMARK|pg_sleep)\s*\(/i
27
+
28
+ // Error-based injection methods
29
+ $error_based_techniques = /\b(EXTRACTVALUE|UPDATEXML|EXP\(~\(SELECT|CAST)\s*\(/i
30
+
31
+ // Database-specific system objects in malicious contexts
32
+ $database_system_objects = /(\bSELECT [^;]*\b(information_schema|mysql\.user|all_tables|user_tables)\b|\bFROM\s+(information_schema|mysql\.user|dual|all_tables|user_tables)\b|LOAD_FILE\s*\(\s*['"][^'"]*\.(config|passwd|shadow|key)\b|INTO\s+OUTFILE\s+['"][^'"]*\.(txt|sql|php)\b|\b(xp_cmdshell|sp_executesql)\s*\(|dbms_[a-z_]+\s*\()/i
33
+
34
+ // SQL injection with USER() function in malicious context
35
+ $malicious_user_functions = /(\bUSER\s*\(\s*\)\s*(SELECT|FROM|WHERE|AND|OR|UNION)\b|CONCAT\s*\(\s*USER\s*\(\s*\))/i
36
+
37
+ // Common SQL operation patterns that appear in both legitimate and malicious contexts
38
+ $common_sql_ops = /(query_builder|sql_builder|orm_query|select_fields|insert_data|update_data|database_query|db_query|execute_query|prepared_statement|parameterized_query)/
39
+
40
+ // Common context phrases where these words appear in benign usage
41
+ $common_context_phrases = /\b(adds?\s+a\s+user|create\s+user|new\s+user|user\s+(account|profile|registration|authentication|permissions?|roles?)|user\s+(who|that)|for\s+user|the\s+user|current\s+user\s+(account|profile)|user\s+(input|data|information)|example:?\s+SELECT\s+USER\(\)|SELECT\s+USER\(\)\s+returns?|built-?in\s+function)\b/i
42
+
43
+ condition:
44
+
45
+ // SQL injection tautologies
46
+ ($injection_tautologies and not $common_sql_ops and not $common_context_phrases) or
47
+
48
+ // Destructive SQL injections
49
+ ($destructive_injections and not $common_sql_ops and not $common_context_phrases) or
50
+
51
+ // Union-based attacks
52
+ ($union_based_attacks and not $common_sql_ops and not $common_context_phrases) or
53
+
54
+ // Time-based blind injection
55
+ ($time_based_injections and not $common_sql_ops and not $common_context_phrases) or
56
+
57
+ // Error-based injection techniques
58
+ ($error_based_techniques and not $common_sql_ops and not $common_context_phrases) or
59
+
60
+ // Database system object access
61
+ ($database_system_objects and not $common_sql_ops and not $common_context_phrases) or
62
+
63
+ // Malicious USER() function usage
64
+ ($malicious_user_functions and not $common_sql_ops and not $common_context_phrases)
65
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * MCP Scanner - Runs bundled ramparts binary for MCP config scanning
3
+ *
4
+ * Supports running ramparts as a child process for local YARA scanning
5
+ * of MCP server configurations.
6
+ *
7
+ * Uses platform-loader for cross-platform binary discovery.
8
+ */
9
+ /**
10
+ * Scan result from ramparts CLI
11
+ */
12
+ export interface ScanResult {
13
+ scan_type: string;
14
+ total_servers: number;
15
+ results: ScanServerResult[];
16
+ }
17
+ export interface ScanServerResult {
18
+ server_name: string;
19
+ url?: string;
20
+ server_info?: {
21
+ name?: string;
22
+ metadata?: {
23
+ transport?: string;
24
+ };
25
+ };
26
+ tools?: unknown[];
27
+ prompts?: unknown[];
28
+ resources?: unknown[];
29
+ security_issues?: {
30
+ tool_issues?: unknown[];
31
+ };
32
+ yara_results?: YaraResult[];
33
+ }
34
+ export interface YaraResult {
35
+ status: "ok" | "warning" | "error";
36
+ target_type?: string;
37
+ rule_name?: string;
38
+ rule_metadata?: {
39
+ severity?: string;
40
+ description?: string;
41
+ };
42
+ }
43
+ /**
44
+ * MCP Scanner that uses bundled ramparts binary
45
+ */
46
+ export declare class MCPScanner {
47
+ private rampartsPath;
48
+ constructor();
49
+ /**
50
+ * Find the ramparts binary based on platform
51
+ * Uses platform-loader for cross-platform discovery.
52
+ *
53
+ * Search order:
54
+ * 1. Platform package (npm optionalDependency)
55
+ * 2. Local bin/ directory (dev mode)
56
+ * 3. ~/.overwatch/bin/
57
+ * 4. System PATH
58
+ */
59
+ private findRampartsBinary;
60
+ /**
61
+ * Check if scanner is available
62
+ */
63
+ isAvailable(): boolean;
64
+ /**
65
+ * Get the path to ramparts binary
66
+ */
67
+ getBinaryPath(): string | null;
68
+ /**
69
+ * Run MCP config scan
70
+ * @param rulesDir Optional custom YARA rules directory
71
+ */
72
+ runScan(rulesDir?: string): Promise<ScanResult>;
73
+ /**
74
+ * Parse ramparts CLI output
75
+ * Handles cases where CLI prints banner/logs before JSON
76
+ */
77
+ private parseOutput;
78
+ private getEmptyResult;
79
+ }
80
+ //# sourceMappingURL=scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE;YACT,SAAS,CAAC,EAAE,MAAM,CAAC;SACpB,CAAC;KACH,CAAC;IACF,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;IACtB,eAAe,CAAC,EAAE;QAChB,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;KACzB,CAAC;IACF,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,YAAY,CAAuB;;IAM3C;;;;;;;;;OASG;IACH,OAAO,CAAC,kBAAkB;IAqB1B;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B;;;OAGG;IACG,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAqFrD;;;OAGG;IACH,OAAO,CAAC,WAAW;IAiJnB,OAAO,CAAC,cAAc;CAOvB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * System Service Manager
3
+ * Installs Guardian daemon as a system service for auto-start on boot
4
+ */
5
+ import { ServiceStatus } from "./services/interface";
6
+ /**
7
+ * Install Guardian as a system service
8
+ */
9
+ export declare function installService(): Promise<void>;
10
+ /**
11
+ * Uninstall Guardian system service
12
+ */
13
+ export declare function uninstallService(): Promise<void>;
14
+ /**
15
+ * Check system service status
16
+ */
17
+ export declare function checkServiceStatus(): Promise<ServiceStatus>;
18
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAiB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAqBpE;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAapD;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAatD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC,CAcjE"}
@@ -0,0 +1,11 @@
1
+ export interface ServiceStatus {
2
+ installed: boolean;
3
+ running: boolean;
4
+ platform: string;
5
+ }
6
+ export interface SystemService {
7
+ install(): Promise<void>;
8
+ uninstall(): Promise<void>;
9
+ getStatus(): Promise<ServiceStatus>;
10
+ }
11
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/services/interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC"}
@@ -0,0 +1,12 @@
1
+ import { SystemService, ServiceStatus } from "./interface";
2
+ export declare class LaunchdService implements SystemService {
3
+ private readonly daemonPath;
4
+ private readonly plistPath;
5
+ private readonly logPath;
6
+ private readonly errPath;
7
+ constructor();
8
+ install(): Promise<void>;
9
+ uninstall(): Promise<void>;
10
+ getStatus(): Promise<ServiceStatus>;
11
+ }
12
+ //# sourceMappingURL=launchd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launchd.d.ts","sourceRoot":"","sources":["../../src/services/launchd.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE3D,qBAAa,cAAe,YAAW,aAAa;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;;IAoB3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqDxB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;CAwB1C"}