Repository navigation
fix(id/web): validate collab AUTH_OK/NEW_VERSION frame fields (#7854) - #8712
Conversation
handleMessage shape-trusted the AUTH_OK refreshed token and the NEW_VERSION hash: a numeric/object token was adopted verbatim, persisted over the valid stored identity via String(value), and re-sent on every reconnect; a non-string hash became [object Object] in dataset.hash. Both frames now validate at the boundary (the INIT #2824 / Cursor #7873 pattern): a token is adopted only when a non-empty string, NEW_VERSION fires only for string hash and name; malformed frames are logged and dropped with current state untouched. Regression tests cover numeric/object tokens (reconnect still sends the old token) and an object hash, plus controls. collab.test.ts 38/38; full web suite 787 pass with one pre-existing search-panel failure reproduced on clean main.
|
Warning Review limit reachedYou'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 24 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #7854.
handleMessageinpkgs/id/web/src/collab.tsshape-trusted two server frames whose fields flow into persisted state:msg[3]was adopted as the refreshed token — written tocurrentToken(re-sent on every reconnect) and passed toonTokenRefresh, whosesaveIdentitypersists it viaString(value): a numeric token persisted as"12345", an object as"[object Object]", overwriting the valid stored token.msg[1]was passed unchecked toonNewVersion, whose callback writes it intodataset.hash— the value the next save posts as the document hash.Both frames now validate at the boundary, following the INIT (#2824) and CURSOR (#7873) pattern in the same switch: a refreshed token is adopted only when it is a non-empty string;
onNewVersionfires only when hash and name are strings. Malformed frames are logged and dropped, leaving the current token, the stored identity, anddataset.hashuntouched.Tests (named oracle: the frame-field validation contract): AUTH_OK with a numeric token and with an object token (assert
onTokenRefreshnever fires and the reconnect AUTH frame still carries the previous token), NEW_VERSION with an object hash (assertonNewVersionnever fires), plus the well-formed controls.Verified locally:
collab.test.ts38/38 pass. Full web suite: 787 passed, 1 failure insearch-panel.test.ts("Replace all matches" aria-label) that reproduces identically on clean main — pre-existing and unrelated.Queue task 14122, lane code-c. Issue triaged inline in the same claim (note on #7854).
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.