Repository navigation
fix(provider): harden inbound request handling (security) - #2130
Merged
Merged
Conversation
…malization
A coordinator request's decrypted body is parsed by JSONSerialization and
JSONDecoder, which recurse once per object or array level, on a Swift
concurrency task whose stack is 512 KiB. A chat body of a few KB whose tool
schema nested a few hundred levels deep (128 in a debug build) exhausted that
stack and killed the provider with SIGBUS, below JSONSerialization's own
512-level limit. The coordinator forwards such bodies: it parses with Go's
decoder and normalizes tool schemas only to depth 64.
- Add `JSONNestingLimit`, a non-recursive scan that counts open containers
and skips brackets inside strings. Refuse bodies deeper than 64 levels
before any parse: in the coordinator handler right after decryption
(`malformed_body`), in `repairedRequestBody` for every other caller, and in
the local chat, batch, Responses and router paths (HTTP 400).
- Give tool-schema normalization a 100,000-node budget per request. Each
positional `{}` or boolean became a two-key map, so a few MiB of them
rewrote into ~85 MB of JSON and ~900 MiB of objects before decoding. Past
the budget the body is decoded as sent, as one over 4 MiB already is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in the JSON limit Refactor-pass follow-up to the JSON nesting limit. - Refuse a body holding a NUL byte. Foundation's JSONSerialization and JSONDecoder also read UTF-16 and UTF-32 JSON, whose bytes the depth scan cannot count: a UTF-16 chat body with a 400-level tool schema passed the scan and still crashed the decoder (SIGBUS on dev). Every UTF-16 or UTF-32 JSON text has a NUL byte; no UTF-8 one does. - Check each tool call's `arguments` after decoding, on the coordinator path (refused as `invalid_tool_arguments`) and on the local chat, batch and Responses paths (400). The body scan skips JSON inside strings, and template rendering decodes and walks those arguments. - Cover the SDK's other JSON routes on the local API (completions, tokenizer utilities, embeddings) with the same 2 MiB collection and check. - Cleanups from the review: one refusal message constant, `refuses` naming, shared test builders, a router test, and the deepest accepted body decoding on a task's stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… NUL rule itself Review follow-up. /apply-template renders its messages' tool calls, decoding each one's arguments, so its body is now decoded and its arguments checked like the chat path. The UTF-16/32 test now holds an escaped quote, so only the NUL rule (not the depth count) can refuse it, and it no longer decodes a body the scan let through. Router comments and the direct-mode doc match what is checked where. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…h-and-tool-schema-budget Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h-and-tool-schema-budget Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 14, 2026
jonathan308
added a commit
that referenced
this pull request
Nov 14, 2026
- changelog.d/gemma-tool-grammar-linear-optional-members.md: generic public text (#2111) - changelog.d/updater-signed-version-matches-release.md: generic public text (#2117) - changelog.d/cluster-pairing-posture-is-self-reported.md: generic public text (#2129) - changelog.d/inbound-json-depth-and-tool-schema-budget.md: generic public text (#2130) - changelog.d/coordinator-inbound-queue-budget.md: generic public text (#2135) - changelog.d/toml-parse-memory.md: generic public text (#2138) - changelog.d/cluster-link-key-keychain.md: generic public text (#2137) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 18, 2026
The suite feeds seeded random and hostile model output, at every chunking, through: - the channel splitter; - the tool frame; - the SDK's ATEM reference reader and its strict parser; - the scheduler's forwarding body, under every tool choice. Each must hold up the way the inbound-depth (#2130), queue-budget (#2135) and TOML (#2138) fixes were tested. It must not crash, stall, buffer without bound, leak framing, raise invalidToolPayload or return a 500. A frame the model gets wrong is the model's error, a 422. deepNesting and the deep hostile frames need the nesting bounds of mlx-swift-lm #423 (824db4cf and 31a7ccb2, from d266d4e6 and 7f958c64) in the pin; this branch pins b7672434, which has them. Without them, a value nested a few hundred levels deep stops the test process with SIGBUS, as it would stop a provider. repeatedStrayCloses took about two minutes in a debug build while the splitter rescanned the tool body on every stray closing tag; with the linear splitter of #2149 (e2c60ca) it takes about a second. Test-only. Co-Authored-By: Claude <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens the provider's handling of inbound request bodies (security scan finding 325).
Details are withheld until the fix has reached the fleet. The full problem statement, tests and review are kept with the
release's private notes and will be published here after the rollout.
Testing
devand pass on this head.