AWS Builder Center
Cropped, But Not Gone: Inside  a Cropalypse Bug

Cropped, But Not Gone: Inside a Cropalypse Bug

Cropping a screenshot feels safe — until it isn't. A hands-on breakdown of CVE-2023-21036, a Cropalypse bug that let 'deleted' image data leak.

Cropped, But Not Gone: Inside a Cropalypse Bug

A few months ago, while going through CTF challenges on image forensics, I ran into something that genuinely unsettled me. Not because it was a complicated exploit — it wasn't. It unsettled me because of how ordinary the mistake was, and how many of us had probably made it a hundred times without knowing.
It's called a Cropalypse bug — officially CVE-2023-21036 — and it's about something as simple as cropping a screenshot.

The scenario we've all been in

You take a screenshot. Maybe it has your card number in it, or your address, or a face you don't want shared. So you crop it. You cut out the sensitive part, save it, and send the "safe" version to a friend, or post it online.
Except — what if the part you cropped out never actually left the file?
That's exactly what happened to millions of people using Google Pixel's built-in Markup tool, and later a similar issue was found in Windows' Snipping Tool. You'd crop an image, save it, and feel confident the removed part was gone. It wasn't. It was still sitting there, physically, inside the file.

Why this happens — and it's not really about "hacking"

When I first read about this, I expected some clever exploit chain. Instead, the root cause was almost embarrassingly simple, and that's what makes it worth understanding.
Here's the thing about how these editing tools saved files: when you cropped an image and hit save, the app would write the new, smaller image data over the beginning of the original file. But if the new file was smaller than the old one — which it almost always is, since you removed part of the image — the app would just move the "end of file" marker up to match the new, smaller size. It wouldn't actually erase the leftover bytes from the old image that were sitting past that marker.
Think of it like erasing the last few pages of a notebook by just writing "END" halfway through, instead of tearing the leftover pages out. Anyone who knows to keep reading past your "END" mark can still see everything you thought you deleted.
For PNG files, this had a very specific consequence. PNGs are built from compressed chunks of image data, and the format allows some flexibility in how that data is read back. Because the original file's leftover chunks were still physically present after the "END" marker, it was possible to reconstruct large portions of the original, uncropped image — sometimes almost the entire thing — just by reading past where the file was supposed to end.

Actually seeing it happen

What made this real for me wasn't reading the writeup — it was recreating it. I took a test image, cropped it the same way the vulnerable tools did, and then went digging into the raw bytes of the "edited" file with a hex viewer.
Sure enough, past the point where the visible, cropped image data ended, there it was — chunks of the original pixel data, untouched, just waiting to be reassembled. With a small script that understood the PNG chunk structure, it wasn't hard to stitch that leftover data back into something close to the original image. No password cracking, no clever social engineering — just knowing where to look.
That moment is genuinely one of those "oh no" realizations in security. Not because the technique is advanced, but because of how invisible the risk is to a normal user. You did everything right — you cropped the sensitive part, you checked the preview, it looked clean. The file itself was lying to you.

Why it actually mattered

This wasn't a theoretical bug. Think about how many screenshots get cropped and shared every single day — on Discord, on Twitter/X, in support tickets, in group chats. Payment details, home addresses, faces of children, private conversations — all "safely" cropped out, and in a lot of cases, still fully recoverable by anyone who knew about the flaw.
Security researchers ended up building tools that could scan public image-sharing platforms for exactly this kind of leftover data, and the results were sobering: real people's real private information, sitting exposed in screenshots they believed were safe.

From Manual Find to Automated Fix — Using AWS

Recreating the bug on one test image with a hex viewer is one thing. But what if we are building a product where thousands of users upload cropped screenshots every day — a support ticket tool, a social app, a chat platform? You can't manually inspect every file. So after digging into this manually, I started sketching out what an automated safety net would actually look like.
Here's the architecture I'd reach for:
  • S3 as the entry point — every uploaded image lands in an S3 bucket. This is the natural trigger point, since almost every image-sharing feature already stores uploads there.
  • A Lambda function triggered on upload — the moment a new object hits the bucket, a Lambda function fires and reads the raw bytes of the file. For PNGs specifically, it checks whether there's any data sitting after the IEND chunk — the official "end of file" marker. If there is, that's the same signature a Cropalypse bug leaves behind: leftover original image data that was never actually deleted.
  • Quarantine instead of block — flagged files get moved to a separate "quarantine" bucket or tagged instead of being deleted outright, so a human (or another automated check) can review false positives before anything gets lost.
None of this requires anything exotic — it's a small Lambda function, an S3 event trigger, and some basic PNG chunk-parsing logic, the same kind of parsing I used manually while reconstructing the test image. The difference is that instead of one researcher checking one file by hand, this runs automatically on every single upload, at whatever scale the platform needs.
The bigger point here: this class of bug isn't just a "patch the crop tool" problem. Any team building features around image uploads — screenshots, ID verification, profile photos — could bake a check like this directly into their upload pipeline, catching the next a Cropalypse-style leak before it ever reaches a user.
The bigger lesson isn't really about PNGs or crop tools. It's this: "delete" and "overwrite" are not the same thing in software. Marking something as gone is not the same as removing it. This shows up everywhere — deleted files that are still recoverable from disk, "cleared" chat histories still sitting in a database, "removed" data still cached somewhere. a Cropalypse is just a very visual, very relatable version of a mistake that shows up across almost every layer of computing.
The next time you crop a screenshot before sending it, it's worth remembering: what you see in the preview isn't always the whole story of what's inside the file.


#buildatpce
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article