fix(query): use Object.create(null) to prevent prototype pollution#2661
fix(query): use Object.create(null) to prevent prototype pollution#2661wdskuki wants to merge 1 commit intovuejs:mainfrom
Conversation
Changes parseQuery, normalizeQuery, and parseURL to use Object.create(null)
instead of {} when creating query objects. This prevents prototype pollution
via __proto__ and constructor keys in query strings.
Fixes vuejs#2658
✅ Deploy Preview for vue-router canceled.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis change addresses a prototype pollution vulnerability in Vue Router's query parsing functions by replacing plain object initialization ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can disable sequence diagrams in the walkthrough.Disable the |
Summary
This PR fixes a security vulnerability where query objects created with
{}are susceptible to prototype pollution via__proto__andconstructorkeys.Changes
parseQuery(): UseObject.create(null)instead of{}normalizeQuery(): UseObject.create(null)instead of{}parseURL(): UseObject.create(null)for initial query objectSecurity Impact
Before this fix, an attacker could craft a URL like:
/?__proto__=evil&foo=bar- pollutes the query object's prototype/?constructor=test- leaks internal Object constructorAfter this fix, these keys are treated as plain data without affecting the prototype chain.
Fixes
Fixes #2658
Summary by CodeRabbit