fix(#119, #121): validate profile names to prevent Object.prototype pollution#138
Conversation
…Object.prototype pollution
Two separate code paths allowed renderer-supplied or filename-derived strings
to be used as object keys on the profiles plain object without any validation:
1. saveThemeProfile (called via theme-profiles:save IPC) used the renderer
string directly: profiles[profileName] = visualizerSettings.
window.paralineApp.saveThemeProfile('__proto__') caused
profiles['__proto__'] = visualizerSettings, polluting Object.prototype
with all current settings properties for the rest of the main-process
session. (Issue SamXop123#121)
2. The theme-profiles:import handler derived the profile name from the
imported filename via path.basename. Importing a file named __proto__.json
set profiles['__proto__'] = sanitizedProfile, same impact. (Issue SamXop123#119)
Added isValidProfileName() which rejects any name that:
- is not a non-empty string
- matches a reserved JS property name (__proto__, constructor, prototype)
- does not match the safe allowlist pattern [A-Za-z0-9 _-() unicode]{1,64}
saveThemeProfile now returns null early for invalid names. The import handler
returns a structured error response. The guard is defined once and applied
consistently across both call sites.
Fixes SamXop123#119
Fixes SamXop123#121
|
@anshul23102 is attempting to deploy a commit to the Dot_NotSam's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 59 minutes and 26 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Summary
Two separate code paths in
main.jsallowed attacker-controlled strings to be used as plain-object keys without validation, enabling prototype pollution ofObject.prototypein the main process.Issue Security: saveThemeProfile and loadThemeProfile accept unchecked profileName strings, allowing renderer to pollute Object.prototype via reserved property names #121:
saveThemeProfile(profileName)used the renderer-supplied string directly asprofiles[profileName] = visualizerSettings. Callingwindow.paralineApp.saveThemeProfile('__proto__')setObject.prototypeproperties to all current settings values, affecting every plain object created in the main process for the rest of the session.Issue Security: theme-profiles:import derives profile name from filename, allowing a file named __proto__.json to pollute Object.prototype #119: The
theme-profiles:importhandler derived the profile name from the imported filename viapath.basename(filePath, '.json'). Importing a file named__proto__.jsontriggeredprofiles['__proto__'] = sanitizedProfile, same impact as above.Closes #119
Closes #121
Root Cause
Fix
Added
isValidProfileName()which rejects:__proto__,constructor,prototype[A-Za-z0-9 _\-()À-ɏ]{1,64}saveThemeProfilereturnsnullearly for invalid names. The import handler returns a structured{ success: false, error }response. The guard is defined once and applied consistently across both call sites.Files Changed
main.js: AddedisValidProfileNamehelper; applied at start ofsaveThemeProfile; applied to filename-derived name intheme-profiles:import.How to Test
window.paralineApp.saveThemeProfile('__proto__')should return null and leaveObject.prototypeunchanged.__proto__.json— should return{ success: false, error: '...' }.My ProfileorDark-2024should continue to work.Checklist