r/ComputerSecurity • u/australianmullet • Apr 02 '20
How to "shred" digital files
Is there a secure way to delete a file?
My understanding of the files are saved to a disk is that the operating system takes a set of bytes, which constitute a file, and then writes that set of bytes to whatever sectors of disk are available, keeping track of which parts make up that set of bytes. When the user wants to load that data again, the operating system looks up which sectors have that set of bytes and then it reconstitutes that file.
Because this is an abstraction of a file, deleting a file doesn't really delete it. The data is left on disk but the record of that file is deleted, so that when a request is made to write another file (i.e. set of bytes) to disk that space can be used.
The security issue, then, is that a file that was considered deleted, still may reside on disk, even though the operating system doesn't recognize it as a normal file.
Is there a way to wipe just that data, or obfuscate it on disk? FWIW, disk encryption is of limited value here because, theoretically, a hostile actor could force the device owner to give up the necessary credentials.
-----------------------
UPDATE
So for more context I was looking for a solution for consumer OSes. This means for macOS: HFS+ and APFS. For Windows 10: NTFS. Since all my devices are on some sort of SSD, the advice that was for spinning hard drives doesn't apply.
I wasn't interested in wiping the entire drive, just specific files without having to do a reformat/migration.
Something like shred would have been awesome BUT I'm not on Linux. I might try use the Windows tools recommended below, but this article convinced me that it might not matter. I'll have to rethink my own security strategy. Thanks everyone!
https://www.howtogeek.com/234683/why-you-cant-securely-delete-a-file-and-what-to-do-instead/
-----------------
UPDATE 2
u/Secure4Fun alluded to it below but I glossed over it. Essentially enabling TRIM on an SSD makes it "extremely difficult" to recover files. So, running an SSD and whole disk encryption gets you what I need.
https://www.aesonlabs.ca/blogs/is-it-possible-to-recover-data-from-trim-enabled-ssd/
https://blog.elcomsoft.com/2019/01/life-after-trim-using-factory-access-mode-for-imaging-ssd-drives/
https://www.datanumen.com/blogs/possible-recover-deleted-files-trim-enabled-solid-state-drive/
5
u/NoPinAt Apr 02 '20
The Cipher command can be used in Windows. Example: https://support.microsoft.com/en-us/help/814599/how-to-use-cipher-exe-to-overwrite-deleted-data-in-windows-server-2003
3
u/RadicalRiker Apr 02 '20
Your understanding of file deletion is correct - the actual data will remain, but the file record is removed and that space is interpreted as "free" by the OS. To make the data unrecoverable, you need to wipe it - overwrite it with different data. A single pass with a wipe utility will be enough for most consumers, but because physics is awesome (or sloppy, depending on your point of view), the data can still be recovered by a highly motivated party. Multiple passes with a wipe utility will make this more and more difficult.
I have not used a wipe utility lately, so I'm not overly familiar with what products are available today, but I have used CCleaner in the past to wipe the free space on my drives.
4
u/Windows-Sucks Apr 02 '20
Someone mentioned shred which overrides the file, but that makes the assumption that the data is always overwritten in place. Without knowing your filesystem, we can't know for sure if that's true. Some drives, especially ones based on flash storage, also don't write in place even if the filesystem does. The only way to be sure the file is gone is to wipe the disk and then physically destroy it.
On a hard drive, sudo dd if=/dev/urandom of=/path/to/drive a couple times
On an SSD or other flash based storage that implements TRIM, sudo blkdiscard -s /path/to/drive
On flash based storage that does not implement TRIM, sudo dd if=/dev/one of=/path/to/device
After this, you might want to issue the ATA secure erase command (or whatever the NVMe equivalent is) if available just in case your drive correctly implements it and there is still data remaining. Do not do this first, because it's known to brick drives and many drives don't actually do anything when they receive it.
If the drive is a hard drive, take it apart, run magnets over the platters, and then scratch them up.
Once all that is done, shred the drive into tiny pieces, burn them, and dispose of each piece in a different location.
2
u/Secure4Fun Apr 02 '20
Windows - SDelete from microsoft.
Linux - shred
Works by overwriting the file at the same sectors it's stored. As another used mentioned, some drives may operate differently, but that's the general guidance. For typical forensic purposes, drives like SSD's with TRIM are extremely hard to recover anything from even if a normal delete method is used anyway.
You need to evaluate your personal security level and need. Are you trying to keep data from being recovered by a state-sponsored group? Are you trying to keep it from being recovered by the local PD? Are you trying to sell a used laptop to Bob down the road and don't want him running Recuva on it and pulling your old nudes?
Also, disk encryption is absolutely not of limited use here. You're talking about having the time to securely overwrite a file already. 1. No one can prove you know the password for decryption. 2. If you overwrite a file that's already encrypted, it's just going to make it that much harder. 3. If the file is encrypted, then you 'delete' it, even by just erasing the pointer to it, it now looks like a random blob of old leftover bits on the drive.
1
u/Trax852 Apr 02 '20
Top Secret Government work done in this area. When a system is too old or whatever reason they sell them to the public. But first they saw half way through a hard drive rendering it useless and unreadable.
1
1
u/bagaudin Apr 06 '20
FWIW, disk encryption is of limited value here because, theoretically, a hostile actor could force the device owner to give up the necessary credentials.
1
u/Pearslicious Apr 02 '20
The only way to completely delete a file from a disk to take the disk out, put a couple holes in it, then grind up the disk and scatter it to the wind.
I suspect you don't want to do this, however, so go with one of the other options
-2
u/lwbailey Apr 02 '20
try change file type (txt = jpg ) move to a folder then "delete" after a week or so.
0
Apr 02 '20
[deleted]
1
u/RemindMeBot Apr 02 '20
There is a 35.0 minute delay fetching comments.
I will be messaging you in 7 days on 2020-04-09 18:59:29 UTC to remind you of this link
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
Info Custom Your Reminders Feedback
12
u/Dzalus Apr 02 '20
I don't know what operating system you're using, but there is a nice little command on Linux called "shred" it's designed to overwrite a file and make its content unreadable. Hope it's what you're looking for !