Repository navigation
Conversation
Copy sanitized object properties with defineProperty instead of direct assignment. Assignment on an ordinary object invokes inherited accessors for special names such as __proto__, letting untrusted input change the prototype of the sanitized result. defineProperty always creates a plain own data property, so __proto__, constructor and prototype are handled safely as ordinary keys. Throw a Duplicate key error when stripping control characters maps two different input keys onto the same output key, instead of silently dropping one of the values. Add direct and nested regression coverage (including objects inside arrays) for special property names, a key that sanitizes into a special name, and key collisions.
This branch has not been 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.
Harden
sanitizeToolParams()against special property names and key collisions.The sanitizer copied entries with direct assignment, so an already-parsed object carrying a
__proto__key could invoke the inherited setter and change the prototype of the sanitized result. It now copies each property withObject.definePropertyas a plain own data property, so__proto__,constructorandprototypeare handled safely as ordinary keys at every nesting level (including inside arrays).When stripping control characters maps two different input keys onto the same output key, the sanitizer now throws a
Duplicate keyerror instead of silently dropping one of the values.Added direct and nested regression coverage for special property names, keys that sanitize into a special name, and key collisions, plus an end-to-end check that a colliding tool call is refused before the handler runs. Documented both safeguards in the README.
Fixes #311