Commit 775f676
authored
feat(security): MCP/A2A security hardening — tool collision detection, SMCP lifecycle, IBCT tokens (#2533)
* feat(security): MCP/A2A security hardening — tool collision detection, list locking, env isolation, intent-anchor wrapper, IBCT (#2496, #2497, #2504)
Phase 1 (no new deps):
- Cross-server sanitized_id collision detection in McpManager: warnings on connect and add_server, first-registered tool wins dispatch (MF-1, SF-6)
- Tool-list snapshot locking (lock_tool_list config): tools/list_changed rejected for connected servers; lock set atomically before connect_entry to eliminate TOCTOU race (MF-2)
- Per-server Stdio environment isolation (env_isolation config): spawned processes receive only BASE_ENV_VARS + server env; XDG dirs included for Linux (SF-3)
- Intent-anchor wrapper for MCP tool output: per-invocation UUID nonce boundary prevents delimiter injection; [TOOL_OUTPUT:: escaped in content (MF-5)
Phase 2 (hmac 0.13 + sha2 0.11):
- IBCT module (crates/zeph-a2a/src/ibct.rs): HMAC-SHA256, key_id field for rotation, Vec<IbctKey> for graceful key rollover, base64-JSON X-Zeph-IBCT header, vault_ref config field for secure key storage (MF-3, MF-4)
- ibct feature gate in zeph-a2a; enabled via a2a workspace feature
* fix(security): address code review issues RC-1, RC-2, RC-3, REC-1
RC-1: replace hex string comparison in ibct.rs with constant-time
verify_signature() using Mac::verify_slice() to eliminate the
timing side-channel in HMAC verification.
RC-2: remove hardcoded trust=untrusted field from intent-anchor wrapper
format; the trust annotation was redundant and potentially misleading
since callers already control context.
RC-3: replace all .expect("connected_server_ids lock poisoned") with
.unwrap_or_else(PoisonError::into_inner) to avoid cascade panics
on RwLock poison in manager.rs.
REC-1: add tool_list_locked.remove() in add_server() error branches
for list_tools and run_probe failures, ensuring the lock is always
cleaned up on early return.
* test(security): add unit tests for build_isolated_env and detect_collisions1 parent 5c008e3 commit 775f676
File tree
20 files changed
+1096
-20
lines changed- crates
- zeph-a2a
- src
- zeph-acp/src
- zeph-config/src
- zeph-core/src
- agent
- bootstrap
- zeph-mcp/src
- src
20 files changed
+1096
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | | - | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
0 commit comments