Skip to content

Use Object.create(null) over {} to avoid prototype issues - v16#4631

Merged
benjie merged 1 commit into16.x.xfrom
obj-create-null-16
Mar 24, 2026
Merged

Use Object.create(null) over {} to avoid prototype issues - v16#4631
benjie merged 1 commit into16.x.xfrom
obj-create-null-16

Conversation

@benjie
Copy link
Copy Markdown
Member

@benjie benjie commented Mar 24, 2026

Object.create(null) is generally safer since it is not vulnerable to prototype pollution in user code. To avoid breaking changes I've returned { ...obj } thus ensuring that the returned object still has the default Object prototype. An alternative would be Object.setPrototypeOf(obj, Object.prototype), but that messes with hidden classes so I figured this solution is cleaner even though it's an additional object allocation. I've also tidied up the variables orphaned by #4453

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
graphql-js Ignored Ignored Preview Mar 24, 2026 10:57am

Request Review

@benjie benjie force-pushed the obj-create-null-16 branch from 327c70b to fef1792 Compare March 24, 2026 10:57
@benjie benjie merged commit 13f130d into 16.x.x Mar 24, 2026
36 checks passed
@benjie benjie added the PR: polish 💅 PR doesn't change public API or any observed behaviour label Mar 24, 2026
benjie added a commit that referenced this pull request Mar 24, 2026
## v16.13.2 (2026-03-24)

#### Docs 📝
* [#4611](#4611) add dev mode docs ([@yaacovCR](https://github.com/yaacovCR))

#### Polish 💅
* [#4631](#4631) Use `Object.create(null)` over `{}` to avoid prototype issues - v16 ([@benjie](https://github.com/benjie))

#### Internal 🏠
* [#4626](#4626) backport: internal: streamline release process (#4615) ([@yaacovCR](https://github.com/yaacovCR))

#### Committers: 2
* Benjie([@benjie](https://github.com/benjie))
* Yaacov Rydzinski ([@yaacovCR](https://github.com/yaacovCR))
@benjie benjie mentioned this pull request Mar 24, 2026
benjie added a commit that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: polish 💅 PR doesn't change public API or any observed behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant