picoclaw/pkg/channels/pico
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
..
client.go merge: integrate main channel config changes 2026-04-14 00:34:17 +08:00
client_test.go refactor(pico): unify message kind handling of tool_calls and thought (#2680) 2026-04-28 10:17:12 +08:00
init.go refactor(config): make config.Channel to multiple instance support 2026-04-13 22:21:21 +08:00
pico.go fix(mcp): add allowlist and validation for dynamic headers 2026-05-11 09:55:38 +02:00
pico_test.go fix(mcp): add allowlist and validation for dynamic headers 2026-05-11 09:55:38 +02:00
protocol.go refactor(pico): unify message kind handling of tool_calls and thought (#2680) 2026-04-28 10:17:12 +08:00