Why writing a system cleaner is hard
From the outside, a cleaner looks like one of the simplest apps in any category: find files, delete files, show a number that went down. To-do lists and note apps get cloned by the dozen because the blast radius of a bug is small. A cleaner is the opposite. Its entire job is deleting files that live next to the operating system and the user’s data, often with elevated privileges, on behalf of people who may not understand what it just did. That combination makes cleaners one of the harder categories of software to get right, and one of the more attractive ones to get wrong on purpose.
If you are thinking about writing one, this page is the job description. If you are deciding whether an existing one deserves your trust, that is a different question: is this a good cleaner?
The blast radius is the whole product
- A cleaner deletes files adjacent to system files, application data, and user documents. A bug in a calculator loses a digit. A bug in a cleaner loses a home directory.
- Cleaning rules are shaped like “delete X but never Y”, and the safe set and the dangerous set are often the same folder.
- Many users will not understand the consequences even when you explain them clearly. You are handing each of them a scalpel: the same tool that frees ten gigabytes can remove a home directory.
It needs privileges, and privileges are the attack surface
- Cleaning system areas requires elevated privileges on every platform. Every step up in privilege is a step up in what a bug or an exploit can do.
- Running the whole app elevated, GUI included, is the easy design and the worst one. The safer design is a small privileged worker doing only what must be done as root, and it is also the inconvenient one.
- Classic filesystem attacks apply: planted symlinks that redirect a delete onto a file the attacker wants gone, race conditions between checking a path and deleting it, and paths that escape their intended directory.
- If the cleaner’s own definitions or update files are stored insecurely, tampering with them rewrites the delete list. The cleaner becomes the payload.
The target never stops moving
- Definitions have to track hundreds of applications that keep changing: browsers rotate cache formats, apps relocate their data, new releases break last month’s rules.
- A stale definition is not neutral. It either cleans nothing or cleans the wrong thing.
- “Delete” is not always the operation. Some artifacts need specialized handling: SQLite databases want vacuuming rather than unlinking, and artifacts like Safari’s cookies live in storage that plain file deletion handles badly enough to corrupt the app that owns them.
- The platform pushes back too. Antivirus software is specifically designed to block access to exactly the files cleaners care about, such as browser cookies and history.
The scoreboard rewards the wrong thing
- Cleaners are judged by one number: how many gigabytes they freed. Every review screenshot and every app listing puts that figure front and center.
- That gives developers a dangerous incentive to pad it by targeting files that are harmless or actively useful, such as system logs, pre-rendered thumbnail caches, and compiled shaders that the operating system will immediately recreate.
- The reclaimed space is temporary and cosmetic, but the cost is real: the OS spends effort rebuilding what was deleted, the drive burns write cycles, and things can run slower while the caches warm back up.
- An honest count would include only files that are safe to remove and stay gone. That number is smaller, and smaller numbers do not sell.
The takeaway
The code in a cleaner is not the hard part. The hard parts are everything around it: keeping privileges small, surviving a hostile filesystem, tracking a moving target, and resisting the scoreboard’s pressure to make a small honest number bigger. And even if you get all of it right, you still have to prove you are the safe one in a category where accidents, exploits, and counterfeits all wear the same icon.
The other half of that problem sits with the user: telling the good ones from the bad before installing. That is a different page: is this a good cleaner?
Last reviewed