Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.9.4 breaks code that depended on .hasOwnProperty() #2585

Closed
isdampe opened this issue Apr 10, 2024 · 3 comments · Fixed by #2591
Closed

Release 3.9.4 breaks code that depended on .hasOwnProperty() #2585

isdampe opened this issue Apr 10, 2024 · 3 comments · Fixed by #2591

Comments

@isdampe
Copy link

isdampe commented Apr 10, 2024

Pull #2574 looks like it introduced breaking changes that set the Object prototype to null (and not Object.prototype). A consequence of this is that returned records can no longer call methods of Object.prototype such as hasOwnProperty.

@sidorares
Copy link
Owner

@wellwelwel maybe freeze Object.prototype instead of inheriting from null?

https://cheatsheetseries.owasp.org/cheatsheets/Prototype_Pollution_Prevention_Cheat_Sheet.html
https://portswigger.net/web-security/prototype-pollution/preventing

@isdampe the "correct" way of calling hasOwnProperty should account for a possible null-prototype https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty#objects_created_with_object.createnull but you are right, this should not be introduced in a minor version change

We either need to fix this error somehow in 3.x or bump major version ( and fix in 3.x )

@wellwelwel
Copy link
Collaborator

wellwelwel commented Apr 11, 2024

I don't think we'll need a major version bump for this, but I'll perform some tests and check again to be sure.

Progress:


Related: #2574 (comment)

@wellwelwel
Copy link
Collaborator

wellwelwel commented Apr 17, 2024

Note to self

Including a safe recommendation from MDN for this in docs (especially in case of a major bump version):

const obj = Object.create(null);

obj.test = true;

Object.hasOwn(obj, 'test'); // ✅

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 a pull request may close this issue.

3 participants