Title: sdk(server): bound request input size before Pydantic model_validate · Issue #239 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: sdk(server): bound request input size before Pydantic model_validate · Issue #239 · adcontextprotocol/adcp-client-python
X Title: sdk(server): bound request input size before Pydantic model_validate · Issue #239 · adcontextprotocol/adcp-client-python
Description: Context Security review of PR #238 (typed handler params) flagged that create_tool_caller now runs Model.model_validate on every tool call with no input-size or depth cap at the SDK layer. Upstream transports (FastMCP streamable-HTTP, a2...
Open Graph Description: Context Security review of PR #238 (typed handler params) flagged that create_tool_caller now runs Model.model_validate on every tool call with no input-size or depth cap at the SDK layer. Upstream...
X Description: Context Security review of PR #238 (typed handler params) flagged that create_tool_caller now runs Model.model_validate on every tool call with no input-size or depth cap at the SDK layer. Upstream...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/239
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sdk(server): bound request input size before Pydantic model_validate","articleBody":"## Context\n\nSecurity review of PR #238 (typed handler params) flagged that `create_tool_caller` now runs `Model.model_validate` on every tool call with no input-size or depth cap at the SDK layer. Upstream transports (FastMCP streamable-HTTP, a2a-python) don't impose a uniform request-body cap, so a hostile caller can submit arbitrarily large JSON and force the server to parse it.\n\nPydantic 2's pydantic-core is Rust-native and resilient to stack depth, but:\n- Deeply-nested JSON with ``extra=\"allow\"`` still allocates per-level Python objects.\n- Large string fields without a `max_length` constraint (e.g. `promoted_offering` on `GetProductsRequest`) become validator-free bulk.\n- CPU per-request rises non-trivially under adversarial input.\n\nPre-existing transport-level concern that PR #238 meaningfully increases because typed dispatch runs validation unconditionally when a model is declared.\n\n## Proposal\n\nOne of:\n\n1. **Starlette middleware at bind time.** `_run_mcp_http` / A2A bind sites install a `max_body_size` guard (Starlette has no built-in; needs a small custom ASGI middleware that reads Content-Length or buffers + caps). Default to a generous 10 MB, expose as a `serve(..., max_request_size=)` kwarg. Same knob for both transports.\n\n2. **SDK-level `len(json.dumps(params)) > N` shortcut** inside `create_tool_caller` before calling `model_validate`. Simpler, but re-serialises what the transport already parsed.\n\nPrefer (1). It kicks in before parsing (cheaper) and covers non-typed handlers too.\n\n## Acceptance\n\n- Size cap on request bodies, enforced at the transport bind point.\n- Default documented in `docs/handler-authoring.md`.\n- Test: request exceeding the cap returns an appropriate transport error before dispatch runs.\n\n## Severity\n\nMedium. Not a merge-blocker for anything shipped. Adversarial-load resilience for adopters running public-facing endpoints.","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-04-20T15:22:38Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/239"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:be80aeb1-5468-fe13-b53b-7ac932d5e2cd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8354:1C6C3E:E27D47:12B8432:6B00FE44 |
| html-safe-nonce | 4a8eb831c80fb4f796fe9d5f77f26b7ed5acde4f7c8111fa209fb1ff12274cba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzU0OjFDNkMzRTpFMjdENDc6MTJCODQzMjo2QjAwRkU0NCIsInZpc2l0b3JfaWQiOiI3MjA1ODcyMDg4MzQ5OTk4NjYwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d7226903636c829d0082be7d9cb5284c805838598ba69f77992edd613ef641d0 |
| hovercard-subject-tag | issue:4296766058 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/239/issue_layout |
| twitter:image | https://opengraph.githubassets.com/78554d8b14fc97ceb77683f4c195aa2615301290448353553ffc43542ee64975/adcontextprotocol/adcp-client-python/issues/239 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/78554d8b14fc97ceb77683f4c195aa2615301290448353553ffc43542ee64975/adcontextprotocol/adcp-client-python/issues/239 |
| og:image:alt | Context Security review of PR #238 (typed handler params) flagged that create_tool_caller now runs Model.model_validate on every tool call with no input-size or depth cap at the SDK layer. Upstream... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width