Apps: validate Windows profile dir names and reject reserved app IDs at install (M/L)#801
Open
Rigidity wants to merge 1 commit into
Open
Apps: validate Windows profile dir names and reject reserved app IDs at install (M/L)#801Rigidity wants to merge 1 commit into
Rigidity wants to merge 1 commit into
Conversation
Windows profile directory names loaded from the database are now validated on deserialize (single safe path segment only), so a tampered storage row like ".." can no longer traverse out of the profiles directory when it is later joined and passed to remove_dir_all during storage cleanup. Installs now structurally reject app IDs that use the reserved __sage_test_ / __sage_runtime_ prefixes or collide with builtin system app IDs, instead of relying on the ID generators never producing them. Sandbox-test IDs in particular bypass the launch gate, so an installed app must never be able to claim one.
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.
Part of the security review follow-ups for #785 (Medium/Low severity, identity & storage validation theme). Targets the
appsmirror branch.Findings addressed
M:
WindowsProfile.directory_nameused without validation (types/storage.rs,lifecycle/storage.rs)The directory name stored in the database is joined onto the app data dir and passed to
remove_dir_allduring storage cleanup (and used as the webviewdata_directoryon Windows). A tampered row like".."or"..\\evil"could traverse out of the profiles directory and delete arbitrary data. Deserialization now rejects anything that isn't a single safe path segment (ASCII alphanumeric plus-/_), which covers every DB-load path while still accepting the legitimateprofile-<uuid>andbuiltin-profile-<id>names.L: reserved
__sage_test_/ system IDs aren't rejected at install (lifecycle/install.rs)Apps with the
__sage_test_prefix bypass the sandbox launch gate (sandbox/gate.rs), so an installed app must never be able to claim a reserved ID. Today the zip/url ID generators can't produce one (slugification strips underscores), but that was a coincidence rather than an invariant. Installs now explicitly reject IDs with the__sage_test_/__sage_runtime_prefixes or that exactly match a builtin system app ID.Notes
cargo clippy --all-targetsand the new unit tests pass locally; relying on CI for the full build.Note
Medium Risk
Changes guard install identity and filesystem paths used during storage cleanup—important security boundaries, but scoped validation with tests and no broad behavior refactors.
Overview
Hardens app install and persisted Windows storage handling from security review follow-ups.
Install path: Before registering a new app,
ensure_installable_app_idrejects IDs with the__sage_test_or__sage_runtime_prefixes and any ID that matches a builtin system app (e.g.task-manager). That closes a gap where reserved IDs could bypass sandbox launch rules or impersonate built-ins, even if current slug generators never produced those IDs.Windows profiles:
SageAppStorage::WindowsProfilenow deserializesdirectory_namethrough validation that only allows a single safe segment (ASCII alphanumeric plus-/_). Tampered DB values like..or paths with separators fail at load time, since those names are joined under app data and used for cleanup (remove_dir_all) and webview data dirs.RUNTIME_ID_PREFIXis exported from builtin app constants for the install check. Unit tests cover reserved-ID rejection/acceptance and serde behavior for profile names.Reviewed by Cursor Bugbot for commit 95d5ea3. Bugbot is set up for automated code reviews on this repo. Configure here.