Skip to content

fix(id/web): validate UPDATE and CURSOR frame fields in collab handleMessage (#7873) - #8507

Closed
dezren39 wants to merge 1 commit into
mainfrom
queue/14189-7873-collab-validate
Closed

dezren39 wants to merge 1 commit into
mainfrom
queue/14189-7873-collab-validate

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Closes #7873.

handleMessage in pkgs/id/web/src/collab.ts now validates the UPDATE and CURSOR frame families at the boundary, like the INIT hardening (#2824) already did:

Tests (7 new in collab.test.ts, in the existing FakeWebSocket harness style): each malformed frame from the issue's probe set is dropped with the editor/session intact (socket stays open, no reconnect socket after timers advance, no cursor stored), a following valid frame still applies, and well-formed CURSOR/CURSOR_REMOVE controls keep working.

  • collab.test.ts: 31/31 pass
  • Full pkgs/id/web vitest suite: 718 passed / 1 failed / 9 skipped — the one failure (search-panel role=search accessibility) fails identically on pristine main and is unrelated to this change
  • bun run typecheck: clean

Out of scope per the issue family split: server-side step validation (#1618), INIT mode (#7859), AUTH_OK/NEW_VERSION fields (#7854).


🤖 agent-note:v1 — queue task 14189 (lane code-g).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 03:52
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b8964a54-05bc-4fb3-8ed4-c46f168c7913
Commits

Reviewing files that changed from the base of the PR and between 786ee93 and 427f75c.

Files selected for processing: 2

  • pkgs/id/web/src/collab.test.ts
  • pkgs/id/web/src/collab.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T03:54:23.586502Z 1616580 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…Message (#7873)

The collab socket is a trust boundary, but handleMessage shape-trusted
the UPDATE and CURSOR families: a malformed UPDATE threw inside the
step-apply try and was misclassified as desync (close 4001 +
reconnect churn), and a malformed CURSOR was stored verbatim in
plugin state, feeding NaN positions into decoration/coords code.

- UPDATE: drop the frame (log + return, session intact) when steps
  is not an array, clientIDs is not an array, their lengths differ,
  or a step fails Step.fromJSON parsing. Step parsing now happens in
  its own try before the apply try, so only genuine apply failures of
  well-shaped steps take the existing reconnect path.
- CURSOR: drop when clientID is not a string/number, head/anchor are
  not finite numbers, or name is present and not a string/null.
  idleSecs is advisory: ignored unless a finite number.
- CURSOR_REMOVE: drop when clientID is not a string/number.

Seven regression tests in collab.test.ts cover each malformed frame
(dropped with editor/session intact — no close, no new socket, no
cursor stored) and that a following valid frame still applies. The
prose in #7873's probe (malformed UPDATE teardown, phantom cursor)
is now pinned as fixtures.

collab.test.ts: 31/31 pass. Full web suite: 718 passed, 1 failed —
search-panel role=search accessibility, failing identically on
pristine main (pre-existing, unrelated). Typecheck clean.
@dezren39

Copy link
Copy Markdown
Member Author

Agent note — task 17221 done: already landed, closing PR #8507 (lane any-c)

This PR's change is already on main as commit cad4e14 — "fix(id/web): validate UPDATE and CURSOR frame fields in collab handleMessage (#7873)", the same subject as this PR — and issue #7873 was CLOSED at 2026-11-11T10:58:02Z. Verified fresh 2026-11-14 against current main:

Closing as already-landed/superseded per task 17221 acceptance. No Codex findings on this PR; no hard-stop labels. The head branch is left in place (not deleted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant