fix: use hasOwnProperty instead of 'in' operator in assignOrPush#720
Open
abhu85 wants to merge 1 commit intoLeonidas-from-XIV:masterfrom
Open
fix: use hasOwnProperty instead of 'in' operator in assignOrPush#720abhu85 wants to merge 1 commit intoLeonidas-from-XIV:masterfrom
abhu85 wants to merge 1 commit intoLeonidas-from-XIV:masterfrom
Conversation
…nidas-from-XIV#719) The `in` operator in JavaScript traverses the prototype chain, which means tags named after inherited Object.prototype methods (toString, valueOf, constructor, hasOwnProperty, etc.) were incorrectly treated as pre-existing properties. This caused inherited functions to be mixed with user data in arrays, breaking the parsed object and causing TypeError crashes on normal usage. This is a bypass of the CVE-2023-0842 fix. That fix correctly prevents prototype pollution when *writing* properties via defineProperty, but this vulnerability is in the *reading/checking* of property existence. Fix: Replace `key not of obj` with `Object::hasOwnProperty.call obj, key` to only check own properties, not inherited ones. Fixes Leonidas-from-XIV#719 Co-Authored-By: Claude Opus 4.6 <[email protected]>
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
assignOrPushmethodProblem
The
assignOrPushmethod uses the JavaScriptinoperator to check if a key exists:The
inoperator traverses the prototype chain, which means tags named after inheritedObject.prototypemethods (<toString>,<valueOf>,<constructor>,<hasOwnProperty>, etc.) are incorrectly treated as pre-existing properties.This causes inherited functions to be mixed with user data in arrays, breaking the parsed object and causing
TypeErrorcrashes:Note: This is NOT a duplicate of CVE-2023-0842. That fix correctly prevents prototype pollution when writing properties via
defineProperty. This vulnerability is in the reading/checking of property existence via theinoperator.Solution
Replace
key not of obj(CoffeeScriptinoperator) withObject::hasOwnProperty.call obj, keyto only check own properties, not inherited ones.Test Plan
toString,valueOf,constructor,hasOwnPropertytag namesCompatibility
Fixes #719
🤖 Generated with Claude Code