Skip to content

🛡️ Sentinel: [CRITICAL] Fix prototype pollution in label scoping#24

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

🛡️ Sentinel: [CRITICAL] Fix prototype pollution in label scoping#24
ericbfriday wants to merge 1 commit into
masterfrom
sentinel-fix-prototype-pollution-5229388649846457813

Conversation

@ericbfriday
Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL
💡 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.
🎯 Impact: Allowed parsing failures, scope collision, and possibly executing malicious code down the line due to prototype pollution.
🔧 Fix: Initialized the labels dictionary structure with Object.create ? Object.create(null) : {} rather than just {}. This ensures that the map object has a null prototype and does not inherit properties from Object.prototype, making keys like __proto__ safe to use.
Verification: Verified using npm run test which now passes successfully without prototype collision, and manually confirmed that parsing goto __proto__ throws the correct "no visible label '__proto__' for <goto>" instead of crashing.


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

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.
@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 22, 2026 00:05
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 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 FullFlowContext scope labels with a null-prototype dictionary.
  • Add a .jules/sentinel.md entry 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.

Comment thread luaparse.js
FullFlowContext.prototype.pushScope = function (isLoop) {
var scope = {
labels: {},
labels: Object.create ? Object.create(null) : {},
Comment thread luaparse.js
Comment on lines 1675 to 1679
FullFlowContext.prototype.pushScope = function (isLoop) {
var scope = {
labels: {},
labels: Object.create ? Object.create(null) : {},
locals: [],
deferredGotos: [],
Comment thread .jules/sentinel.md
## 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 `{}`.
Comment thread .jules/sentinel.md
Comment on lines +4 to +5
**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 `{}`.
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