PDF redaction mistakes that leak data
By Felix Stiffel · · 5 min read
Black is not the same as gone
Redacting means removing information from a document before you share it: an account number in a letter, a name in a court filing, a salary in a contract. In a PDF, the part you see and the part that is stored are two different things. A redaction only works if the information is removed from the file, not just covered up on the page.
The classic mistake is to draw black shapes over the text instead of removing it. The page looks redacted, but the words are still in the file and can be copied and pasted. To show how easy that mistake is, we tested it ourselves.
The test letter
We wrote a one-page sample letter with two sensitive details: a German IBAN (a made-up test number) and a tax ID. We exported it to PDF with LibreOffice and set the document properties the way many office programs fill them in automatically: a title and an author name.
Then we tried to hide the IBAN in three ways and checked each result with pdftotext, a free command-line tool that extracts the text of a PDF, the same way copy and paste or a search engine would.
Mistake 1: drawing a black rectangle
Many PDF editors and office programs let you draw shapes on a page. We drew a filled black rectangle over the IBAN. On screen the number was completely hidden.
pdftotext still returned the full sentence, "Your salary will be paid to IBAN DE89 3704 0044 0532 0130 00 from 1 January." The rectangle is just one more drawing instruction placed after the text. The text itself is untouched, so anything that reads the text rather than the picture, including copy and paste, screen readers and search, gets the number.
Mistake 2: a black highlight or rectangle comment
Comment tools are the other common shortcut: a black highlight, or a rectangle comment with a black fill. We added a filled black square annotation over the IBAN. Again it looked perfect on screen.
Again pdftotext returned the full IBAN. An annotation is a separate object that sits on top of the page. It does not change the page content at all, and in most editors anyone can select the comment and delete it, which reveals the text without any special tools.
Mistake 3: forgetting the document properties
Both covered-up versions still carried the original document properties: title "Salary letter (test file)" and author "Jane Example". Many viewers show these under File, Properties, and they travel with every copy of the file. Author fields often contain a full name or a login name, which can be exactly the detail a redaction was meant to hide.
Other places worth checking are bookmarks, the names of form fields, attached files, comments, and the file name itself. None of them are visible on the page, and all of them are part of the file.
Mistake 4: cropping or hiding instead of removing
Some people cut sensitive parts off by cropping the page, or hide them with a white box. Neither removes anything. Cropping only changes which part of the page a viewer displays; the content outside the visible area stays in the file. A white box behaves exactly like the black rectangle in mistake 1, it just draws over the text in a different colour.
The same goes for pages you mark as hidden or that sit in a hidden layer. If the information is in the file, assume someone can get it out.
What a real redaction does
A real redaction removes the information from the page content, so there is nothing left to extract. Professional PDF editors usually do this with redaction annotations that are first marked and then applied. Applying them deletes the text, images and drawings under each mark and paints the black box in their place.
Our Redact PDF tool takes a simpler route that is easy to verify. Every page on which you draw a box is rendered to an image at 150 dpi with the boxes painted solid black, and that image replaces the page. Pages without boxes are copied unchanged. In our test, redacting the IBAN took 439 milliseconds in Chromium. pdftotext found no text at all on the redacted page, and the page consisted of a single 1,275 × 1,651 pixel image.
That approach has two side effects you should know about. First, the whole page becomes an image, not only the redacted area. The rest of the letter is still readable, but it can no longer be searched, selected or read aloud by a screen reader. Second, the file grew from 12 KB to 39 KB, because an image of a page is larger than the text it shows. If you need searchable text again, you can run OCR on the result. There is nothing under the black box for OCR to recover.
In our test the redacted file also no longer contained the original title and author. Do not rely on that for every file, though. Check the document properties of the result, and clear them with a metadata editor if needed.
Check before you send
Whatever tool you use, test the result as if you were the person trying to read it.
1. Open the redacted file and search for the word or number you removed, using the viewer's search (Ctrl+F or Cmd+F). If the search finds it, the redaction failed.
2. Select all text on the page (Ctrl+A or Cmd+A), copy it and paste it into a plain text editor. Look for anything that should not be there.
3. Open the document properties and check title, author, subject and keywords.
4. Look for comments, bookmarks, form fields and attachments in the viewer's side panels.
5. Redact a copy and keep the original somewhere safe. A redaction that removes content cannot be undone, so you will want the original if you redacted too much.
6. Ask whether an earlier, unredacted version has already been shared, for example as an email attachment. Redacting the latest copy does not recall the copies that are already out.
These checks take two minutes. Skipping them is how covered-up account numbers end up in public documents.