LearnNewsExamplesServices
Frontmatter
id14728
titleHarden fleet closed-set token resolvers against prototype-shaped keys (hasOwn)
stateClosed
labels
bugaiarchitecture
assigneesneo-opus-vega
createdAt11:27 AM
updatedAt1:39 PM
githubUrlhttps://github.com/neomjs/neo/issues/14728
authorneo-opus-vega
commentsCount0
parentIssue14560
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAt1:39 PM

Harden fleet closed-set token resolvers against prototype-shaped keys (hasOwn)

Closed Backlog/active-chunk-3 bugaiarchitecture
neo-opus-vega
neo-opus-vega commented on 11:27 AM

Problem

The fleet cockpit primitive token resolvers use the MAP[key] || fallback idiom, which is not a closed set: a prototype-shaped key (toString, constructor, hasOwnProperty, __proto__) resolves to the inherited Object.prototype member (truthy) instead of the intended fallback, leaking a broken value (a function) into the rendered --fm-* custom property.

@neo-fable reproduced this on familyToken in the #14722 pre-review; it is systemic across the sibling resolvers:

  • kindToken / kindLabel — apps/agentos/view/fleet/kindRegistry.mjs (from #14701)
  • stateLabel — apps/agentos/view/fleet/HealthSwatch.mjs (from #14637)
  • stateToken — apps/agentos/view/fleet/StateDot.mjs (merged, #14593)

familyToken (#14722, FamilyRail.mjs) is already fixed — it delegates to the hasOwn-guarded isKnownFamily.

The fix

Each resolver: return Object.hasOwn(MAP, key) ? MAP[key] : fallback (or delegate to a hasOwn-guarded isKnown* predicate), so the closed set stays closed by construction.

Acceptance criteria

  • kindToken, kindLabel, stateLabel, stateToken guard the map lookup with Object.hasOwn (no MAP[k] || map-membership).
  • Regression assertions per resolver: toString / constructor / __proto__ resolve to the neutral/fallback (token) or literal (label), never an inherited member.
  • One PR after #14701 / #14637 merge (all three files then live on dev) — a single coherent closed-set-hardening change.

Out of scope

familyToken (#14722, already hardened) · any new resolver (the pattern is the guard, not the map).

Notes

Low real-world likelihood (the maps are fed by the DTO's known vocabulary, not arbitrary input) — this is correctness-by-construction robustness, not a live exploit. Durable lesson: a MAP[key] || fallback lookup is not a closed set.

tobiu referenced in commit 4a77b1b - "fix(agentos): kindRegistry resolvers guard the closed set against prototype-shaped keys (#14728) (#14737) on 1:39 PM
tobiu closed this issue on 1:39 PM