Commit 93fc2ee
committed
Reject an orphan Mcp-Name header when the body omits the named param
classify_inbound_request's Mcp-Name check only ran when the body carried
the name-bearing method's param (name_key). When the body omitted it, a
present Mcp-Name header went unvalidated entirely -- an intermediary or
client could set it to claim a different tool/prompt/resource than the
request body actually names, with no rejection.
validate_mcp_param_headers already treats this shape -- a header present
with no matching body value -- as a rejection for Mcp-Param-* headers,
on the same reasoning: a conforming client never emits the header unless
the body value is present, so a header with nothing to match against did
not come from this request. Mcp-Name had no equivalent check.
Mirrors that handling: when the named param is absent, an absent header
still passes (the param's own absence is INVALID_PARAMS elsewhere, not
this rung's concern), but a present header is now rejected HEADER_MISMATCH.
Adds test_header_rung_rejects_orphan_name_header_when_body_omits_the_named_param,
parametrized over all of NAME_BEARING_METHODS. Confirmed it fails against
the unpatched code (reverting just inbound.py, keeping the test) and
passes with the fix.
AI assistance disclosure: I used Claude to help investigate this issue
and implement/test the fix; I've reviewed the change and reasoning above
and can answer questions about it.
Fixes #32691 parent a4f4ccd commit 93fc2ee
2 files changed
Lines changed: 36 additions & 6 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
389 | | - | |
390 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
391 | 392 | | |
392 | 393 | | |
393 | 394 | | |
| |||
444 | 445 | | |
445 | 446 | | |
446 | 447 | | |
447 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
448 | 463 | | |
449 | 464 | | |
450 | 465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
315 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
316 | 317 | | |
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
320 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
321 | 336 | | |
322 | 337 | | |
323 | 338 | | |
| |||
0 commit comments