Skip to content

🛡️ Sentinel: [CRITICAL] Fix prototype pollution in Lua labels#27

Open
ericbfriday wants to merge 1 commit into
masterfrom
sentinel-fix-prototype-pollution-9779084557372783428
Open

🛡️ Sentinel: [CRITICAL] Fix prototype pollution in Lua labels#27
ericbfriday wants to merge 1 commit into
masterfrom
sentinel-fix-prototype-pollution-9779084557372783428

Conversation

@ericbfriday
Copy link
Copy Markdown
Owner

🚨 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 with Object.prototype properties (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.labels to use Object.create ? Object.create(null) : {}, effectively creating a pure dictionary isolated from JavaScript built-ins, with a fallback for ancient environments.
Verification: Ran npm run test to verify parser functionality remains completely intact and ran npm run bench:luast to verify no performance degradation.


PR created automatically by Jules for task 9779084557372783428 started by @ericbfriday

@google-labs-jules
Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings May 23, 2026 23:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.labels as a null-prototype dictionary to avoid collisions with Object.prototype properties.
  • 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.

Comment thread luaparse.js
Comment on lines 1676 to 1678
var scope = {
labels: {},
labels: Object.create ? Object.create(null) : {},
locals: [],
Comment thread .jules/sentinel.md
## 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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants