Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Wiping Out Sensitive Data


Wiping Out Sensitive Data

Most computer users don’t realize that deleting a file does not get rid of the file contents. Conventional file deletion merely drops entries for the file in the File Allocation Table (in a FAT filesystem), Master File Table (in NTFS), or similar index to allocated clusters. Clusters are marked as unallocated so they may be reused for the storage of data associated with new files in the future. To protect against unwanted disclosure of sensitive data, files must be wiped or erased rather than simply being deleted.

When a file is wiped, its contents are overwritten so that normal disk I/O and software calls are not sufficient to recover the file's data. Overwritten data is considered erased even when forensic data recovery techniques are able to detect residual recoverable data physically present on the storage device. When data recovery is a simple matter of executing software instructions to parse data structures starting with known file headers, the difference between a deleted file and an active one is little more than a limitation of perception caused by inadequate built-in data recovery features.

As programmers, it is our job to ensure that delete really means that data is gone, at least with respect to software that can control the data storage device through the normal I/O interface. Very sensitive information is supposed to be overwritten numerous times with random bit sequences, and a variety of techniques and algorithms have been defined and standardized for accomplishing thorough destruction of data. Two programs that are useful for permanently wiping data storage devices or highly sensitive files are Darik's Boot and Nuke (DBAN) and Eraser. These programs are open source and can be downloaded from SourceForge at the following URLs:

DBAN
http://sourceforge.net/projects/dban/

Eraser
http://sourceforge.net/projects/eraser/

In most cases, simply overwriting file contents with nonrandom data, such as streams of ones or zeros, is more than enough additional protection against software-based data recovery or forensic tools. The following .NET class illustrates a simple, quick, and effective way to ensure that delete really means that a file cannot be recovered using software alone. The class wipes a file by writing zeros in place of each byte of allocated space prior to calling the regular file-deletion API:

using System;
using System.IO;

namespace filewipeclass {
class main {
  [STAThread]
  static void Main(string[] args) {
  FileWipe fw = new FileWipe();
  fw.Wipe(args[0]); }}
class FileWipe {
  // File.Delete method only drops FAT/MFT entry
  // FileWipe destroys file data first.
  public void Wipe(string sPath) {
  FileInfo fi = new FileInfo(sPath);
  try {
  if(fi.Exists) {
  FileStream fs = fi.OpenWrite();
  for(int a = 0;a < fi.Length;a++) {
  fs.WriteByte(0);
  }
  fs.Close();
  }
  fi.Delete();
  }
  catch(Exception e) {System.Console.WriteLine(e);}
}}}

There is no good reason to leave deleted data sitting on a data storage device just waiting to be recovered. Adding a predelete step to the file-erasing process is easy in any language, and only by wiping files that users believe they are deleting can we fulfill our obligation to users to provide them with software that does not provide a false sense of security.

Even data that may not seem sensitive to us often turns out to be very sensitive to our users. For instance, temporary files that are never seen by a normal user are often examined by forensic investigators who consider the mere existence of a file, deleted or not, to be conclusive proof that a particular person caused our software to perform some task at a particular time. Such circumstantial evidence of possible activity on a computer in the past can have significant security or legal implications for the computing public.

As a rule, if you care about producing secure software products that are safe to use, everything must be wiped rather than just being deleted.


Jason Coombs <[email protected]> works as a freelance computer forensic analyst and security incident response investigator. He also serves as a technical expert witness in civil and criminal court cases. Jason thinks he knows a thing or two about information security and forensics, but he may be mistaken; he may in fact be your typical corporate programmer geek with a slightly unusual résumé, which is mostly the result of a refusal to work in a cubicle and a desire to earn far more than he is probably worth.



Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.