You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Symlink following in file deletion enables arbitrary file destruction #25
CleaningEngine.cleanItems() and ScanEngine.scanDirectory() do not resolve symlinks before deleting files. A symlink planted in any scanned directory (e.g. ~/Library/Caches/) can redirect deletion to arbitrary user-accessible paths like ~/.ssh/, ~/Documents/, or ~/.gnupg/.
Steps to reproduce
# 1. Create a symlink in a scanned cache directory
ln -s ~/.ssh ~/Library/Caches/fake-cache-entry
# 2. Run PureMac → Smart Scan# 3. The symlink appears as a scannable cache item (auto-selected)# 4. Click "Clean" → ~/.ssh is deleted
Impact
Any process running as the current user — malware, a rogue npm postinstall script, or even a cron job — can plant symlinks before a scheduled auto-clean runs. Combined with autoClean: true in SchedulerService, this becomes a zero-interaction attack that silently destroys targeted files.
Services/ScanEngine.swift:302-347 — scanDirectory() doesn't check for symlinks
Suggested fix
Before any deletion, resolve the real path and verify it's still inside the expected scan root:
// Add to CleaningEngine, call before every removeItem
privatefuncisSafeToDelete(path:String,allowedRoots:[String])->Bool{letresolved=URL(fileURLWithPath:path).resolvingSymlinksInPath().path
// Reject if the resolved path escapes all allowed roots
returnallowedRoots.contains{rootinresolved.hasPrefix(root)}}
Each scan category already knows its root paths — pass them through to the cleaning engine and validate before deletion.
Additionally, in scanDirectory(), check FileManager.attributesOfItem(atPath:)[.type] for .typeSymbolicLink and either skip or flag symlinks to the user rather than treating them as normal cache entries.
Valid finding. This is a real attack vector — especially dangerous combined with autoClean: true in SchedulerService since it becomes zero-interaction.
Plan:
ScanEngine — skip symlinks in scanDirectory() by checking FileAttributeType.typeSymbolicLink:
Hey @0x-man! You're credited in the v2.0 README under the Acknowledgments section for your symlink security report. That was a critical find that made PureMac significantly safer. Thank you!
Activity
momenbasel commentedon Apr 14, 2026
Valid finding. This is a real attack vector — especially dangerous combined with
autoClean: trueinSchedulerServicesince it becomes zero-interaction.Plan:
scanDirectory()by checkingFileAttributeType.typeSymbolicLink:CleaningCategoryalready defines its scan paths — those become the allowlist passed to the cleaning engine.Prioritizing this. Will tag the fix PR with this issue.
momenbasel commentedon Apr 14, 2026
Hey @0x-man! You're credited in the v2.0 README under the Acknowledgments section for your symlink security report. That was a critical find that made PureMac significantly safer. Thank you!
security: fix symlink-following attack in file deletion
security: fix symlink-following attack in file deletion