[GH-ISSUE #515] Pixelforge: two remaining prototype-key reads (theme resolution, resident names) #261

Closed
opened 2026-10-20 17:25:52 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Aug 23, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/515

Originally assigned to: @kolacheee on GitHub.

Two sibling sites of the prototype-key bug class fixed in 59-economy.js (S5 slices 5-6 gate) survive elsewhere in the Pixelforge package, and one of them is the upstream half of how a prototype-named theme reaches saved state at all:

  1. packages/pixelforge/src/10-art.js (~:468) — THEMES[id] is a truthiness read, so setTheme("constructor") resolves Object's constructor function as truthy, returns "constructor", and pins the module-level activeTheme to it — directly contradicting the function's own docstring ("Unknown ids resolve to the fixed default"). This is how a prototype-named theme can end up in world.theme and a save row in the first place.

  2. packages/pixelforge/src/20-world.js (~:2003) — RESIDENT_NAMES[activeTheme] ?? RESIDENT_NAMES["cozy-village"] is the exact ??-never-reaches-fallback shape: RESIDENT_NAMES["__proto__"] is Object.prototype (non-nullish), so the fallback never fires and compile() throws; the throw is caught and the world silently degrades to the legacy three-zone layout.

Both are contained today (the economy layer now guards its own reads with Object.prototype.hasOwnProperty.call, and the degradation path doesn't corrupt saves), but the class keeps resurfacing — the S5 gates have now caught it in zone lookups (slices 1-2), player-block maps (slices 3-4), and the economy tables (slices 5-6). Suggested fix shape, same as the shipped ones: an own-property test before trusting any read off a caller-influenced key, with the documented fallback actually reachable. A shared own(map, key) helper in the prelude would end the per-site whack-a-mole.

Found by the slices 5-6 verification pass (probe-verified at both sites); scoped out of that round because neither file was touched by it.

Originally created by @kolacheee on GitHub (Aug 23, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/515 Originally assigned to: @kolacheee on GitHub. Two sibling sites of the prototype-key bug class fixed in `59-economy.js` (S5 slices 5-6 gate) survive elsewhere in the Pixelforge package, and one of them is the upstream half of how a prototype-named theme reaches saved state at all: 1. `packages/pixelforge/src/10-art.js` (~:468) — `THEMES[id]` is a truthiness read, so `setTheme("constructor")` resolves `Object`'s constructor function as truthy, returns `"constructor"`, and pins the module-level `activeTheme` to it — directly contradicting the function's own docstring ("Unknown ids resolve to the fixed default"). This is how a prototype-named theme can end up in `world.theme` and a save row in the first place. 2. `packages/pixelforge/src/20-world.js` (~:2003) — `RESIDENT_NAMES[activeTheme] ?? RESIDENT_NAMES["cozy-village"]` is the exact `??`-never-reaches-fallback shape: `RESIDENT_NAMES["__proto__"]` is `Object.prototype` (non-nullish), so the fallback never fires and `compile()` throws; the throw is caught and the world silently degrades to the legacy three-zone layout. Both are contained today (the economy layer now guards its own reads with `Object.prototype.hasOwnProperty.call`, and the degradation path doesn't corrupt saves), but the class keeps resurfacing — the S5 gates have now caught it in zone lookups (slices 1-2), player-block maps (slices 3-4), and the economy tables (slices 5-6). Suggested fix shape, same as the shipped ones: an own-property test before trusting any read off a caller-influenced key, with the documented fallback actually reachable. A shared `own(map, key)` helper in the prelude would end the per-site whack-a-mole. Found by the slices 5-6 verification pass (probe-verified at both sites); scoped out of that round because neither file was touched by it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#261
No description provided.