Take care redacting WebP images

29 November 2026

Suppose you are sharing an image and you want to redact the sensitive data first. You have to be careful if that original image was saved in a lossy format—the pixels of the redacted information can spread across the image as a result of the compression process. This is fairly well-known for JPEG, where the solution is also quite simple: the influence of the redacted content extends at most within 8x8 pixel blocks, so you are safe provided you maintain a minimum 8px buffer around the content you’re redacting (for non-progressive JPEGs anyway). I was curious to try this out with WebP, and it turns out there is no such convenient 8x8 pixel containment.

Here is a synthetic example. The original JPEG had a large word “YES”; this was saved at quality 50. That image then had the YES painted over with a black box—a narrow box that extends only 2px past the glyphs—with the result saved as a lossless PNG.

Mock case file document with a black redaction box covering one line of text

If you do the same process to an image that actually contained the word “NO”, the ring of artifacts outside the redaction box changes in a deterministic way. If you diff the pixel magnitudes between the YES and NO images (and amplify the difference by 20x to make it clearer) you get this.

Amplified difference between the redacted JPEGs, showing artifacts only in the bands immediately above and below the redaction box

In principle you could use this difference to infer whether the redacted content was originally YES or NO. Hence, the recommendation to make the redaction box at least 8px beyond the sensitive content so that it cannot influence pixels beyond the redaction box.

If you repeat the experiment but use lossy WebP (VP8) instead of JPEG, then the diff between the YES and NO images looks like this.

Amplified difference between the redacted lossy WebP images, showing changes across the whole image including the untouched heading and footer text

It is clearly apparent that the presence of YES or NO has had an impact across the entire image. There is no obvious way to apply the redaction that would prevent leakage.

Now, image forensics is not my wheelhouse and I am not going to claim that it’s necessarily easy to work out what is behind an arbitrary redaction. However, this example clearly suggests we should not take that chance. If you need to redact and share something, I would advise against using any lossy WebP source material.


Serious Computer Business Blog by Thomas Karpiniec
Posts RSS, Atom