Skip to content

Commit 2cd0bd1

Browse files
run prettier
1 parent 87a73db commit 2cd0bd1

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

docs/specification/draft/basic/security_best_practices.mdx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,26 @@ sequenceDiagram
194194

195195
When you have multiple stateful HTTP servers that handle MCP requests, the following attack vectors are possible:
196196

197-
1. Session Hijack Prompt Injection
198-
1. The client connects to **Server A** and receives a session ID.
199-
2. The attacker obtains an existing session ID and sends a malicious event to **Server B** with said session ID.
197+
**Session Hijack Prompt Injection**
198+
199+
1. The client connects to **Server A** and receives a session ID.
200+
1. The attacker obtains an existing session ID and sends a malicious event to **Server B** with said session ID.
201+
202+
200203
- When a server supports [redelivery/resumable streams](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#resumability-and-redelivery), deliberately terminating the request before receiving the response could lead to it being resumed by the original client via the GET request for server sent events.
201204
- If a particular server initiates server sent events as a consequence of a tool call such as a `notifications/tools/list_changed`, where it is possible to affect the tools that are offered by the server, a client could end up with tools that they were not aware were enabled.
202-
3. **Server B** enqueues the event (associated with session ID) into a shared queue.
203-
4. **Server A** polls the queue for events using the session ID and retrieves the malicious payload.
204-
5. **Server A** sends the malicious payload to the client as an asynchronous or resumed response.
205-
6. The client receives and acts on the malicious payload, leading to potential compromise.
206-
2. Session Impersonation Hijack
207-
1. The MCP client authenticates with the MCP server, creating a persistent session ID.
208-
2. The attacker obtains the session ID.
209-
3. The attacker makes calls to the MCP server using the session ID.
210-
4. MCP server does not check for additional authorization and treats the attacker as a legitimate user, allowing unauthorized access or actions.
205+
206+
3. **Server B** enqueues the event (associated with session ID) into a shared queue.
207+
4. **Server A** polls the queue for events using the session ID and retrieves the malicious payload.
208+
5. **Server A** sends the malicious payload to the client as an asynchronous or resumed response.
209+
6. The client receives and acts on the malicious payload, leading to potential compromise.
210+
211+
**Session Impersonation Hijack**
212+
213+
1. The MCP client authenticates with the MCP server, creating a persistent session ID.
214+
2. The attacker obtains the session ID.
215+
3. The attacker makes calls to the MCP server using the session ID.
216+
4. MCP server does not check for additional authorization and treats the attacker as a legitimate user, allowing unauthorized access or actions.
211217

212218
#### 2.3.4 Mitigation
213219

@@ -222,5 +228,5 @@ Generated session IDs (e.g., UUIDs) **SHOULD** use secure random number generato
222228
MCP servers **SHOULD** bind session IDs to user-specific information.
223229
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.
224230

225-
MCP servers can optionally leverage additional unique identifiers.
231+
MCP servers can optionally leverage additional unique identifiers.
226232
Where appropriate, consider incorporating other unique attributes into the session key, such as the source IP address. This adds another layer of defense, making it more difficult for attackers to hijack sessions from different locations.

0 commit comments

Comments
 (0)