Repository navigation
fix(core): draw 64-bit session ids so a pruned id is not reused - #445
Merged
Merged
Conversation
Session ids now carry 8 random bytes. After prune frees an id, a new session practically never draws it again, so a stalled caller cannot act on a new session by its old id. Records with 8-hex ids still read, update and destroy. Refs #413.
…descriptor Clients checked and connected to host.sock by its full path. With 16-hex session ids, a session home of 60 bytes or more pushed that path past the 107-byte socket path limit, so requests failed with EINVAL. Clients now check the socket identity and connect through one verified viewer directory descriptor, as the host binds it. Refs #413.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #413
Closes #376
New session ids carry 8 random bytes (16 hex characters) instead of 4. A new session drawing one specific id freed by
session prunenow has a chance of 2^-64 per creation, so a stalled caller cannot act on a new session through its old id. Records with 8-hex ids from before this change still read, update and destroy.The generation binding the issue first proposed was dropped. The council found that every check-then-mutate path (update, destroy, stop input) still raced a reuse, so it narrowed the window without closing it.
The longer id makes
viewer/host.sock8 bytes longer. Clients now connect to the native viewer host through/proc/self/fd/<fd>/host.sockon a verified handle to its directory, so the path length no longer matters. This also fixes #376. Every #404 identity check on the socket is unchanged and now runs on that same descriptor path. Requests, subscriptions and pulses all connect this way.Traceability
randomBytes(8); unit test on all four session types<prefix>-[0-9a-f]{16}~/.pickforge/investigations/413/ids/before-old-source.log,vitest-core.logdesk-1a2b3c4drecord~/.pickforge/investigations/413/ids/vitest-core.log~/.pickforge/investigations/413/ids/qa-short-label.png,qa-long-label.png,titles.txthost.sockis connected by Pickforge, fixed below; app-made sockets unchanged in kind~/.pickforge/investigations/413/ids/path-table.mdnative-viewer-host.test.ts"serves a request, a subscription and a pulse when the socket path passes the limit"~/.pickforge/investigations/413/socket/before-long-home.log,after-long-home.logwatchopens the native viewerPICKFORGE_HOMEwatchwith no browser fallback~/.pickforge/investigations/413/socket/qa/qa-root.png,sessions.txt,watch-longhome.log~/.pickforge/investigations/413/socket/vitest-focused.logsession create --no-viewerandsession destroywith an 84-byte home~/.pickforge/investigations/413/socket/long-home-create.logfull-suite.shat 0ea478a~/.pickforge/investigations/413/full3/pickcheck check --base origin/main --fail-on new,worsened,unmatched; gitleaks on the branch commits~/.pickforge/investigations/413/full3/pickcheck.jsonReview
Council, three seats per round.
Round 2 found the
host.sockconnect limit and a stale 32-bit comment; both are fixed in 45efb80 and 0ea478a. Round 3 left three nits, accepted without a repair round: a missing or symlinked viewer directory reports the run storage wording fromDirHandle, a refused connect names the/proc/self/fdpath, and the long-home test covers success, while the shared refusal checks run under a short home.A socket swapped at
host.sockbetween the identity check and connect is still reached, as before this change. Requests and subscriptions refuse it when the reply does not match the recorded host.