picoclaw/pkg/mcp
Andy Lo-A-Foe 5b4f3d575a
fix(mcp): add allowlist and validation for dynamic headers
Addresses security concerns raised in PR review:

1. Dynamic headers now require explicit allowlist per server:
   - New `dynamic_headers.allowed` config field lists permitted header names
   - Without allowlist, no dynamic headers are forwarded (secure by default)
   - Header names matched case-insensitively

2. Add limits to prevent abuse:
   - `max_count`: max headers per request (default: 10)
   - `max_value_len`: max value length (default: 4096)

3. Protect internal metadata in pico channel:
   - Reserved keys (platform, session_id, conn_id, etc.) cannot be
     overwritten by client-provided metadata

Example config:
```json
"dynamic_headers": {
  "allowed": ["X-Grafana-Service-Account-Token"],
  "max_count": 5,
  "max_value_len": 2048
}
```

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 09:55:38 +02:00
..
events.go fix(events): keep runtime observers non-blocking 2026-04-27 13:09:03 +08:00
isolated_command_transport.go Feat/support isolation (#2423) 2026-04-08 18:15:42 +08:00
manager.go fix(mcp): add allowlist and validation for dynamic headers 2026-05-11 09:55:38 +02:00
manager_test.go fix(mcp): add allowlist and validation for dynamic headers 2026-05-11 09:55:38 +02:00