Repository navigation
Description
id(web/main): /api/identity/me, /api/identity/register and /api/identity/name responses shape-trusted — a wrong-shape 200 persists a fake 'undefined' / '[object Object]' identity in localStorage
Summary
The client identity flow in pkgs/id/web/src/main.ts uses the JSON bodies of
all three identity endpoints with no shape validation:
ensureIdentity()—const data = await resp.json();for
/api/identity/me(main.ts:148) and/api/identity/register(main.ts:185)updateDisplayName()—const data = await resp.json();for
/api/identity/name(main.ts:215)
data.token, data.client_id and data.name flow straight into
saveIdentity() (main.ts:91), which writes them to localStorage via
setItem — and Web Storage coerces non-string values with String(value).
A wrong-shape 200 therefore does not just fail one request: it persists a
corrupt identity that survives reloads and overwrites a previously valid
stored token.
Verified evidence (laptop, origin/main @1aea9b5f75)
Probe: ~/git/fleet/probe-identity-shape on the laptop — main.ts lines
63–224 extracted byte-verbatim (diff-checked against
git show origin/main:pkgs/id/web/src/main.ts, md5 f182df7ec224deda5298b8023c84da3f),
run under Bun with a spec-faithful localStorage stub (setItem coerces via
String()) and a stubbed fetch. Controls pass: a well-formed register
body registers and stores correctly, and a well-formed /me body rotates
the stored token.
Wrong-shape results:
| Scenario | Result |
|---|---|
register {} |
fake success: identity {token: undefined, clientId: undefined} returned; localStorage stores the literal strings "undefined" / "undefined"; getStoredIdentity() on the next load rehydrates {token: "undefined", clientId: "undefined"} |
register "abc" |
same fake success + "undefined" credentials persisted |
register {token: 123, client_id: {x: 1}} |
persists token "123" and client_id "[object Object]" |
register null |
raw TypeError on data.token, caught and logged as a generic registration error (returns null) |
/me {token: {evil: 1}} with a valid stored identity |
overwrites the good stored token with the literal string "[object Object]" |
/me {token: 12345} |
numeric token accepted and persisted as "12345" |
/me null |
raw TypeError, caught by the network-error branch and misreported as an identity-check failure (stored identity returned optimistically) |
/name {name: 123} |
updateDisplayName returns 123 as the name and persists "123" |
Why it matters
Identity is the credential layer for the whole web UI. A single malformed
200 — from a proxy, a partial deploy, a different server version, or a
compromised/misbehaving endpoint — permanently poisons the stored identity
until localStorage is manually cleared: the client then presents token
"undefined" / "[object Object]" on every subsequent load, and the /me
path can destroy an otherwise valid token in place. This is the same
validate-where-you-read-it gap as #7811/#7823/#7831/#7837, but worse than
the display-only cases because the bad value is persisted as a
credential.
Acceptance criteria
- Parse all three identity responses through a validating parser
(e.g. inidentity-refresh.ts, alongsideidentityNeedsRefresh):
the body must be a plain object;token/client_id, when required
or present, must be non-empty strings;namemust be a string or
null. Anything else is a failed validation/register/name update —
never a persisted value. - A wrong-shape
/me200 must not overwrite, coerce, or clear the
stored identity; a wrong-shape register 200 must not call
saveIdentityat all. - Regression tests (vitest, named oracle: the validated-parser
contract) covering at least:{},null, a bare string, a numeric
token, and an object token/client_id for register and /me, plus a
non-stringnamefor /name — each asserting localStorage is
unchanged / no identity is returned. - Existing web suites stay green (in particular
identity-refresh,
world,image-browser,image-uploadsuites).
Found by the fleet issue creator (Lane B); sibling pattern of
#7811/#7823/#7831/#7837 — different module, endpoints, and a persisted
credential sink, so filed separately.
Activity
developing-today commentedon Nov 8, 2026
🤖 Agent note · filed
resp.json()at :148/:185/:215): a wrong-shape register or /me 200 must never call saveIdentity with non-string token/client_id, so localStorage can never persist the literal strings 'undefined' or '[object Object]' as credentials (pattern: validating parsers from PR fix(id/web): validate /api/upload response shape before inserting (#7823) #7827 / id(web/image-upload): /api/upload response shape-trusted — a wrong-shape 200 inserts an image node with src undefined into the document #7823; parser home: identity-refresh.ts). Add regression tests.dezren39 commentedon Nov 10, 2026
🤖 Agent note · parked — awaiting triage
direct(row 5860)status/needs-triage. Per Queue/lane design rules: no by-id blocking by default, optional platform selector, triage separate from fixes #8097 Rule 3, fix work starts only on triaged items and triage belongs to the dedicated triage step, so this lane parks task 14019 back for the triage step (delay 1500s, stage awaiting_triage). No findings, no label changes, no follow-up enqueue from this lane.dezren39 commentedon Nov 11, 2026
agent-note:v1
state: triaged
task: 14019
lane: code-b (repo-worker-code)
Inline triage (runbook 1c): work kind small-fix (task/small-fix, already on issue #7839); priority/normal (a wrong-shape 200 silently persists a fake identity — bad, but requires a misbehaving/compromised endpoint, so not expedited); effort/s (effort/s already on issue); kind/bug already present. status/needs-triage removed; fix proceeds in this same claim.
Verified live at current main 56cf191: pkgs/id/web/src/main.ts lines 148/185/215 still call resp.json() unguarded; data.token/data.client_id/data.name flow into saveIdentity which String()-coerces into localStorage. No open PR owns this (search 7839: none).
First step: add validating parsers in identity-refresh.ts (home of identityNeedsRefresh; pattern parseUploadResponse), route all three endpoints through them, fail closed through existing error paths, never saveIdentity on a wrong-shape body.
Acceptance: regression tests for {}, null, bare string, numeric/object token and client_id (register + /me) and non-string name (/name), asserting localStorage unchanged / no identity returned; pkgs/id web suite + typecheck green.
dezren39 commentedon Nov 11, 2026
agent-note:v1
state: pr_opened
task: 14019
lane: code-b (repo-worker-code)
PR #8505 opened (head c26fce3, branch queue/14019-7839-identity-response-validation): validating parsers parseIdentityMeResponse / parseIdentityRegisterResponse / parseIdentityNameResponse added in identity-refresh.ts; all three fetch sites in main.ts routed through them — a wrong-shape 200 now fails through the existing error paths and never reaches saveIdentity/updateStoredName.
Tests: identity-refresh.test.ts 15/15 pass (10 new regression tests: {}, null, bare string, array, numeric/object token and client_id, empty token, non-string name); tsc --noEmit clean; full pkgs/id web suite 720 passed with 1 pre-existing failure (search-panel.test.ts, verified failing identically on clean main) and 1 flake (tags.test.ts, passes in isolation on both trees).
test(id/web): add property coverage for identity response parsers (#7839
Merge pull request #8505 from developing-today/queue/14019-7839-ident…
dezren39 commentedon Nov 11, 2026
state: done (already_done — verified merged)
task 14019 (small_fix) — issue #7839 / PR #8505 — lane tmp-code-y, 2026-11-11
Claimed task 14019 and re-verified fresh before any work: PR #8505 is MERGED (mergedAt 2026-11-11T04:00:25Z, merge commit 52f7965, merged head 1f01c77) and issue #7839 is CLOSED. Codex review on the merged head completed with no findings. The merge landed after this task's last checkpoint (pr_opened) via the standing merge path, so no further work was needed from this lane.
Terminal: task 14019 completed with outcome already_done on this evidence. Stale in-flight labels (status/in-progress, queue/claimed, work/assigned) removed from the closed issue in the same pass.