iOS 17.5.1 brings an emergency fix for a bug causing deleted iPhone and iPad photos to reappear, sometimes years after being deleted.

If you thought you permanently deleted NSFW photos only to find them reappearing in your Photos library, you must install iOS 17.5.1. Go to Settings > General > Software Update and follow the onscreen instructions to finish installing the update.
“This update provides important bug fixes and addresses a rare issue where photos that experienced database corruption could reappear in the Photos library even if they were deleted,” Apple wrote in the iOS and iPadOS 17.5.1 release notes.
iOS 17.5.1 stops deleted iPhone photos from resurfacing
The first complaints about this bug started popping up on Reddit and other online discussion forums right after iOS 17.5 and iPadOS 17.5 were released.
Some folks complained about old images resurfacing as the latest iCloud uploads in the Photos app, even after being repeatedly deleted. “Six photos from different times, all I have deleted,” one user wrote. “Some I had deleted in 2023.” Others say the old images keep coming back, even after being repeatedly deleted.
The Mac doesn’t suffer from this bug, as Apple hasn’t released a macOS update with the same fix. The company certainly wasted no time with this fix.
When are deleted iPhone photos deleted for good?
I haven’t spotted this bug, but I don’t like this. If some folks found their old photos deleted years back resurfaced, then it begs a valid question: When exactly do our deleted iPhone photos and videos get permanently deleted?
A deleted photo isn’t gone right away. Instead, it’s moved temporarily to the Recently Deleted folder in the Photos app. This is by design, so you can recover a deleted photo or video. But, every deleted item is permanently removed from the Recently Deleted folder after 30 days and cannot be recovered anymore.
Now, Apple is required by law to retain some of users’ deleted data, like records of purchases, but our personal photos and videos shouldn’t be kept on servers for years. I hope this is just a bug in the system but it gave me a pause, making me wonder what’s going on behind the scenes when we delete data from iCloud.