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.

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.
