Repository navigation
Commit db4c181
KaiyiQuan
fix(server): do not crash the SSE server process on an invalid Host/Origin
When a request to /sse fails the transport-security checks (DNS-rebinding
protection: disallowed Host -> 421, disallowed Origin -> 403), connect_sse
sends the rejection response and then raises ValueError to signal the
caller that no SSE session was established. FastMCP.sse_app()'s handle_sse
had no handler for it, so the exception escaped the ASGI callable and
uvicorn crashed the whole server process -- one malformed request killed
every client (reported in #3661 via ida-pro-mcp's idalib-mcp).
Catch ValueError in handle_sse: the rejection response has already been
sent to that one client, so just return. Also document connect_sse's
send-then-raise contract so future callers know to handle it.
Adds a regression test driving MCPServer.sse_app() with a disallowed Host
through the in-process ASGI bridge: 421 returned and no exception escapes.
32 server/security tests pass (1367 in tests/server/).1 parent 91941ed commit db4c181
3 files changed
Lines changed: 43 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1175 | 1175 | | |
1176 | 1176 | | |
1177 | 1177 | | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
1182 | 1192 | | |
1183 | 1193 | | |
1184 | 1194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
0 commit comments