🛡️ Sentinel: [CRITICAL] Fix prototype pollution in Lua labels#27
🛡️ Sentinel: [CRITICAL] Fix prototype pollution in Lua labels#27ericbfriday wants to merge 1 commit into
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR hardens control-flow label tracking in luaparse by preventing prototype pollution / key-collision issues when user-supplied Lua labels are stored in a plain JavaScript object.
Changes:
- Initialize
scope.labelsas a null-prototype dictionary to avoid collisions withObject.prototypeproperties. - Add a Sentinel note documenting the vulnerability pattern and recommended prevention approach.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| luaparse.js | Uses a null-prototype object for scope.labels to prevent prototype pollution from user-controlled label names. |
| .jules/sentinel.md | Adds a security note describing the issue and recommending a safer dictionary initialization pattern. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var scope = { | ||
| labels: {}, | ||
| labels: Object.create ? Object.create(null) : {}, | ||
| locals: [], |
| ## 2024-05-24 - [Fix Prototype Pollution in Lua labels dictionary] | ||
| **Vulnerability:** Dictionary objects storing user-supplied string keys (e.g., Lua labels) were initialized using object literals `{}`. This allowed properties on `Object.prototype` (like `__proto__`, `toString`, `hasOwnProperty`) to interfere with standard logic, enabling potential prototype injection attacks or unexpected control flow. | ||
| **Learning:** In parsers tracking user-supplied identifiers (labels, variable names, etc.), relying on standard objects allows malicious overlap with inherited JS object properties. | ||
| **Prevention:** To prevent prototype pollution in dictionary objects, always use `Object.create ? Object.create(null) : {}` for safer initialization. This effectively creates pure dictionaries isolated from `Object.prototype`. |
🚨 Severity: CRITICAL
💡 Vulnerability: The dictionary object storing user-supplied Lua labels (
scope.labels) was initialized as a standard object literal{}. This made it vulnerable to prototype pollution and unexpected logic issues when label names overlap withObject.prototypeproperties (like__proto__,toString).🎯 Impact: Prevents malicious overlap with inherited JS object properties in the parser's labels context, avoiding unexpected control flow or logic overrides.
🔧 Fix: Changed the initialization of
scope.labelsto useObject.create ? Object.create(null) : {}, effectively creating a pure dictionary isolated from JavaScript built-ins, with a fallback for ancient environments.✅ Verification: Ran
npm run testto verify parser functionality remains completely intact and rannpm run bench:luastto verify no performance degradation.PR created automatically by Jules for task 9779084557372783428 started by @ericbfriday