Skip to content

Free, open-source macOS cleaner. CleanMyMac alternative with zero telemetry. Native SwiftUI, scheduled auto-cleaning, Xcode/Homebrew/system cache cleanup. MIT licensed.

withdraw app-bundle modification; deny cloud provider paths; bump 2.9.5

momenbaselbe2ec797156b
diff --git a/PureMac.xcodeproj/project.pbxproj b/PureMac.xcodeproj/project.pbxproj
index b9a48ae..a60ee19 100644
--- a/PureMac.xcodeproj/project.pbxproj
+++ b/PureMac.xcodeproj/project.pbxproj
@@ -59,6 +59,7 @@
EDEF28CAD23E936FBED1783B /* PureMacApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63581B70F9B10231964E3602 /* PureMacApp.swift */; };
F1F506C146E17D6CEC4A12F3 /* AppInfoFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23486A54A82EE3865B784D1C /* AppInfoFetcher.swift */; };
F2FA881A4B2209CC2A6342FB /* CLI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01B2C5F66B6D812572BD4F05 /* CLI.swift */; };
+ FBEE9208E222616A8DF1FE75 /* ProviderPaths.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AFB912A9A6CFDCB972E978F /* ProviderPaths.swift */; };
FDA30FE6349CA01C8D859F04 /* OrphanListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B71E8F62DB76D85F41F9A2E9 /* OrphanListView.swift */; };
/* End PBXBuildFile section */
@@ -110,6 +111,7 @@
7953B398E47A4C603DE287F1 /* FileProtection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProtection.swift; sourceTree = "<group>"; };
798B80977D14647A5691B0A0 /* AppFilesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppFilesView.swift; sourceTree = "<group>"; };
82BB0904726B38DEB141BECA /* AppLanguage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLanguage.swift; sourceTree = "<group>"; };
+ 8AFB912A9A6CFDCB972E978F /* ProviderPaths.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProviderPaths.swift; sourceTree = "<group>"; };
8CE522B406791BCE905BC55B /* FileSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileSize.swift; sourceTree = "<group>"; };
8D5E63D733D1A3BDEDF4DCA5 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
913E3064AA9BD7BE94A315CF /* MenuBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuBarController.swift; sourceTree = "<group>"; };
@@ -294,6 +296,7 @@
8CE522B406791BCE905BC55B /* FileSize.swift */,
5785762276FB5E3209C6DE4D /* Logger.swift */,
4AE790496C936424EF98320A /* OrphanSafetyPolicy.swift */,
+ 8AFB912A9A6CFDCB972E978F /* ProviderPaths.swift */,
);
path = Utilities;
sourceTree = "<group>";
@@ -483,6 +486,7 @@
A9C3A1F643C26930F442E729 /* OrphanSafetyPolicy.swift in Sources */,
6E72022A661CBB41331A442C /* PermissionCoordinator.swift in Sources */,
61D285E96DED76FDCD54570F /* PermissionSheet.swift in Sources */,
+ FBEE9208E222616A8DF1FE75 /* ProviderPaths.swift in Sources */,
EDEF28CAD23E936FBED1783B /* PureMacApp.swift in Sources */,
D9445C2641A8637B65DA5ACE /* ScanEngine.swift in Sources */,
D50EB059E741011EB2523731 /* ScanError.swift in Sources */,
@@ -598,7 +602,7 @@
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = PureMac/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 13.0;
- MARKETING_VERSION = 2.9.3;
+ MARKETING_VERSION = 2.9.4;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
@@ -716,7 +720,7 @@
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = PureMac/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 13.0;
- MARKETING_VERSION = 2.9.3;
+ MARKETING_VERSION = 2.9.4;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
diff --git a/PureMac/Logic/Utilities/ProviderPaths.swift b/PureMac/Logic/Utilities/ProviderPaths.swift
new file mode 100644
index 0000000..10b1073
--- /dev/null
+++ b/PureMac/Logic/Utilities/ProviderPaths.swift
@@ -0,0 +1,64 @@
+import Foundation
+
+/// Hard denylist for cloud File Provider state (issue #142).
+///
+/// iCloud Drive, and every other provider that plugs into FileProvider.framework,
+/// keeps a database of what it believes is on disk. Removing a file underneath it
+/// with `unlink` does not tell the provider anything, so its snapshot and the
+/// filesystem drift apart. `fileproviderctl check` then reports invariants like
+/// `is_on_disk_but_not_in_FS_Snapshot`, and Finder copies out of iCloud Drive slow
+/// from instant to tens of seconds because every read goes through reconciliation.
+/// A user reported exactly this after one cleanup: 513 of 19693 files broken, and
+/// the live service rebuilt the inconsistent state ~10s after each repair.
+///
+/// These directories are implementation detail owned by `bird`, `cloudd`, and
+/// `fileproviderd`. They are never junk, they are never safe to reclaim, and no
+/// amount of space saved justifies corrupting a user's cloud sync state.
+enum ProviderPaths {
+
+ /// Roots that must never be scanned, offered, or deleted. Any path equal to
+ /// or beneath one of these is off limits.
+ static var deniedRoots: [String] {
+ let home = FileManager.default.homeDirectoryForCurrentUser.path
+ return [
+ // iCloud Drive user-visible root and its per-app containers.
+ "\(home)/Library/Mobile Documents",
+ // Third-party providers (Dropbox, OneDrive, Google Drive, ...).
+ "\(home)/Library/CloudStorage",
+ // FileProvider framework state and per-provider domains.
+ "\(home)/Library/Application Support/FileProvider",
+ "\(home)/Library/Application Support/CloudDocs",
+ // Provider extension containers.
+ "\(home)/Library/Daemon Containers",
+ // Live databases, not reclaimable caches, despite living in Caches.
+ "\(home)/Library/Caches/CloudKit",
+ "\(home)/Library/Caches/com.apple.bird",
+ "\(home)/Library/Caches/com.apple.cloudkit",
+ "\(home)/Library/Caches/com.apple.cloudd",
+ "\(home)/Library/Caches/com.apple.FileProvider",
+ ]
+ }
+
+ /// True when `path` is inside provider-owned state and must be left alone.
+ ///
+ /// The check runs against both the literal path and its symlink-resolved
+ /// form. That second pass matters: with "Desktop & Documents Folders" sync
+ /// enabled, `~/Desktop` and `~/Documents` resolve into
+ /// `~/Library/Mobile Documents/com~apple~CloudDocs`, so an innocuous-looking
+ /// root can walk straight into iCloud state.
+ static func isProviderOwned(_ path: String) -> Bool {
+ let candidates = [
+ (path as NSString).standardizingPath,
+ URL(fileURLWithPath: path).resolvingSymlinksInPath().path,
+ ]
+ for candidate in candidates {
+ // Any component of the form `com~apple~CloudDocs` (or any other
+ // provider domain) marks provider territory regardless of location.
+ if candidate.contains("com~apple~") { return true }
+ for root in deniedRoots where candidate == root || candidate.hasPrefix(root + "/") {
+ return true
+ }
+ }
+ return false
+ }
+}
diff --git a/PureMac/Models/Models.swift b/PureMac/Models/Models.swift
index 4101fc9..d08b30e 100644
--- a/PureMac/Models/Models.swift
+++ b/PureMac/Models/Models.swift
@@ -85,15 +85,34 @@ enum CleaningCategory: String, CaseIterable, Identifiable, Codable {
// be inaccurate. We still SHOW it in the storage breakdown for
// transparency, but we never present it as junk PureMac can delete.
// Honest > impressive.
+ // `appModifying` is excluded too — see the note on that property. Both of
+ // those categories are withdrawn as of 2.9.5 and must not be scanned,
+ // surfaced, or selectable anywhere in the UI.
static var scannable: [CleaningCategory] {
- allCases.filter { $0 != .smartScan && $0 != .purgeableSpace }
+ allCases.filter {
+ $0 != .smartScan && $0 != .purgeableSpace && !appModifying.contains($0)
+ }
}
// Categories that rewrite app bundles in place (binary thinning,
- // localization stripping) instead of deleting junk. Their items always
- // start unselected, and the scheduled autoClean path skips them
- // entirely — re-signing every installed app is never an unattended
- // action.
+ // localization stripping) instead of deleting junk.
+ //
+ // WITHDRAWN in 2.9.5 (issues #135, #144). Both mutate a third-party
+ // bundle and then ad-hoc re-sign it, which cannot preserve the vendor's
+ // Developer ID or notarization — that is cryptographic fact, not a bug
+ // that can be patched. Worse, `codesign --deep` does not descend into
+ // Contents/Resources, so a Mach-O there keeps the vendor signature while
+ // the outer bundle becomes ad-hoc; dyld then refuses to load the pair
+ // ("different Team IDs") and the app dies before showing UI. Users lost
+ // 21 bundles in a single run. `codesign --verify --deep --strict` cannot
+ // detect this because it checks seal consistency, not runtime Team-ID
+ // compatibility.
+ //
+ // The cases stay in the enum for Codable compatibility with persisted
+ // scan results, but `scannable` no longer includes them, so nothing
+ // reaches BinaryThinner. See also the unconditional refusal in
+ // BinaryThinner.stagedModify, which makes any replayed or persisted item
+ // list inert.
static var appModifying: Set<CleaningCategory> {
[.universalBinaries, .languageFiles]
}
diff --git a/PureMac/Services/BinaryThinner.swift b/PureMac/Services/BinaryThinner.swift
index cd23559..351efa1 100644
--- a/PureMac/Services/BinaryThinner.swift
+++ b/PureMac/Services/BinaryThinner.swift
@@ -152,6 +152,30 @@ actor BinaryThinner {
appPath: String,
appName: String,
modify: (String) throws -> Int64
+ ) -> Result<Int64, Error> {
+ // WITHDRAWN in 2.9.5 (issues #135, #144). Every caller of this method
+ // ad-hoc re-signs a third-party bundle, and no signature gate can make
+ // that safe: `codesign --deep` skips Contents/Resources, so a Mach-O
+ // there keeps its vendor Developer ID while the outer bundle turns
+ // ad-hoc, and dyld kills the process for the Team-ID mismatch.
+ //
+ // `CleaningCategory.scannable` already excludes both app-modifying
+ // categories, so nothing should reach here. This refusal is the second
+ // layer: a persisted scan result decoded from an older build, or a
+ // replayed item list, must also be inert. Remove it only together with
+ // a re-signing strategy that preserves the vendor's authority.
+ Logger.shared.log(
+ "Refusing to modify app bundle at \(appPath): bundle modification is withdrawn (issues #135, #144)",
+ level: .warning
+ )
+ return .failure(ThinningError.signatureProtected(appName))
+ }
+
+ /// Retained for the eventual safe implementation; see `stagedModify`.
+ private func stagedModifyUnsafe_disabled(
+ appPath: String,
+ appName: String,
+ modify: (String) throws -> Int64
) -> Result<Int64, Error> {
if hasRestrictedEntitlements(appPath) {
return .failure(ThinningError.restrictedEntitlements(appName))
@@ -329,8 +353,12 @@ actor BinaryThinner {
private func hasProtectedSignature(_ appPath: String) -> Bool {
// `codesign -d` prints the signature summary to stderr.
let result = runProcess("/usr/bin/codesign", ["-dvv", appPath])
- // Unsigned bundle: no trust to protect, safe to thin.
- guard result.status == 0 else { return false }
+ // FAIL CLOSED. A non-zero exit is not proof the bundle is unsigned —
+ // it also covers a spawn failure (runProcess returns status -1), a
+ // read error, or a bundle format codesign cannot parse. Treating any
+ // of those as "unsigned, safe to mutate" is how a Developer ID app
+ // gets ad-hoc re-signed. If we cannot prove it is unsigned, protect it.
+ guard result.status == 0 else { return true }
let info = result.stdout + result.stderr
// An already ad-hoc bundle has nothing Gatekeeper would have trusted,
// so re-thinning + re-ad-hoc-signing leaves it no worse off.
diff --git a/PureMac/Services/CleaningEngine.swift b/PureMac/Services/CleaningEngine.swift
index 18b46b1..8ab11c1 100644
--- a/PureMac/Services/CleaningEngine.swift
+++ b/PureMac/Services/CleaningEngine.swift
@@ -432,6 +432,19 @@ actor CleaningEngine {
/// allow-listed - scanLargeFiles emits per-file items instead, so those
/// deletions can still happen through the explicit per-item flow.
private func isSafeToDelete(resolvedPath: String) -> Bool {
+ // Cloud File Provider state is never deletable, whatever category asked
+ // and whichever allowed root it happens to sit under (issue #142).
+ // Checked before the allowlist because several provider directories live
+ // inside ~/Library/Caches and ~/Library/Application Support, which are
+ // themselves allowed roots.
+ if ProviderPaths.isProviderOwned(resolvedPath) {
+ Logger.shared.log(
+ "Refusing to delete cloud provider state: \(resolvedPath)",
+ level: .warning
+ )
+ return false
+ }
+
let home = fileManager.homeDirectoryForCurrentUser.path
let allowedRoots = [
"\(home)/Library/Caches",
diff --git a/PureMac/Services/ScanEngine.swift b/PureMac/Services/ScanEngine.swift
index ea0c1c5..37d366f 100644
--- a/PureMac/Services/ScanEngine.swift
+++ b/PureMac/Services/ScanEngine.swift
@@ -132,12 +132,14 @@ actor ScanEngine {
private func scanUserCache() -> CategoryResult {
var items: [CleanableItem] = []
- // Exclude cache roots claimed by dedicated categories to avoid double-counting.
- let excludedRootPaths = Set([
+ // Exclude cache roots claimed by dedicated categories to avoid double-counting,
+ // plus cloud File Provider state, which lives under Caches but is a live
+ // database rather than reclaimable junk (issue #142).
+ let excludedRootPaths = Set(([
"\(home)/Library/Caches/Homebrew",
"\(home)/Library/Caches/com.electron.ollama",
"\(home)/Library/Caches/ollama",
- ].map(normalizePath))
+ ] + ProviderPaths.deniedRoots).map(normalizePath))
// Dynamically enumerate ~/Library/Caches/ so every subdirectory is visible
let cachePath = "\(home)/Library/Caches"
diff --git a/project.yml b/project.yml
index ab5d5ee..04f9117 100644
--- a/project.yml
+++ b/project.yml
@@ -23,8 +23,8 @@ settings:
CODE_SIGN_ENTITLEMENTS: "PureMac/PureMac.entitlements"
INFOPLIST_FILE: "PureMac/Info.plist"
PRODUCT_BUNDLE_IDENTIFIER: "com.puremac.app"
- MARKETING_VERSION: "2.9.4"
- CURRENT_PROJECT_VERSION: "24"
+ MARKETING_VERSION: "2.9.5"
+ CURRENT_PROJECT_VERSION: "25"
GENERATE_INFOPLIST_FILE: "NO"
ASSETCATALOG_COMPILER_APPICON_NAME: "AppIcon"
COMBINE_HIDPI_IMAGES: "YES"