🛡️ Sentinel: [CRITICAL] Fix prototype pollution in label scoping#24
🛡️ Sentinel: [CRITICAL] Fix prototype pollution in label scoping#24ericbfriday wants to merge 1 commit into
Conversation
Updated luaparse.js to use `Object.create ? Object.create(null) : {}` for initializing the labels scoping dictionary instead of a plain `{}` object literal. This prevents prototype pollution and environment corruption via Lua scripts with labels named like `::__proto__::`. Also added Sentinel journal entry.
|
👋 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 mitigates a prototype-pollution vector in luaparse’s label scoping by avoiding plain-object dictionaries for user-controlled label names, and records the security lesson in a Sentinel note.
Changes:
- Initialize
FullFlowContextscopelabelswith a null-prototype dictionary. - Add a
.jules/sentinel.mdentry documenting the vulnerability, learning, and prevention guidance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
luaparse.js |
Uses a null-prototype dictionary for scope.labels to prevent prototype pollution via label names. |
.jules/sentinel.md |
Documents the vulnerability and recommended prevention pattern for future reference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| FullFlowContext.prototype.pushScope = function (isLoop) { | ||
| var scope = { | ||
| labels: {}, | ||
| labels: Object.create ? Object.create(null) : {}, |
| FullFlowContext.prototype.pushScope = function (isLoop) { | ||
| var scope = { | ||
| labels: {}, | ||
| labels: Object.create ? Object.create(null) : {}, | ||
| locals: [], | ||
| deferredGotos: [], |
| ## 2024-05-22 - \[CRITICAL] Fix prototype pollution in label scoping | ||
|
|
||
| **Vulnerability:** A prototype pollution vulnerability existed in `luaparse.js` where the AST parser collected parsed Lua labels into a plain JavaScript object literal `{}`. An attacker controlling parsed Lua scripts could use labels like `::__proto__::` which would corrupt the parser's environment, possibly allowing unexpected behavior during AST traversal. | ||
| **Learning:** Dictionary objects storing user-supplied string keys must be securely initialized without inheriting from `Object.prototype`. In an environment where polyfills might not be present, conditional initializations like `Object.create ? Object.create(null) : {}` provides a safer fallback than just `{}`. |
| **Learning:** Dictionary objects storing user-supplied string keys must be securely initialized without inheriting from `Object.prototype`. In an environment where polyfills might not be present, conditional initializations like `Object.create ? Object.create(null) : {}` provides a safer fallback than just `{}`. | ||
| **Prevention:** Always initialize map/dictionary structures storing dynamic strings with `Object.create(null)` instead of `{}`. |
🚨 Severity: CRITICAL
💡 Vulnerability: A prototype pollution vulnerability existed in
luaparse.jswhere the AST parser collected parsed Lua labels into a plain JavaScript object literal{}. An attacker controlling parsed Lua scripts could use labels like::__proto__::which would corrupt the parser's environment, possibly allowing unexpected behavior during AST traversal.🎯 Impact: Allowed parsing failures, scope collision, and possibly executing malicious code down the line due to prototype pollution.
🔧 Fix: Initialized the
labelsdictionary structure withObject.create ? Object.create(null) : {}rather than just{}. This ensures that the map object has a null prototype and does not inherit properties fromObject.prototype, making keys like__proto__safe to use.✅ Verification: Verified using
npm run testwhich now passes successfully without prototype collision, and manually confirmed that parsinggoto __proto__throws the correct"no visible label '__proto__' for <goto>"instead of crashing.PR created automatically by Jules for task 5229388649846457813 started by @ericbfriday