1

I'm trying to create a redacted, printer-friendly version of a web page. I'd like the user to have the option of converting this printer-friendly page to a PDF and emailing it to someone else.

My research indicates that the best way to redact data from any kind of electronic document is to remove it. In my case this isn't possible.

Next I've seen several posts that suggest using CSS to display the text as black squares, etc. I'm thinking of using display:none so that the text just isn't rendered.

Finally to my questions: If I use CSS to hide the redacted text somehow, will this text still be included in the PDF and could a knowledgeable Adobe User access that data? Or is there another method I should try?

5
  • 2
    Welcome on Security SE! How do you intend to generate the PDF? I ask this because, depending on the way used, there might be differences in the exact information included in the final file. Jul 12, 2016 at 17:06
  • 1
    Why would it not be possible to remove the data?
    – Anders
    Jul 12, 2016 at 17:11
  • We use a content management system where field values are nested deeply in data structures that can be very difficult to access. Especially if the field is part of a collection. And I won't have control over how the pdf files are created. It's good to know PDF file creation may not be consistent.
    – ann b
    Jul 12, 2016 at 17:20
  • If there wasn't a lot of active content, one might save the HTML page, and redact the saved copy in a text editor, then export that to a PDF. Of course that wouldn't work for text rendered by javascript
    – infixed
    Jul 12, 2016 at 18:34
  • 1
    Based on the helpful answers and comments, I decided that the web page must be redacted on the server before ever reaching the browser. I found a way to access the field values and replace them with an arbitrary number of █ characters. Now the user can generate the pdf file at the client end using various generators. I accept all of the answers and think future readers should read them all. If anyone thinks I should choose a correct answer please let me know. Thank you very much.
    – ann b
    Jul 12, 2016 at 20:59

3 Answers 3

3

You can use a HTML parser like BeautifulSoup to programmatically remove HTML tags or replace them with tags such as <div class=redacted>~~~~~~~~~~</div> and add a redacted class to your stylesheet with black text and black background, or just put display:none. Note: replace the redacted information with junk data - this is key!

Edit: using display:none won't work because a user could just look at the raw HTML. Just replace it with junk characters and stylize them to your needs.

4
  • "user could just look at the raw HTML": it is not so simple, the OP specifically mentioned that the final file was in PDF format, and depending on the PDF generation process you can be quite sure that there will be no more "raw HTML" in the file. Putting some filtering between the HTML code generation output and the PDF conversion input might work though, relying on the same criteria as the current one used in the CSS code and a bit of XPath tricks, it would allow to enforce the information to be redacted. Jul 12, 2016 at 17:32
  • @WhiteWinterWolf you can ensure the PDF renderer doesn't include the info that way - the only thing in infosec you can trust is yourself (and definitely not adobe products) Jul 12, 2016 at 17:35
  • It's not about trusting Adobe, it's about trusting the PDF generation process. Although it is not the process which will be used here, for a server-side generated PDF, but some client-side PDF generators stand as virtual printers: I think one can be quite confident that non-displayed sections never reach the printer, this confidence can therefore be extended to the PDF files generated this way. Jul 12, 2016 at 17:49
  • @WhiteWinterWolf The adobe part was a joke. Many PDF renderers store metadata and not just the image itself. Jul 12, 2016 at 17:50
1

It may be possible for your server to serve a version of the HTML with the redacted content removed.

It sounds like you have some server-side functionality available to accomplish Email and PDF functions. Serving alternate HTML (where redacted content is fully removed from the HTML) may not be a significant addition to your application compared to what you are already doing.

However, if this is not possible, and you are limited to CSS rules, The safest route for you is to convert the page into an image after redaction, and only include the image in the generated PDF. (unfortunately, you also lose text selection features doing this)

If you need to keep text formatting and not convert to an image, using display:none sounds like the most likely approach that might work. However this all depends on which PDF generator you are using. It is likely that some PDF generators will still include the content in hidden (or visible) form.

You may also consider using JavaScript to remove the redacted element, but many PDF generators will not support this.

One last point, CSS and JavaScript techniques will not remove the redacted content from the HTML, so if you are allowing folks to email an HTML version then the redacted content will still be there. It sounds like you are only interested in emailing PDF copies though...

0

The ONLY way to redact digital content is to remove it. You can hide it all kinds of ways, and none of them will ever be effective.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .