Is editing and renaming a file an effective way to wipe its original data from your drive?

Say I have a text or image file that I don’t want on my drive anymore, but I have an SSD, so there’s no way to effectively remove it. Can I remove its data by editing and saving it, say by deleting all the text for a text file, or opening an image in an editor and covering its old contents with something else, like a black brush or another pasted image, and then renaming it to obscure what it originally was?

No. You can’t write directly to a specific block on an SSD, there are several abstraction layers between your file and what the SSD controller actually does on the NAND flash.

In your example the SSD controller will create a new version of the file somewhere else on the storage and mark the old one for deletion. If and when this happens is largely out of your control.

SSDs sound pretty terrible for security then.

That’s what full disk encryption is for. :slight_smile:
Companies with important enough secrets will also mechanically destroy any defunct drives by turning them into tiny particles with specialised shredders.

Or encrypted containers (like with Veracrypt). As long as the file is only ever saved into the container, then the file is not recoverable without the decryption key, so it could be disposed of while keeping the rest of the drive intact. (Though some memory swap might still happen which would save an unencrypted copy to the drive?)

Also, with some SSDs, some OSes will also TRIM on delete and run scheduled TRIM afterward. For example, Windows will TRIM an internal SSD “immediately” (but asynchronously) and then weekly, making recovery that depends on the SSD firmware unlikely. If an adversary doesn’t have tools that can access the drive’s contents without the firmware, it’s probably not something to worry about after some minutes/a week (with some SSDs and some OSes).

As other comments mentioned, whole-disk encryption would also work with fewer ifs.

If you already have that file, and its not on an encrypted filesystem, delete that file, then make a file that takes up the rest of the space with random data so theres no option for the filesystem to compress it. Then flush the fs cache, and delete that file. To flush the cache in linux, the command is “sync”. To make that file in linux, you can dd from /dev/random until you run out of space. But keep doing this, and you’ll wear out your flash cells, so you don’t want this to be a habbit.

If your going to store a file that you know you want securely deleted later, store it encrypted or in an encrypted container as the others have said.

Some OSes have a secure delete, but you’ll have to look into how they work. They could be snake oil.