fix(desktop): reject unsafe imported session IDs - #743
Open
imMamdouhaboammar wants to merge 1 commit into
Open
Conversation
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.
Problem
Desktop session persistence uses the session ID as the filename under
temp/desktop_sessions/. Generated IDs are safe, but imported session JSON can supply a different ID.Without validation, an imported ID can either resolve outside the session store or normalize to the same file as a different session ID. Examples include
../../escape, absolute paths, and aliases such asnested/../sess-safe123.The alias case is an integrity bug even when the normalized target stays inside the store: duplicate detection compares the raw IDs, so the alias can be accepted as a second session and overwrite the first session's JSON file.
Fix
/or\_session_file()as a second containment checkGenerated session IDs and normal imported IDs keep the existing format and behavior.
Verification
TDD was run on a separate validation branch before the clean contribution commit:
31161662002failed exactly on the../../escapecase while the valid-session case passed31162056903, then persisted-state run31162136988passednested/../sess-safe123: run31162487893failed only on that alias case3116258552831162679798passed all 5 final security/compatibility casessys.pathand cross-test filesystem state; run31164041346passed compile, all regressions, andgit diff --checkFinal regression coverage includes traversal IDs, absolute IDs, normalized aliases, Windows-style path separators, and a normal safe session ID.
Scope
mainA separate review observation about deterministic session temp-file writes racing under concurrency was verified as pre-existing in base
main, not introduced by this patch. It is intentionally kept out of this imported-ID boundary fix and should be addressed independently.