Under certain conditions, macOS may copy data into the void, leading to data loss of important files, all due to a bug in how the operating system handles APFS sparse disk images.
The issue was discovered and reported to Apple this past week by Mike Bombich, the creator of a Mac backup application named Carbon Copy Cloner. Bombich says the bug affects only "sparse disk images" formatted in Apple's new filesystem format APFS, first deployed macOS High Sierra in March 2017.
A "disk image" is a file format that contains the entire contents and structure of a disk volume, such as USB, CD, DVD, hard disk drive, or network share. Many Mac applications utilize disk images, especially backup software, allowing users to create copies of other volumes and quickly move files in and out of an older backup image at a later date. A "sparse" disk image is a type of disk image file that can grow as the user adds more data to it. But sparse image disks can only go as far as the underlying storage medium permits, and they will show a free space available value, depending on the free space that remains on the underlying hard drive.
Users at risk of losing sensitive data
The issue is that APFS sparse disk images fail to synchronize the value of the "free disk space" from the sparse disk image with the real "free disk space" value from the underlying hard drive. This leads to catastrophic scenarios where users might think they have free space on APFS sparse disk images —but they do not— and end up writing data into a void, once the underlying storage disk is full and data overflows.
Bombich says the bug is not the fact that macOS writes data into the void, but that it fails to warn users that (1) there is no more space on the underlying hard drive and (2) that it shows misleading information. The misleading information is that for a short period after the write operation has taken place, macOS can still access the file, and even show the file with a proper checksum, tricking the user into believing that the copy/move operation has gone as planned.
In reality, this has not, and this state lasts until a system reboot when any artifacts of the copied files are removed from the OS' memory, and files become corrupted and inaccessible. Here's an example, to better understand how this works.
- A user creates 50 GB APFS-formatted sparse disk image that stores its data on a remote network share of 50 GB.
- The user copies data to the remote network share, taking up 40 GB of data.
- The APFS disk image file is not updated, and continues to show 50 GB of free space.
- The user tries to copy a 20 GB file to the disk image.
- The copy operation goes as planned. The user can still access and open the file right after the copy operation and the checksum is identical to the original file.
- User reboots workstation.
- Copied file becomes corrupt, as 10 GB of its data disappears.
Not many users affected
The good news is that not many users are affected. Bombich cites statistics from his own software, saying that only 7% of all Carbon Copy Cloner users store backups as sparse disk image files and that only 12% of these 7% use APFS-formatted disk images. Nonetheless, sending files into the void is not a good look for a backup software, so Bombich says his software will not support AFPS-formatted sparse disk images until Apple resolves the bug he reported. Bombich has recorded a video showing the bug in action. The video embedded below:
This is the second major bug that Apple has to fix in its new APFS filesystem format. In October last year, Apple issued an emergency update for macOS High Sierra to address a bug that exposed the passwords of encrypted APFS volumes via the password hint feature. This is also Apple's second major bug this week after it emerged on Thursday that many iOS and macOS apps would crash in a loop because they were unable to display a simple Indian Tegulu character.
Axarhöfði 14,
110 Reykjavik, Iceland