Repository navigation
fix(security): preserve chat structured response-format integrity - #2402
Merged
HAYDEN-OAI merged 1 commit intoAug 18, 2026
Merged
Conversation
Contributor
jbeckwith-oai
approved these changes
Aug 18, 2026
jbeckwith-oai
left a comment
Contributor
There was a problem hiding this comment.
Independent two-pass security review confirms chat structured response-format integrity across Zod v3, Zod v4, Zod v4 Mini, and Standard Schema. The shared factory canonicalizes the discriminator, isolates both format levels, removes callable and accessor serialization hooks, preserves branded parsers and immutable inputs, and retains streaming/nonstreaming compatibility. Focused adversarial tests and CI are green. No findings.
HAYDEN-OAI
deleted the
agent/chat-schema-serialization-security-svmfcodj
branch
August 18, 2026 20:45
Merged
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
strict: true.json_schemaconfiguration before removing its owntoJSONhook, preserving frozen inputs, ordinary metadata, enumerable symbols, and validated local parsing.json_schemadiscriminator and root serializer protections already used by Responses text-format helpers.Security impact
Both public
zodResponseFormat()andstandardResponseFormat()spread caller metadata intoresponse_format.json_schema. An enumerable function or getter namedtoJSONis retained there and invoked by real request serialization. Consequently,client.chat.completions.parse()sends attacker-selected{ name, strict: false, schema }even though the SDK's in-memory format still advertises the trusted strict schema and its branded parser validates returned output. The issue affects Zod v3, Zod v4, Zod v4 Mini, and Standard Schema.Validation
client.chat.completions.parse()combinations: four schema families × own callable/accessor serializer.Exactly two handwritten files are changed.