Repository navigation
Hush's data folder is private, files from chats get Gatekeeper's check, and pasted pictures are cleaned up - #175
Merged
Merged
Conversation
The data folder is 0700 in both apps (made so and tightened at open, Unix only). A file opened from a chat or exported with it carries the quarantine mark, so Gatekeeper checks it before it runs. Pasted pictures are removed once sent or dropped from the tray, and what a previous run left in Hush-paste goes at launch.
…the app's temp folders The mark is written directly (Launch Services' download flags, no event id), so opening an attachment leaves no row in the quarantine events database, and a file already marked keeps its mark and any Open Anyway. Exporting returns the finished folder even when a file can't be marked, marking off the main thread. Pasted pictures go only from the paste folder itself. Leftovers are cleared once the core holds the data folder, so a refused second copy can't clear the running one's. Tests swap both temp roots before clearing.
Owner
Author
|
Review findings and fixes (231df1e). There were no Critical findings. Important
Suggestions
Ruling: Linux files inside an already-0755 folder stay 0644, because the folder's 0700 stops any new lookup. Tightening every file is the owner's call. Checks: |
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.
What changed
spawn(actor.rs) sets 0700 on the folder after creating it, so a new folder starts private and an existing one is tightened the next time it opens. Unix only; on Windows the per-user app data folder's ACL already keeps other users out. If the file system won't take a mode, the core logs a warning and still opens: refusing to open wouldn't make the folder private.$TMPDIR, and the desktop app makes none.Files.quarantinewritescom.apple.quarantinewithsetxattr:0081;<hex time>;Hush;. Those are the download flags Launch Services writes itself. Gatekeeper then checks a.commandor.terminala contact sent before it runs.URLResourceValues.quarantinePropertieswould also add a lasting row to~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2on every open, which is a record of when attachments were opened.Files.openable(Quick Look, its Open With, and the audio player) quarantines the file it makes. That file is usually a hard link, and the mark lives on the inode, so the stored attachment gets it too. That does no harm: it's an attachment, not a database, and Hush only reads it. A later export also carries the mark over.files/folder, off the main thread.chat.htmlstays unmarked: Hush writes it itself and it has no script in it. Marking is best effort: a file that can't be marked is logged, and the finished export is still returned and shown.LSFileQuarantineEnabled, which would quarantine every file Hush writes (the databases and backups too) and would be harder to test.NSSavePanelwrites Hush's own encrypted file, which isn't a chat's file, so I left it alone.$TMPDIR/Hush-paste. A pasted picture is deleted once its message is sent (the core has made its own copy by then), when it's taken out of the tray, or when switching chats empties the tray. A send that fails puts it back in the tray, and it stays. A failed send after the chat was switched deletes it.Files.clearLeftovers()(formerlyclearOpened) empties bothHush-openandHush-paste. It runs inAppStore.openRealonce the core holds the data folder, so a second copy of Hush that is refused the folder can't clear the running copy's files. Only files directly in the paste folder are deleted (..is resolved first). Files chosen or dropped from the user's own folders are never deleted.temp_diruses are all in tests).Why
Closes #165. The folder was 0755 with 0644 files, so on Linux, where home folders are often 0755, other users could read the desktop app's attachments. Opened files had no quarantine mark, so a script a contact sent could run from Quick Look without a Gatekeeper check. Pasted pictures stayed in
$TMPDIRuntil the system cleaned it.How it was tested
Each test below was written first and failed before its fix:
client::tests::the_data_folder_is_ours_alone: a new folder is 0700, and a 0755 folder is 0700 again after it opens. Before the fix the mode was 0755.FilesTests.testOpenedFilesAreQuarantined: the fileopenablemakes carries the mark0081;<8 hex digits>;Hush;, and a file already marked keeps its mark.AppStoreBackupTests.testAnExportReachesTheCoreAndAFailureIsShown: the fake core now writes an export like the real one. Itsfiles/entries are quarantined andchat.htmlis not. A file that can't be marked (a dangling link) is logged, and the export is still returned with no error shown.AppStoreFilesTests.testPastedPicturesGoOnceSentOrDropped: covers sent, failed (kept), removed from the tray, a..path (kept), switching chats, a failed send after a chat switch (deleted), the user's own file (kept) and the clear-out.PasteTestsnow checks that a pasted picture is written toFiles.pasteRoot. Every test that touches these folders swaps both of them (useTemporaryRoots), so none can reach the installed app's.spctl --assess --type openrejects an unsigned script with or without a mark, so it can't show the difference.make format,make lintandcargo test -q(whole workspace) pass.LegacyTests.testSettingsAreAdoptedWithoutOverwritingNewOnes:persistentDomainreturns[:], not nil, for a removed UserDefaults domain.MessageRowTests.testRightClickOnTextClickedIntoShowsTheMessageMenu. The on-screenTimelineOpenTests.testALongChatOpensWithOnePageAtItsNewestMessagefailed in the first run and passed in the second.Not run in the real app: the owner's installed Hush was running, and its data folder was in use.