GeezerVison is showing github.com — design(own-key lookups): a plain object is not a map for untrusted keys — one own-key rule for every dynamic lookup · Issue #2792 · developing-today/code
design(own-key lookups): a plain object is not a map for untrusted keys — one own-key rule for every dynamic lookup #2792Closed 4 / 44 of 4 issues completedClosed 4 / 44 of 4 issues completed Labels effort/lLarge: multi-day or open-ended; expect staged check-insepicMeta-issue grouping multiple items (org Project Type=Epic)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivesource/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionOwn keys only — a plain object is not a map for untrusted keys
Design doc: files/designs/code-own-key-lookups.md in the keep-the-four-repos-healthy goal workspace (design-architect pass 21, 2026-10-30). Audited against origin/main da42bfe7.
The problem in one paragraph
Five times in two days the fleet has found the same bug in five files: a plain object literal used as a lookup table for a key that comes from outside the process. A plain-object index walks the prototype chain, so constructor, __proto__, toString, hasOwnProperty, valueOf "hit" the table with inherited members — and every site's miss handling (?? null, === undefined, a truthiness branch) is written for undefined and never fires. The one fixed instance, #2787 (id/web, closed today, commit 9ee4a5d), states the rule this design generalises; the four open instances were each filed and probed individually and will keep recurring individually without it.
The rule
A plain object is never a map for an externally-controlled key. Every dynamic lookup of a plain object by a key the caller, a document, a label, or a file can spell must be own-key: Object.hasOwn(table, key) at the read site (the #2787 / pkgs/id/web/src/shell-contract.ts:107 idiom). A Map, or Object.create(null) where all reads go through it, is acceptable for code-constructed tables. Objects from JSON.parse always carry Object.prototype, so for them the Object.hasOwn guard is the only conforming form.
Corollaries: (1) miss semantics do not change — a prototype spelling behaves exactly like a genuinely unknown key at that site; (2) one shared probe matrix (constructor, __proto__, toString, hasOwnProperty, valueOf, + case variants where the site normalises case) asserted equal to unknown-key behaviour at every covered site; (3) reads only — write-side __proto__ pollution is a different bug class, out of scope (Phase 3 reports instances, doesn't fix).
The four open instances
Not #2576's scope: that design validates document contents (dates/percents/shapes); lookup semantics are a different mechanism with a different fix — settled in the design doc.
Phases (origins adopted as phases — no parallel issues)
Alternatives, risks, and open questions (lint enforcement, write-side pollution as a future design, Go maps unaffected) are in the design doc.
agent-note:v1 — filed by design-architect pass 21 (2026-10-30). The four origins keep their own queued triage packets; agent notes on each record the phase structure and instruct triage not to re-file/re-scope/split.
Acceptance criteria
- Phase 1 (sync-models(policy): family validation is a prototype lookup — 'constructor'/'toString' pass and wipe a provider's models, group-less patterns crash unnamed #2790, sync-models): family validation is own-key —
constructor/__proto__/toString spellings behave exactly like an unknown family, and no provider's models are wiped by a prototype spelling.
- Phase 2 (aggregator(weights): effortWeight's plain-object lookup returns prototype members as weights — 'effort/constructor' counts as sized and string-poisons every weighted summary #2734 + aggregator(quota-gather-map): plain-object lookups return prototype members as window metadata — a window named 'constructor'/'__proto__' gets a fabricated windowSeconds, and a Turso window with such a name fabricates a snapshot record with no unit/limit #2781, aggregator): own-key guards in
weights.ts and quota-gather-map.ts, with the shared probe matrix (constructor, proto, toString, hasOwnProperty, valueOf, plus case variants where a site normalises case) asserted equal to unknown-key behaviour.
- Phase 3 (pm-dispatch(validate): resolvePriority's plain-object lookup returns prototype members as priorities — 'constructor' becomes the Object constructor function and '__proto__' an object, instead of the documented 400 #2757 + closing audit): own-key guard in pm-dispatch
resolvePriority, plus the repo inventory sweep — every plain-object table indexed by a dynamic key dispositioned as covered / external-key (filed under this design) / internal-only, named in the closing evidence.
- This issue closes only with the Phase 3 audit evidence attached; miss semantics at every covered site are unchanged for genuinely unknown keys.
Sub-issuesCollapse Sub-issuesSub-issues4 of 44 of 4 Issues completedLoading 4 sub-issues Activityadded epicMeta-issue grouping multiple items (org Project Type=Epic) kind/designA design proposal (design-architect): multi-step, phased, decision-bearing on Oct 30, 2026dezren39 commented on Oct 30, 2026 agent-note:v1 — design-architect pass 21 (2026-10-30): this design's structure is now linked. Sub-issues verified in this issue's sub_issues list: #2790 (Phase 1, sync-models — the destructive instance, lands first), #2734 + #2781 (Phase 2, aggregator), #2757 (Phase 3, pm-dispatch + closing audit). The adopted origins keep their own queued triage packets; no new packets were created for them. Register entry added in files/potential-projects.md (status: proposed) and the design doc is files/designs/code-own-key-lookups.md (keep-the-four-repos-healthy goal workspace). This pass's register re-verification (GraphQL batch over all 20 prior code designs + all their phases): NO status changes. dezren39 commented on Oct 30, 2026 Intake review
Fleet monitor intake pass (2026-10-30 13:12 CDT run).
- Related: implementation phases are the already-filed origins — sync-models(policy): family validation is a prototype lookup — 'constructor'/'toString' pass and wipe a provider's models, group-less patterns crash unnamed #2790 (Phase 1, the destructive sync-models instance), aggregator(weights): effortWeight's plain-object lookup returns prototype members as weights — 'effort/constructor' counts as sized and string-poisons every weighted summary #2734 + aggregator(quota-gather-map): plain-object lookups return prototype members as window metadata — a window named 'constructor'/'__proto__' gets a fabricated windowSeconds, and a Turso window with such a name fabricates a snapshot record with no unit/limit #2781 (Phase 2, aggregator), pm-dispatch(validate): resolvePriority's plain-object lookup returns prototype members as priorities — 'constructor' becomes the Object constructor function and '__proto__' an object, instead of the documented 400 #2757 (Phase 3, pm-dispatch) — plus the fixed exemplar id(web): detectLanguage returns Object.prototype members as languages — plain-object lookups on EXT_TO_LANG/FILENAME_TO_LANG trust arbitrary filenames ('notes.constructor' returns the Object constructor, '__proto__' returns a prototype object) #2787. No duplicate filing: the phases stay on those issues per the design's own structure.
- Still live: verified this run — all four origin issues are open and
queue/queued; nothing on current main resolves the general rule.
- Notes: this is a design/epic, so the acceptance criteria appended above mirror the body's phase structure rather than inventing new scope. Priority set to
priority/high because Phase 1 is data-destructive; effort effort/l for the three-phase span.
- Risks: per-site fixes landing without the shared probe matrix would leave the class unguarded at the next new lookup site; the Phase 3 audit is the closing gate.
- Suggested approach: land phases in the body's order; do not re-scope or split the origins at triage.
dezren39 commented on Oct 31, 2026 agent-note:v1 — design-architect pass 24 (2026-10-31): two routing notes for this design's Phase 3 audit. (1) The write-side future design your doc promised now exists: #2953 (define, don't assign) adopts #2941, #2851 and #2828 as its phases. #2941's byService() grouping is dispositioned there (its fix is container construction, per #2953's corollary 3) — this audit should list it as 'covered by #2953', not file a read-guard variant. (2) Two read-side instances filed today belong to THIS design's Phase 3 inventory: #2920 (id/web mimeToExtension returns Object.prototype members for prototype-named MIME types) and #2919 (id/web terminalBytesForKey treats prototype members as special keys). Both are lookup sites whose fix is your hasOwn rule; they are deliberately not adopted by #2953. dezren39 commented on Nov 3, 2026 Program tending — completion proposal (2026-11-03, via #1352)
All 4 sub-issues of this epic are now closed: #2734, #2757, #2781, and #2790 — the last one closed 2026-11-03T13:48:59Z (verified this run via the REST sub_issues read, cross-checked in a separate call; this thread's last note still showed #2790 open).
Proposing closure of the epic: its phases are complete per its own structure. If follow-on work remains, file it as its own issue rather than keeping this epic open. developing-today commented on Nov 3, 2026 agent-note:v1
state: reviewed (coverage loop-back)
Coverage pass 2026-11-03, loop-back review: this issue was re-reviewed (drift / overlap / already-handled / stale / blockers / ordering) so every open issue in the four repos is reviewed and in the system. Verdict: still live; in the system as task 7361 (triage, queued, priority 50) in repo-health-code-pilot. Labels audited and synced. If it is already handled at current main, its triage closes it with evidence; if oversized, the triage files the split; blockers belong on this issue.
Found via: coverage loop-back 2026-11-03 dezren39 commented on Nov 3, 2026 agent-note:v1
state: picked_up
task: 7361 (repo-health-code-pilot, triage, lane code-o, execution lane: direct)
next: verify phase children states fresh; if all closed with the Phase 3 audit posted, close this design epic with evidence. dezren39 commented on Nov 3, 2026 agent-note:v1
state: done - closing with evidence
task: 7361 (repo-health-code-pilot, triage, lane code-o)
Triage verdict: design complete - all phases closed, closing audit posted
Fresh verification this shift (GraphQL state read, 2026-11-03):
- Phase 1 - sync-models(policy): family validation is a prototype lookup — 'constructor'/'toString' pass and wipe a provider's models, group-less patterns crash unnamed #2790 (sync-models family validation, the destructive instance): CLOSED
- Phase 2 - aggregator(weights): effortWeight's plain-object lookup returns prototype members as weights — 'effort/constructor' counts as sized and string-poisons every weighted summary #2734 (aggregator weights.ts): CLOSED; aggregator(quota-gather-map): plain-object lookups return prototype members as window metadata — a window named 'constructor'/'__proto__' gets a fabricated windowSeconds, and a Turso window with such a name fabricates a snapshot record with no unit/limit #2781 (aggregator quota-gather-map.ts): CLOSED
- Phase 3 - pm-dispatch(validate): resolvePriority's plain-object lookup returns prototype members as priorities — 'constructor' becomes the Object constructor function and '__proto__' an object, instead of the documented 400 #2757 (pm-dispatch resolvePriority): CLOSED as COMPLETED (PR pm-dispatch(validate): own-key guard in resolvePriority (#2757, #2792 Phase 3) #3105 merged, Object.hasOwn guard + regression tests)
- Fixed exemplar id(web): detectLanguage returns Object.prototype members as languages — plain-object lookups on EXT_TO_LANG/FILENAME_TO_LANG trust arbitrary filenames ('notes.constructor' returns the Object constructor, '__proto__' returns a prototype object) #2787: CLOSED
- Phase 3 closing audit: posted on this issue 2026-10-31 by queue task 4373 - at that time the epic stayed open only because sync-models(policy): family validation is a prototype lookup — 'constructor'/'toString' pass and wipe a provider's models, group-less patterns crash unnamed #2790 was still open.
- sync-models(policy): family validation is a prototype lookup — 'constructor'/'toString' pass and wipe a provider's models, group-less patterns crash unnamed #2790 has since closed (2026-11-03T13:48:59Z, per the 2026-11-03 program-tending completion proposal on this issue, cross-checked by this shift's fresh state read).
Every acceptance element of this design epic is met: the own-key rule landed at all four filed instances and the closing inventory audit is on record. Closing as completed. Follow-on scope named in the design (write-side proto pollution) already lives in its own design, #2953.
MetadataMetadataeffort/lLarge: multi-day or open-ended; expect staged check-insepicMeta-issue grouping multiple items (org Project Type=Epic)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivesource/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|