You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Example `message`: `"@.bashrc what is in this file?"` (user/agent intent captured).
59
+
- Example `message`: "@.bashrc what is in this file?" (user/agent intent captured).
60
60
- Claude Code history: `~/.claude/history.jsonl`
61
61
- JSONL entries with fields like `display`, `timestamp`, `project`.
62
62
63
-
Correlate these local logs with requests observed at your LLM gateway/proxy (e.g., LiteLLM) to detect tampering/model‑hijacking: if what the model processed deviates from the local prompt/output, investigate injected instructions or compromised tool descriptors.
64
-
65
63
---
66
64
67
-
## Endpoint Telemetry Patterns
65
+
## Pentesting Remote MCP Servers
68
66
69
-
Representative chains on Amazon Linux 2023 with Node v22.19.0 and Python 3.13:
67
+
Remote MCP servers expose a JSON‑RPC 2.0 API that fronts LLM‑centric capabilities (Prompts, Resources, Tools). They inherit classic web API flaws while adding async transports (SSE/streamable HTTP) and per‑session semantics.
70
68
71
-
1) Built‑in tools (local file access)
72
-
- Parent: `node .../bin/claude --model <model>` (or equivalent for the CLI)
73
-
- Immediate child action: create/modify a local file (e.g., `demo-claude`). Tie the file event back via parent→child lineage.
69
+
Key actors
70
+
- Host: the LLM/agent frontend (Claude Desktop, Cursor, etc.).
71
+
- Client: per‑server connector used by the Host (one client per server).
72
+
- Server: the MCP server (local or remote) exposing Prompts/Resources/Tools.
74
73
75
-
2) MCP over STDIO (local tool server)
76
-
-Chain: `node → uv → python → file_write`
77
-
-Example spawn: `uv run --with fastmcp fastmcp run /home/ssm-user/tools/server.py`
74
+
AuthN/AuthZ
75
+
-OAuth2 is common: an IdP authenticates, the MCP server acts as resource server.
76
+
-After OAuth, the server issues an authentication token used on subsequent MCP requests. This is distinct from `Mcp-Session-Id` which identifies a connection/session after `initialize`.
78
77
79
-
3) MCP over HTTP (remote tool server)
80
-
-Client: `node/<ai-cli>` opens outbound TCP to `remote_port: 8000` (or similar)
81
-
-Server: remote Python process handles the request and writes `/home/ssm-user/demo_http`.
78
+
Transports
79
+
-Local: JSON‑RPC over STDIN/STDOUT.
80
+
-Remote: Server‑Sent Events (SSE, still widely deployed) and streamable HTTP.
82
81
83
-
Because agent decisions differ by run, expect variability in exact processes and touched paths.
82
+
A) Session initialization
83
+
- Obtain OAuth token if required (Authorization: Bearer ...).
- Look for error echoes/stack traces in results to refine payloads. Independent testing has reported widespread command‑injection and related flaws in MCP tools.
134
+
- Prompts → Injection preconditions
135
+
- Prompts mainly expose metadata; prompt injection matters only if you can tamper with prompt parameters (e.g., via compromised resources or client bugs).
118
136
119
-
## Blue‑Team Repro Notes
137
+
D) Tooling for interception and fuzzing
138
+
- MCP Inspector (Anthropic): Web UI/CLI supporting STDIO, SSE and streamable HTTP with OAuth. Ideal for quick recon and manual tool invocations.
139
+
- HTTP–MCP Bridge (NCC Group): Bridges MCP SSE to HTTP/1.1 so you can use Burp/Caido.
140
+
- Start the bridge pointed at the target MCP server (SSE transport).
141
+
- Manually perform the `initialize` handshake to acquire a valid `Mcp-Session-Id` (per README).
142
+
- Proxy JSON‑RPC messages like `tools/list`, `resources/list`, `resources/read`, and `tools/call` via Repeater/Intruder for replay and fuzzing.
120
143
121
-
Use a clean VM with an EDR or eBPF tracer to reproduce chains like:
122
-
- `node → claude --model claude-sonnet-4-20250514` then immediate local file write.
123
-
- `node → uv run --with fastmcp ... → python3.13`writing under `$HOME`.
124
-
- `node/<ai-cli>`establishing TCP to an external MCP server (port 8000) while a remote Python process writes a file.
144
+
Quick test plan
145
+
- Authenticate (OAuth if present) → run `initialize` → enumerate (`tools/list`, `resources/list`, `prompts/list`) → validate resource URI allow‑list and per‑user authorization → fuzz tool inputs at likely code‑execution and I/O sinks.
125
146
126
-
Validate that your detections tie the file/network events back to the initiating AI‑CLI parent to avoid false positives.
147
+
Impact highlights
148
+
- Missing resource URI enforcement → LFI/SSRF, internal discovery and data theft.
149
+
- Missing per‑user checks → IDOR and cross‑tenant exposure.
150
+
- Unsafe tool implementations → command injection → server‑side RCE and data exfiltration.
127
151
128
152
---
129
153
130
154
## References
131
155
132
156
-[Commanding attention: How adversaries are abusing AI CLI tools (Red Canary)](https://redcanary.com/blog/threat-detection/ai-cli-tools/)
0 commit comments