Commit d2e9fd4
fix(python-sdk): wrap proxy callable so caller cannot override account [PLEN-2345]
The previous PLEN-2345 commits used ``functools.partial`` to pre-bind
``connected_account_id`` onto the ``execute_request`` proxy callable.
Codex flagged that ``partial`` lets a caller-supplied keyword override
a pre-bound value: a custom tool calling
``execute_request(connected_account_id="ca_other")`` would run the
proxy under that account while ``auth_credentials`` came from the
trusted resolved account — a credential/identity mismatch (CWE-639).
Replace the partial with a closure whose signature omits
``connected_account_id`` entirely. The id is fixed by the SDK to the
account whose credentials were also passed to the tool function; any
attempt to override it now raises ``TypeError`` at the call site rather
than silently swapping the account out from under the credentials.
Side effect: the public ``ExecuteRequestFn`` Protocol no longer
declares ``connected_account_id`` (it would never have been honoured
anyway given the new wrapper). Sentinel switched ``NotGiven``→``Omit``
on the same Protocol to match the underlying ``client.tools.proxy``
type signature — both sentinels are runtime-equivalent in Stainless'
``is_given``/``strip_not_given``, but the type alignment removes a
mypy error in the wrapper forwarding code.
Pinned by ``test_execute_request_rejects_caller_supplied_connected_account_id``
(new). Existing PLEN-2345 proxy-binding assertions adjusted to match
the wrapper's ``body=omit, parameters=omit`` forwarding.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Karan Vaidya <karan@composio.dev>1 parent 47d000f commit d2e9fd4
2 files changed
Lines changed: 97 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
48 | 59 | | |
49 | 60 | | |
50 | 61 | | |
51 | 62 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 63 | + | |
| 64 | + | |
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
| |||
232 | 240 | | |
233 | 241 | | |
234 | 242 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
239 | 267 | | |
240 | 268 | | |
241 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
370 | 418 | | |
371 | 419 | | |
372 | 420 | | |
| |||
427 | 475 | | |
428 | 476 | | |
429 | 477 | | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
435 | 485 | | |
436 | 486 | | |
437 | 487 | | |
| |||
469 | 519 | | |
470 | 520 | | |
471 | 521 | | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
477 | 526 | | |
478 | 527 | | |
479 | 528 | | |
| |||
0 commit comments