Commit e2c5eba
fix(agent): scrub model-supplied _owner on the qualified mcp__ image path (P2, #4123 review)
The wrapper path (_call_mcp_tool) injected the trusted _owner only for the builtin
"generate_image" name. A model could instead issue the fully-qualified
mcp__image_gen__generate_image directly, which the generic mcp__ dispatch branch
passed straight to MCP with the model's JSON args — letting a model-supplied _owner
through to resolve another user's private image endpoint/API key and tag the gallery
row under the spoofed owner.
Centralise the contract in _apply_trusted_owner(name, args, owner): drop any
model-supplied _owner (server-side-only field), then inject the trusted caller owner
for owner-scoped tools — keyed by both the builtin name and its qualified mcp__ name.
Both dispatch paths now call it, so they enforce identically.
Tests: qualified-name and builtin-name spoof regressions on the real helper, a strip
on a non-owner-scoped mcp__ tool, the no-owner case, and a guard that both dispatch
paths call the helper. Full suite green (3544 passed).
Co-Authored-By: Claude <noreply@anthropic.com>1 parent d8fd9ed commit e2c5eba
2 files changed
Lines changed: 71 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
360 | 385 | | |
361 | 386 | | |
362 | 387 | | |
| |||
479 | 504 | | |
480 | 505 | | |
481 | 506 | | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
490 | 512 | | |
491 | 513 | | |
492 | 514 | | |
| |||
961 | 983 | | |
962 | 984 | | |
963 | 985 | | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
964 | 990 | | |
965 | 991 | | |
966 | 992 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
102 | 134 | | |
103 | 135 | | |
104 | 136 | | |
| |||
0 commit comments