Time-of-check to time-of-use (TOCTOU) vulnerability in file deletion logic, allowing symlink-based allow-list bypass.
Raw Developer Origin & Technical Request
GitHub Issue
Apr 16, 2026
### Summary
`CleaningEngine.cleanItems` resolves symlinks once for the allow-list check but calls `removeItem(atPath: item.path)` on the ORIGINAL (unresolved) path. An attacker at the same UID who wins the race swaps an intermediate path component to a symlink → `removeItem` follows it and deletes outside the allow-list. The `cb813ab` fix did not close this variant.
### Location
`PureMac/Services/CleaningEngine.swift` lines 30-42
### Evidence (runtime)
```
[check] resolved=.../Library/Caches/MyApp/sub/id_ed25519
[check] isSafe=true
[attacker] swapping intermediate component 'sub' → symlink to .../.ssh
[before] .../.ssh/id_ed25519 exists = true
[remove] removed: .../Library/Caches/MyApp/sub/id_ed25519
[after] .../.ssh/id_ed25519 exists = false ← deleted through the swapped symlink
```
### Impact
Arbitrary user-file deletion outside the allow-list — `~/.ssh/*`, `~/.aws/*`, `~/.config/*`, etc.
### Fix
Use the resolved URL at delete time and re-verify right before the call:
```swift
let itemURL = URL(fileURLWithPath: item.path)
guard fileManager.fileExists(atPath: item.path) else { continue }
let resolvedURL = itemURL.resolvingSymlinksInPath()
let resolved = resolvedURL.path
guard isSafeToDelete(resolvedPath: resolved) else { /* log + skip */; continue }
let reResolved = URL(fileURLWithPath: item.path).resolvingSymlinksInPath().path
guard reResolved == resolved else { /* log + skip */; continue }
try fileManager.removeItem(at: resolvedURL)
```
The residual race (attacker ...
Developer Debate & Comments
No active discussions extracted for this entry yet.
Adjacent Repository Pain Points
Other highly discussed features and pain points extracted from momenbasel/PureMac.
Frequently Asked Questions
Market intelligence mapped to Time-of-check to time-of-use (TOCTOU) vulnerability in file deletion logic, allowing symlink-based allow-list bypass..
What problem does Time-of-check to time-of-use (TOCTOU) vulnerability in file deletion logic, allowing symlink-based allow-list bypass. solve?
Which technical concepts are associated with Time-of-check to time-of-use (TOCTOU) vulnerability in file deletion logic, allowing symlink-based allow-list bypass.?
Engagement Signals
Cross-Market Term Frequency
Quantifies the cross-market adoption of foundational terms like TOCTOU and symlinks by tracking occurrence frequency across active SaaS architectures and enterprise developer debates.
SaaS Metrics