The release of iOS 17.5 brought with it a somewhat troubling bug, as many users reported old, deleted photos resurfacing — some from more than ten years after they were deleted. While Apple has resolved this bug in iOS 17.5.1, many are still curious to know what caused the issue in the first place.

While there were rumblings that it could be tied to issues with iCloud’s photos backups themselves, Apple has confirmed to 9to5Mac that the issue did not originate from iCloud. Instead, the tech company says that the resurfacing photos were caused by a corrupt database entry that existed on affected phones’ file systems.

But how does that work, especially since many of us aren’t using the same devices that we were more than five years ago? Apple says that the issue could have transferred to newer devices through device-to-device transfers, restoring from an iCloud backup, or restoring from a backup on the device itself.

To better understand the issue and how it was fixed, security researchers with Synactiv took a deeper look at the issue by reverse-engineering the update to iOS 17.5.1 to see what changed. According to their report, iOS 17.5 appears to have added a migration routine that scans and re-imports photos from the filesystem. Apple deleted this routine in the update to iOS 17.5.1, as it seems to be the cause behind why old files were re-indexed on the local file system and moved back to the active photo galleries.

Synactiv told The Verge that the the photos appear to have been lying around on affected file systems, and that “based on the code” they were picked up by the migration routine. Unfortunately, the security researchers say that there isn’t really any way to conclude how the photos remained on the file systems in the first place.

Another possible cause that Synactiv pointed to, though, was a Reddit comment noting how sometimes your device saves files to both the Files app and your Photos app. So, if you only deleted images in your Photos app, the image would still be on your device and stored in Files.

Unfortunately, there’s no way to say for sure whether or not the issue boils down to the image being saved in two places or Apple’s “corrupt database entry,” explanation. The issue is now resolved, so long as you update to iOS 17.5.1. If you were one of the few who had older photos resurfacing, you’ll need to delete the photos yourself, as the update won’t remove them automatically.