Skip to content

fix: Cap JSON parser depth#1748

Open
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/fix/json-max-depth
Open

fix: Cap JSON parser depth#1748
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/fix/json-max-depth

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented May 25, 2026

Reject JSON inputs whose object or array nesting exceeds 64 levels. The parser previously recursed once per nested container with no limit, so crafted cached JSON could exhaust the C call stack during SDK startup or envelope/session processing.

Use 64 because the JSON writer already uses that maximum depth. Matching the writer preserves the SDK's existing JSON depth policy: JSON the SDK can emit remains accepted, while deeper untrusted input is rejected.

Msgpack deserialization was already capped in #1727. Raise that existing cap from 32 to 64 because msgpack uses the same recursive value conversion shape.

jpnurmi and others added 2 commits May 25, 2026 12:14
Reject JSON inputs whose object or array nesting exceeds 64 levels. The parser
previously recursed once per nested container with no limit, so crafted cached
JSON could exhaust the C call stack during SDK startup or envelope/session
processing.

Use 64 because the JSON writer already uses that maximum depth. Matching the
writer preserves the SDK's existing JSON depth policy: JSON the SDK can emit
remains accepted, while deeper untrusted input is rejected.

Msgpack deserialization was already capped. Raise that existing cap from 32 to
64 because msgpack uses the same recursive value conversion shape, and 64 is
the stack-safe bound chosen for JSON.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant