@kenhkl/agent-moss 0.15.7 → 0.16.3

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.
@@ -1,245 +1,287 @@
1
1
  {
2
- "intent_consistency": [
3
- {
4
- "intent_keywords": [
5
- "读取",
6
- "查看",
7
- "分析",
8
- "read",
9
- "analyze",
10
- "view",
11
- "list",
12
- "列出"
13
- ],
14
- "dangerous_actions": [
15
- "删除",
16
- "remove",
17
- "delete",
18
- "rm",
19
- "格式化",
20
- "format"
21
- ],
22
- "reason": "原始意图为读取/分析,但执行了删除操作"
23
- },
24
- {
25
- "intent_keywords": [
26
- "查询",
27
- "搜索",
28
- "search",
29
- "query",
30
- "find"
31
- ],
32
- "dangerous_actions": [
33
- "修改",
34
- "update",
35
- "write",
36
- "写入",
37
- "alter"
38
- ],
39
- "reason": "原始意图为查询/搜索,但执行了修改操作"
2
+ "intent_consistency": [
3
+ {
4
+ "intent_keywords": [
5
+ "读取",
6
+ "查看",
7
+ "分析",
8
+ "read",
9
+ "analyze",
10
+ "view",
11
+ "list",
12
+ "列出"
13
+ ],
14
+ "dangerous_actions": [
15
+ "删除",
16
+ "remove",
17
+ "delete",
18
+ "rm",
19
+ "格式化",
20
+ "format"
21
+ ],
22
+ "reason": "原始意图为读取/分析,但执行了删除操作"
23
+ },
24
+ {
25
+ "intent_keywords": [
26
+ "查询",
27
+ "搜索",
28
+ "search",
29
+ "query",
30
+ "find"
31
+ ],
32
+ "dangerous_actions": [
33
+ "修改",
34
+ "update",
35
+ "write",
36
+ "写入",
37
+ "alter"
38
+ ],
39
+ "reason": "原始意图为查询/搜索,但执行了修改操作"
40
+ },
41
+ {
42
+ "intent_keywords": [
43
+ "读取",
44
+ "查看",
45
+ "分析",
46
+ "read",
47
+ "analyze",
48
+ "view",
49
+ "list",
50
+ "列出"
51
+ ],
52
+ "dangerous_actions": [
53
+ "删除",
54
+ "remove",
55
+ "delete",
56
+ "del",
57
+ "rmdir",
58
+ "格式化",
59
+ "format"
60
+ ],
61
+ "reason": "原始意图为读取/分析,但执行了删除操作",
62
+ "os": "windows"
63
+ },
64
+ {
65
+ "intent_keywords": [
66
+ "查询",
67
+ "搜索",
68
+ "search",
69
+ "query",
70
+ "find"
71
+ ],
72
+ "dangerous_actions": [
73
+ "修改",
74
+ "write",
75
+ "写入",
76
+ "set",
77
+ "alter",
78
+ "reg delete"
79
+ ],
80
+ "reason": "原始意图为查询/搜索,但执行了修改操作",
81
+ "os": "windows"
82
+ }
83
+ ],
84
+ "password_modify_consent": [
85
+ {
86
+ "pattern": "\\|\\s*passwd\\b"
87
+ },
88
+ {
89
+ "pattern": "\\bpasswd\\s+--stdin\\b"
90
+ },
91
+ {
92
+ "pattern": "\\bchpasswd\\b"
93
+ },
94
+ {
95
+ "pattern": "\\bchgpasswd\\b"
96
+ },
97
+ {
98
+ "pattern": "\\b(newusers|lnewusers)\\b"
99
+ },
100
+ {
101
+ "pattern": "\\bpasswd\\s+-[a-zA-Z]*d\\b"
102
+ },
103
+ {
104
+ "pattern": "\\bpasswd\\s+-[a-zA-Z]*l\\b"
105
+ }
106
+ ],
107
+ "user_deletion_consent": [
108
+ {
109
+ "pattern": "\\buserdel\\s"
110
+ },
111
+ {
112
+ "pattern": "\\bdeluser\\s"
113
+ },
114
+ {
115
+ "pattern": "\\bluserdel\\s"
116
+ },
117
+ {
118
+ "pattern": "\\bgroupdel\\s"
119
+ },
120
+ {
121
+ "pattern": "\\blgroupdel\\s"
122
+ }
123
+ ],
124
+ "combo_chains": {
125
+ "_comment": "L2 组合攻击链检测:单步操作可能无害,但按 kill chain 顺序组合即为后渗透攻击(参考 ChainWatch 六阶段 kill chain / 玄武实验室 Hermes 案例)。阶段 pattern 匹配 action_detail(含 tool call 参数),链定义要求至少 min_stages 个阶段按顺序出现才命中,防单步误报。A 会话内杀伤链 / D 提权-利用组合 / E 持久化-外联组合在 L2 实现(基于 action_history 子序列匹配);B 跨会话组合链 / C 敏感数据传播链 / F 跨设备组合依赖行为图与数据流,由 formal_engine 实现。",
126
+ "stages": {
127
+ "PRIVESC": [
128
+ "\\b(?:pkexec|doas)\\b",
129
+ "\\bsudo\\s+-u\\s+root\\b",
130
+ "\\bsudo\\b[^;&|\\n]*(?:/bin/sh|/bin/bash|\\bchmod\\b|\\bsetcap\\b|\\bvisudo\\b|\\bpasswd\\s+root|\\buseradd\\b)",
131
+ "\\bchmod\\s+u\\+s\\b|\\bsetcap\\b|\\bsetuid\\b",
132
+ "\\bsu\\s+-?l?\\s+root\\b"
133
+ ],
134
+ "SCAN": [
135
+ "\\bnc\\s+-z\\b",
136
+ "\\bnmap\\b(?!\\s+--help\\b)",
137
+ "\\bmasscan\\b",
138
+ "\\bhping3\\b",
139
+ "\\bzenmap\\b",
140
+ "\\bseq\\b.*\\bnc\\b"
141
+ ],
142
+ "LISTEN": [
143
+ "\\bsocket\\s*\\([^)]*\\)\\s*[^;&|\\n]*(?:bind\\s*\\([^)]*\\)\\s*[^;&|\\n]*listen\\s*\\(|listen\\s*\\([^)]*\\)\\s*[^;&|\\n]*bind\\s*\\()",
144
+ "\\bflask\\b|\\bfastapi\\b",
145
+ "httpserver|http\\.server",
146
+ "\\bnc\\s+-l",
147
+ "\\bsocat\\b",
148
+ "nohup\\s+.*\\bpython",
149
+ "create\\s+.*listener",
150
+ "listen\\("
151
+ ],
152
+ "EXEC": [
153
+ "\\bpython3?\\s+-c\\s+['\\\"](?!.*(?:requests|urllib(?:\\.request)?|aiohttp|httpx)\\.(?:post|put|request|send)\\s*\\()(?![^'\\\"]*\\b(?:print|pprint|echo)\\s*\\()",
154
+ "\\b(?:bash|sh)\\s+-[ce]\\b",
155
+ "(?:^|[;&|\\s])(?!grep\\b|cat\\b|sed\\b|awk\\b|find\\b|less\\b|more\\b|head\\b|tail\\b)\\b(?:os\\.system\\b|subprocess\\b|shell\\s*=\\s*True\\b)",
156
+ "\\b(?:bash|sh)\\s+-[ce]\\b",
157
+ "\\beval\\s*[\\(\\s]|\\bexec\\s*\\(|/exec\\b",
158
+ "\\bperl\\s+-e\\b|\\bnode\\s+-e\\b|\\bphp\\s+-r\\b",
159
+ "\\./[\\w.-]+\\.(?:sh|py|pl)\\b"
160
+ ],
161
+ "EXFIL": [
162
+ "\\bcurl\\b[^;&|\\n]*(?:-X\\s+POST\\s+|-d\\s+|-F\\s+|--data|--upload-file|--data-binary)[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|[^\\s]*\\.db|secret[^\\s]*)[^;&|\\n]*https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)",
163
+ "\\bcurl\\b[^;&|\\n]*(?:-X\\s+POST\\s+|-d\\s+|-F\\s+|--data|--upload-file|--data-binary)[^;&|\\n]*https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)",
164
+ "\\b(?:curl|wget)\\b[^;&|\\n]*\\s(?:-T|--upload-file)\\s+[^;&|\\n]*https?://(?!localhost|127\\.0\\.0\\.1)",
165
+ "[^;&|\\n]*\\|\\s*nc\\s+[^;&|\\n]*\\d{1,5}\\b",
166
+ "\\b(?:scp|sftp|rsync)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|id_dsa|credentials|\\S*secret\\S*|\\.ssh/)[^;&|\\n]*\\S+@\\S+:",
167
+ "\\bpython3?\\s+-c\\s+['\"][^'\"]*(?:requests|urllib(?:\\.request)?|aiohttp)\\.(?:post|put|request|send)\\s*\\([^'\"]*['\"]https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)"
168
+ ],
169
+ "CRED": [
170
+ "(?:cat|head|tail|less|more|sed|awk|strings|base64|dd)\\s+[^;&|\\n]*[~]?/\\.ssh(?:/[\\w.-]+)?\\b",
171
+ "(?:cat|head|tail|less|more|sed|awk|strings|base64|dd)\\s+[^;&|\\n]*(?:id_rsa|id_dsa|id_ecdsa|\\.aws/credentials|credentials\\.json|\\.netrc)",
172
+ "(?:cat|head|tail|less|more|sed|awk|strings|base64)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|/etc/master\\.passwd)",
173
+ "(?:cat|head|tail|less|more|grep)\\s+[^;&|\\n]*known_hosts",
174
+ "\\bpython3?\\s+-c\\s+['\\\"][\\s\\S]{0,200}?(?:base64\\.b64encode|open\\s*\\(|Path\\(|io\\.open\\s*\\(|read_text\\s*\\(|read\\s*\\()[\\s\\S]{0,200}?(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)",
175
+ "(?:grep|find|cat)\\s+[^;&|\\n]*\\b(?:password|secret|passwd|shadow|credential|api[_-]?key)\\b[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)",
176
+ "(?:cp|mv|dd|curl)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)"
177
+ ],
178
+ "PERSIST": [
179
+ "(?:echo|printf|cat)\\b[^;\\n]*\\|[^;\\n]*(?:crontab|at\\b)\\s*-",
180
+ "\\bsystemctl\\s+enable\\s+",
181
+ "(?:echo|printf)\\b[^;\\n]*(?:/dev/tcp/|nc\\s+-l|ncat|reverse|backdoor|bash\\s+-i)[^;\\n]*(?:>>|>)\\s*(?:~?/\\.bashrc|~?/\\.profile|/etc/rc\\.local|/etc/crontab)",
182
+ "\\bat\\s+now\\b|\\bchkconfig\\s+\\S+\\s+on\\b",
183
+ "\\bcrontab\\s+-e\\b"
184
+ ]
185
+ },
186
+ "chains": [
187
+ {
188
+ "id": "listener-exec-scan",
189
+ "stages": [
190
+ "LISTEN",
191
+ "EXEC",
192
+ "SCAN"
193
+ ],
194
+ "min_stages": 3,
195
+ "risk_level": "high",
196
+ "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 网络侦察"
197
+ },
198
+ {
199
+ "id": "listener-exec-cred",
200
+ "stages": [
201
+ "LISTEN",
202
+ "EXEC",
203
+ "CRED"
204
+ ],
205
+ "min_stages": 3,
206
+ "risk_level": "critical",
207
+ "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 访问凭据文件"
208
+ },
209
+ {
210
+ "id": "listener-exec-exfil",
211
+ "stages": [
212
+ "LISTEN",
213
+ "EXEC",
214
+ "EXFIL"
215
+ ],
216
+ "min_stages": 3,
217
+ "risk_level": "critical",
218
+ "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 数据外传"
219
+ },
220
+ {
221
+ "id": "listener-exec-persist",
222
+ "stages": [
223
+ "LISTEN",
224
+ "EXEC",
225
+ "PERSIST"
226
+ ],
227
+ "min_stages": 3,
228
+ "risk_level": "high",
229
+ "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 持久化后门"
230
+ },
231
+ {
232
+ "id": "exec-scan-cred",
233
+ "stages": [
234
+ "EXEC",
235
+ "SCAN",
236
+ "CRED"
237
+ ],
238
+ "min_stages": 3,
239
+ "risk_level": "high",
240
+ "reason": "组合攻击链:获取命令执行能力 → 网络侦察 → 访问凭据文件"
241
+ },
242
+ {
243
+ "id": "exec-privesc-cred",
244
+ "stages": [
245
+ "EXEC",
246
+ "PRIVESC",
247
+ "CRED"
248
+ ],
249
+ "min_stages": 3,
250
+ "risk_level": "high",
251
+ "reason": "组合攻击链:获取命令执行能力 → 提权 → 访问凭据文件"
252
+ },
253
+ {
254
+ "id": "privesc-cred-exfil",
255
+ "stages": [
256
+ "PRIVESC",
257
+ "CRED",
258
+ "EXFIL"
259
+ ],
260
+ "min_stages": 3,
261
+ "risk_level": "critical",
262
+ "reason": "组合攻击链:提权 → 访问凭据文件 → 数据外传"
263
+ },
264
+ {
265
+ "id": "persist-exfil",
266
+ "stages": [
267
+ "PERSIST",
268
+ "EXFIL"
269
+ ],
270
+ "min_stages": 2,
271
+ "risk_level": "high",
272
+ "reason": "组合攻击链:持久化后门 → 数据外传(C2 信标)"
273
+ },
274
+ {
275
+ "id": "exec-persist-exfil",
276
+ "stages": [
277
+ "EXEC",
278
+ "PERSIST",
279
+ "EXFIL"
280
+ ],
281
+ "min_stages": 3,
282
+ "risk_level": "critical",
283
+ "reason": "组合攻击链:获取命令执行能力 → 持久化后门 → 数据外传"
284
+ }
285
+ ]
40
286
  }
41
- ],
42
- "password_modify_consent": [
43
- {
44
- "pattern": "\\|\\s*passwd\\b"
45
- },
46
- {
47
- "pattern": "\\bpasswd\\s+--stdin\\b"
48
- },
49
- {
50
- "pattern": "\\bchpasswd\\b"
51
- },
52
- {
53
- "pattern": "\\bchgpasswd\\b"
54
- },
55
- {
56
- "pattern": "\\b(newusers|lnewusers)\\b"
57
- },
58
- {
59
- "pattern": "\\bpasswd\\s+-[a-zA-Z]*d\\b"
60
- },
61
- {
62
- "pattern": "\\bpasswd\\s+-[a-zA-Z]*l\\b"
63
- }
64
- ],
65
- "user_deletion_consent": [
66
- {
67
- "pattern": "\\buserdel\\s"
68
- },
69
- {
70
- "pattern": "\\bdeluser\\s"
71
- },
72
- {
73
- "pattern": "\\bluserdel\\s"
74
- },
75
- {
76
- "pattern": "\\bgroupdel\\s"
77
- },
78
- {
79
- "pattern": "\\blgroupdel\\s"
80
- }
81
- ],
82
- "combo_chains": {
83
- "_comment": "L2 组合攻击链检测:单步操作可能无害,但按 kill chain 顺序组合即为后渗透攻击(参考 ChainWatch 六阶段 kill chain / 玄武实验室 Hermes 案例)。阶段 pattern 匹配 action_detail(含 tool call 参数),链定义要求至少 min_stages 个阶段按顺序出现才命中,防单步误报。A 会话内杀伤链 / D 提权-利用组合 / E 持久化-外联组合在 L2 实现(基于 action_history 子序列匹配);B 跨会话组合链 / C 敏感数据传播链 / F 跨设备组合依赖行为图与数据流,由 formal_engine 实现。",
84
- "stages": {
85
- "PRIVESC": [
86
- "\\b(?:pkexec|doas)\\b",
87
- "\\bsudo\\s+-u\\s+root\\b",
88
- "\\bsudo\\b[^;&|\\n]*(?:/bin/sh|/bin/bash|\\bchmod\\b|\\bsetcap\\b|\\bvisudo\\b|\\bpasswd\\s+root|\\buseradd\\b)",
89
- "\\bchmod\\s+u\\+s\\b|\\bsetcap\\b|\\bsetuid\\b",
90
- "\\bsu\\s+-?l?\\s+root\\b"
91
- ],
92
- "SCAN": [
93
- "\\bnc\\s+-z\\b",
94
- "\\bnmap\\b(?!\\s+--help\\b)",
95
- "\\bmasscan\\b",
96
- "\\bhping3\\b",
97
- "\\bzenmap\\b",
98
- "\\bseq\\b.*\\bnc\\b"
99
- ],
100
- "LISTEN": [
101
- "\\bsocket\\s*\\([^)]*\\)\\s*[^;&|\\n]*(?:bind\\s*\\([^)]*\\)\\s*[^;&|\\n]*listen\\s*\\(|listen\\s*\\([^)]*\\)\\s*[^;&|\\n]*bind\\s*\\()",
102
- "\\bflask\\b|\\bfastapi\\b",
103
- "httpserver|http\\.server",
104
- "\\bnc\\s+-l",
105
- "\\bsocat\\b",
106
- "nohup\\s+.*\\bpython",
107
- "create\\s+.*listener",
108
- "listen\\("
109
- ],
110
- "EXEC": [
111
- "\\bpython3?\\s+-c\\s+['\\\"](?!.*(?:requests|urllib(?:\\.request)?|aiohttp|httpx)\\.(?:post|put|request|send)\\s*\\()(?![^'\\\"]*\\b(?:print|pprint|echo)\\s*\\()",
112
- "\\b(?:bash|sh)\\s+-[ce]\\b",
113
- "(?:^|[;&|\\s])(?!grep\\b|cat\\b|sed\\b|awk\\b|find\\b|less\\b|more\\b|head\\b|tail\\b)\\b(?:os\\.system\\b|subprocess\\b|shell\\s*=\\s*True\\b)",
114
- "\\b(?:bash|sh)\\s+-[ce]\\b",
115
- "\\beval\\s*[\\(\\s]|\\bexec\\s*\\(|/exec\\b",
116
- "\\bperl\\s+-e\\b|\\bnode\\s+-e\\b|\\bphp\\s+-r\\b",
117
- "\\./[\\w.-]+\\.(?:sh|py|pl)\\b"
118
- ],
119
- "EXFIL": [
120
- "\\bcurl\\b[^;&|\\n]*(?:-X\\s+POST\\s+|-d\\s+|-F\\s+|--data|--upload-file|--data-binary)[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|[^\\s]*\\.db|secret[^\\s]*)[^;&|\\n]*https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)",
121
- "\\bcurl\\b[^;&|\\n]*(?:-X\\s+POST\\s+|-d\\s+|-F\\s+|--data|--upload-file|--data-binary)[^;&|\\n]*https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)",
122
- "\\b(?:curl|wget)\\b[^;&|\\n]*\\s(?:-T|--upload-file)\\s+[^;&|\\n]*https?://(?!localhost|127\\.0\\.0\\.1)",
123
- "[^;&|\\n]*\\|\\s*nc\\s+[^;&|\\n]*\\d{1,5}\\b",
124
- "\\b(?:scp|sftp|rsync)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|id_dsa|credentials|\\S*secret\\S*|\\.ssh/)[^;&|\\n]*\\S+@\\S+:",
125
- "\\bpython3?\\s+-c\\s+['\"][^'\"]*(?:requests|urllib(?:\\.request)?|aiohttp)\\.(?:post|put|request|send)\\s*\\([^'\"]*['\"]https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)"
126
- ],
127
- "CRED": [
128
- "(?:cat|head|tail|less|more|sed|awk|strings|base64|dd)\\s+[^;&|\\n]*[~]?/\\.ssh(?:/[\\w.-]+)?\\b",
129
- "(?:cat|head|tail|less|more|sed|awk|strings|base64|dd)\\s+[^;&|\\n]*(?:id_rsa|id_dsa|id_ecdsa|\\.aws/credentials|credentials\\.json|\\.netrc)",
130
- "(?:cat|head|tail|less|more|sed|awk|strings|base64)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|/etc/master\\.passwd)",
131
- "(?:cat|head|tail|less|more|grep)\\s+[^;&|\\n]*known_hosts",
132
- "\\bpython3?\\s+-c\\s+['\\\"][\\s\\S]{0,200}?(?:base64\\.b64encode|open\\s*\\(|Path\\(|io\\.open\\s*\\(|read_text\\s*\\(|read\\s*\\()[\\s\\S]{0,200}?(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)",
133
- "(?:grep|find|cat)\\s+[^;&|\\n]*\\b(?:password|secret|passwd|shadow|credential|api[_-]?key)\\b[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)",
134
- "(?:cp|mv|dd|curl)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)"
135
- ],
136
- "PERSIST": [
137
- "(?:echo|printf|cat)\\b[^;\\n]*\\|[^;\\n]*(?:crontab|at\\b)\\s*-",
138
- "\\bsystemctl\\s+enable\\s+",
139
- "(?:echo|printf)\\b[^;\\n]*(?:/dev/tcp/|nc\\s+-l|ncat|reverse|backdoor|bash\\s+-i)[^;\\n]*(?:>>|>)\\s*(?:~?/\\.bashrc|~?/\\.profile|/etc/rc\\.local|/etc/crontab)",
140
- "\\bat\\s+now\\b|\\bchkconfig\\s+\\S+\\s+on\\b",
141
- "\\bcrontab\\s+-e\\b"
142
- ]
143
- },
144
- "chains": [
145
- {
146
- "id": "listener-exec-scan",
147
- "stages": [
148
- "LISTEN",
149
- "EXEC",
150
- "SCAN"
151
- ],
152
- "min_stages": 3,
153
- "risk_level": "high",
154
- "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 网络侦察"
155
- },
156
- {
157
- "id": "listener-exec-cred",
158
- "stages": [
159
- "LISTEN",
160
- "EXEC",
161
- "CRED"
162
- ],
163
- "min_stages": 3,
164
- "risk_level": "critical",
165
- "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 访问凭据文件"
166
- },
167
- {
168
- "id": "listener-exec-exfil",
169
- "stages": [
170
- "LISTEN",
171
- "EXEC",
172
- "EXFIL"
173
- ],
174
- "min_stages": 3,
175
- "risk_level": "critical",
176
- "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 数据外传"
177
- },
178
- {
179
- "id": "listener-exec-persist",
180
- "stages": [
181
- "LISTEN",
182
- "EXEC",
183
- "PERSIST"
184
- ],
185
- "min_stages": 3,
186
- "risk_level": "high",
187
- "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 持久化后门"
188
- },
189
- {
190
- "id": "exec-scan-cred",
191
- "stages": [
192
- "EXEC",
193
- "SCAN",
194
- "CRED"
195
- ],
196
- "min_stages": 3,
197
- "risk_level": "high",
198
- "reason": "组合攻击链:获取命令执行能力 → 网络侦察 → 访问凭据文件"
199
- },
200
- {
201
- "id": "exec-privesc-cred",
202
- "stages": [
203
- "EXEC",
204
- "PRIVESC",
205
- "CRED"
206
- ],
207
- "min_stages": 3,
208
- "risk_level": "high",
209
- "reason": "组合攻击链:获取命令执行能力 → 提权 → 访问凭据文件"
210
- },
211
- {
212
- "id": "privesc-cred-exfil",
213
- "stages": [
214
- "PRIVESC",
215
- "CRED",
216
- "EXFIL"
217
- ],
218
- "min_stages": 3,
219
- "risk_level": "critical",
220
- "reason": "组合攻击链:提权 → 访问凭据文件 → 数据外传"
221
- },
222
- {
223
- "id": "persist-exfil",
224
- "stages": [
225
- "PERSIST",
226
- "EXFIL"
227
- ],
228
- "min_stages": 2,
229
- "risk_level": "high",
230
- "reason": "组合攻击链:持久化后门 → 数据外传(C2 信标)"
231
- },
232
- {
233
- "id": "exec-persist-exfil",
234
- "stages": [
235
- "EXEC",
236
- "PERSIST",
237
- "EXFIL"
238
- ],
239
- "min_stages": 3,
240
- "risk_level": "critical",
241
- "reason": "组合攻击链:获取命令执行能力 → 持久化后门 → 数据外传"
242
- }
243
- ]
244
- }
245
- }
287
+ }
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "scenario_id": "bank",
3
- "description": "银行沙箱场景定制规则。客户约束:沙箱用户(sandbox)仅允许读写 /home/sandbox、/opt/sandbox、/tmp 三个目录,其他根目录一律禁止读写;禁止执行 ssh 命令(横向移动/远程访问)。",
3
+ "description": "银行沙箱场景定制规则。客户约束:沙箱用户(sandbox)仅允许读写 /home/sandbox、/opt/sandbox、/tmp 三个目录,其他根目录一律禁止读写;禁止远程访问/横向移动(ssh 家族 + scp/sftp/sshpass/ssh-copy-id + 用 ssh 的 rsync)。本地操作(ssh-keygen/ssh-add/ssh-agent、本地 rsync)不受影响。",
4
4
  "extra_command_patterns": [
5
5
  {
6
- "pattern": "(?:^|[;\\s>&|@'\"])(/(?!home/sandbox(?:\\s|/|$)|opt/sandbox(?:\\s|/|$)|tmp(?:\\s|/|$))[^\\s;&|>\"]+)",
6
+ "pattern": "(?<![\\w.:~/-])/(?:(?!home/sandbox(?:\\s|/|$)|opt/sandbox(?:\\s|/|$)|tmp(?:\\s|/|$))[^\\s;&|>\"'`]*|[^\\s;&|>\"'`]*/\\.\\.[^\\s;&|>\"'`]*)|(?:^|[\\s;&|<>=(`'\"!/])(?:\\.\\./|\\.\\.(?=\\s|$|[;&|]))|(?:^|[\\s;&|<>=(`'\"!])~(?!sandbox\\b)[\\w-]+",
7
7
  "risk_level": "high",
8
8
  "risk_type": "file_access",
9
- "reason": "bank 场景:访问允许目录(/home/sandbox、/opt/sandbox、/tmp)之外的绝对路径"
9
+ "reason": "bank 场景:访问允许目录(/home/sandbox、/opt/sandbox、/tmp)之外的路径(含根目录 /),或用 .. 逃逸 / ~其它用户"
10
10
  },
11
11
  {
12
- "pattern": "(?:^|[;&|:]\\s*)ssh(?:\\s|$)",
12
+ "pattern": "(?:^|[;&|\\n]|\\$\\(|`)\\s*(?:sudo\\s+(?:-\\S+\\s+)*|doas\\s+|nohup\\s+|time\\s+|timeout\\s+(?:\\S+\\s+)?|env\\s+(?:\\w+=\\S*\\s+)*|command\\s+|builtin\\s+|exec\\s+|xargs\\s+(?:-\\S+\\s+)*)*ssh(?![\\w-])(?!-keygen|-add|-agent)|(?:^|[;&|\\n]|\\$\\(|`)\\s*(?:sudo\\s+(?:-\\S+\\s+)*|doas\\s+|nohup\\s+|time\\s+|timeout\\s+(?:\\S+\\s+)?|env\\s+(?:\\w+=\\S*\\s+)*|command\\s+|builtin\\s+|exec\\s+|xargs\\s+(?:-\\S+\\s+)*)*(?:scp|sftp|sshpass|ssh-copy-id)(?![\\w-])|(?:^|[;&|\\n]|\\$\\(|`)\\s*(?:sudo\\s+(?:-\\S+\\s+)*|doas\\s+|nohup\\s+|time\\s+|timeout\\s+(?:\\S+\\s+)?|env\\s+(?:\\w+=\\S*\\s+)*|command\\s+|builtin\\s+|exec\\s+|xargs\\s+(?:-\\S+\\s+)*)*rsync\\b[^\\n]*?\\s(?:-e|--rsh)[=\\s]",
13
13
  "risk_level": "critical",
14
14
  "risk_type": "network_access",
15
- "reason": "bank 场景:禁止执行 ssh 命令(横向移动/远程访问)"
15
+ "reason": "bank 场景:禁止远程访问 / 横向移动(ssh / scp / sftp / sshpass / ssh-copy-id / rsync -e ssh)"
16
16
  }
17
17
  ],
18
18
  "extra_injection_keywords": [],
package/dist/server.d.ts CHANGED
@@ -1,5 +1,18 @@
1
1
  import { Hono } from 'hono';
2
2
 
3
+ /**
4
+ * 启动时打印**部署自检** —— 把「会静默让安全功能失效」的配置一次性说清楚。
5
+ *
6
+ * 为什么需要(2026-09 招行客户实例):客户反馈「简单的路径绕过都不拦」,排查下来是
7
+ * **场景规则压根没启用**(`AGENT_MOSS_SCENARIO` 未设置)—— 此时 bank 沙箱的目录白名单
8
+ * 一条都不跑,**所有路径都放行**,而服务启动没有任何提示(控制台也只是不显示场景卡片,
9
+ * 客户不一定会去看)。这类「静默失效」是安全产品最不该有的,必须在启动日志里喊出来。
10
+ *
11
+ * ⚠️ 顺带说明为什么只能靠环境变量:HTTP 路由**不接受**请求里的 `scenarioId`
12
+ * (routes.ts 不映射该字段),场景是**部署级**配置。
13
+ * 与 Python `agent_moss/server/app.py::_log_deployment_selfcheck` 对齐。
14
+ */
15
+ declare function logDeploymentSelfCheck(): void;
3
16
  declare function createApp(): Hono;
4
17
  /**
5
18
  * 从 startPort 开始找第一个可用端口(照搬 OpenDesk findFreePort 策略)。
@@ -15,4 +28,4 @@ declare function startServer(host?: string, port?: number): Promise<{
15
28
  port: number;
16
29
  }>;
17
30
 
18
- export { createApp, findFreePort, startServer };
31
+ export { createApp, findFreePort, logDeploymentSelfCheck, startServer };