Repository navigation
fix(server): keep paired devices out of sensitive folders and slow down repeated pairing requests - #545
Conversation
…wn repeated pairing requests With an access token and no allowed folders, callers could save anywhere, so a paired device or a leaked token could drop files into ~/Library/ LaunchAgents, ~/.ssh or the app's own folders. Such callers are now kept out of system folders, the user's application data, the app's data and install folders, and hidden entries, unless inside the download folder, and a new download never replaces an existing file. Pairing requests that are denied or left unanswered now make their address wait before asking again, doubling each time, and many of them pause pairing for everyone, so a device cannot prompt the owner until they tap Allow by mistake. Android's Allow notification button needs the phone unlocked.
Codex Review SummaryThis 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. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9bff0eaf47
ℹ️ 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".
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".
Pairing requests no longer pop up a dialog over whatever the owner is doing. They show as cards at the top of Settings › Sharing, the only place a device can be allowed in. Elsewhere in the app a sticky toast with Review opens Sharing, and while the app is not in front the desktop tray or an Android notification tells about them, on arrival or once the app leaves the front; tapping it opens Sharing. The Android notification keeps only Don't allow, so nobody holding a locked phone lets a device in.
…Retry-After up A file:// destination skipped the protected and hidden folder checks, and Android opens any absolute URI for writing, so a caller with the token could still overwrite the app's own files. Only content:// URIs, which reach folders the owner granted, pass now. Retry-After truncated the remaining backoff, so a device that waited as told was turned away again; it is rounded up.
Test Results 1 898 files + 483 1 925 suites +483 22m 30s ⏱️ + 5m 39s Results for commit 29ba1e5. ± Comparison against base commit bafc86e. This pull request removes 2 and adds 4314 tests. Note that renamed tests count towards both. |
Why
A review of device sharing found three ways a shared device could be misused:
allowedDirectories(always the case in the apps),DestinationGuardwas off. A paired device, or anyone holding the token, could save into~/Library/LaunchAgents,~/.ssh, the Windows Startup folder or the app's own folders, which means code execution as the user.What changed
Folders (
DestinationPathPolicy,DestinationGuard,systemProtectedDirectories())403 path_rejected:~/LibraryandAppDataketch server) and the desktop app's install folder, for portable copies~/.sshand~/.zshrcexcludedandrefuseHiddenoptions onDestinationPathPolicyare checked only below the root that holds a path. The download folder stays usable even inside a protected or hidden folder.file (1).zipinstead).content://folder URIs pass unchanged, since the app can only write to folders it was granted.KetchServer(protectedDirectories = ...)parameter.Pairing (
PairingBackoff)429 pairing_pausedwithRetry-After.RemotePairingreturns a newPairingResult.Paused, and the connect form shows a new message, translated into all ten languages.Where pairing requests are answered
PairingRequestCards), the only place a device can be allowed in.PairingNotices.follow), on arrival or once the app leaves the front. Tapping the notification opens Settings › Sharing: the desktop tray viaNotificationClick.Pairing, Android viaAndroidNotifier.opensSharing.Docs updated: AGENTS.md,
cli/README.md,docs/docker.md,docs/architecture.md.Reviewer notes
Testing
:library:core:jvmTest(newDestinationPathPolicyTestcases: exclusions, case, links, hidden entries):library:server:test(newDestinationGuardTestcases,PairingBackoffTest, pairing route test):library:remote:jvmTest(newPairingResult.Pausedtest):app:shared:jvmTest:app:desktop,:cliand:app:android(compileDirectDebugKotlin)AppStatePairingTest(toast) andPairingNoticesTest(host notifications)ConnectSnapshots.pairingRequest_asksTheOwnerWithTheCodeThe pairing window (pairing off until the owner turns it on, for 3 minutes) and the Find on local network changes came after this was merged; they are in #547.