114 points · by goranmoomin · 3y ago · 114 comments
Modern SSD controllers encrypt all data by default. Not to increase security, to improve wear levelling. Encrypted data should be effectively random data (that’s what good encryption aims to produce). So encrypting the data ensures that patterns in data written to the SSD don’t end up creating uneven wear patterns in the flash chips.
As a consequence, reading the raw data of an SDD would just produce garbage. You would need to also extract the encryption key from the SSD controller. Given this encryption isn’t meant to be secure, it’s quite possible to extracting that key is quite easy. But I believe that secure erase on SSDs is achieved by simply rotating the encryption key used for wear levelling, so maybe it’s reasonable well protected.
I would expect an SSD to quite aggressively erase TRIMed blocks where possible. Erasing a block of flash memory is about 10x slower (2ms) than writing to flash memory (200microseconds), so there’s quite a large performance hit once a drive runs out of empty blocks and needs to start erasing blocks in the write path.
Overall I suspect that simply TRIMing most SSD is secure enough for most applications. At least secure enough for anyone that even asks the question “is TRIMing secure enough”. For everyone else, you either don’t care at all, or your really care, in which case you’re using multiple layers of security such as full disk encryption, secure SSD erase, and shredding drives already.
"An Experimental Analysis of Erase-to-Program Interference in Multi-Level Cell NAND Flash Memories" by F. X. Zhang, et al., in IEEE Transactions on Electron Devices, vol. 63, no. 4, pp. 1621-1628, April 2016.
"Erase-to-Program Disturbance in NAND Flash Memory: Characterization, Modeling, and Mitigation Techniques" by M. H. Kim, et al., in IEEE Transactions on Very Large Scale Integration (VLSI) Systems, vol. 25, no. 9, pp. 2381-2392, Sept. 2017.
"A Study of Erase to Program Disturbance in 3D NAND Flash Memory" by T. Wang, et al., in IEEE Transactions on Electron Devices, vol. 64, no. 7, pp. 3153-3159, July 2017.
"Characterization and Modeling of the Erase-to-Program Disturbance in Multi-Level Cell NAND Flash Memories" by R. Micheloni, et al., in IEEE Transactions on Electron Devices, vol. 56, no. 11, pp. 2384-2392, Nov. 2009.I'm not even sure where to start
Reading data from multi-level flash chips, or from spinning rust, has more in common with an FM radio, or mobile phone radio, than it does with anything you’ll see in an IDE. It’s all very complex signal processing, trying to extract small signals from lots of noise, in that world you know what your data probably looks like. You then need checksumming to figure out if it’s correct, and if it isn’t you need to try again, or declare the data lost.
If you’re in a situation where you’re thinking that TRIM might be good enough, then you clearly don’t care that much about the data potentially being recovered by sophisticated attacker. You just don’t want it to be trivial to recover that data. In that case, even old cyphers and small keys is probably good enough.
But once again, if your really care about destroying your data, use something’s that’s explicitly designed to destroy data!
Contrary story from 2018/9:
> The security researchers explain that they were able to modify the firmware of the drives in a required way, because they could use a debugging interface to bypass the password validation routine in SSD drives. It does require physical access to a (internal or external) SSD. But the researchers were able to decrypt hardware-encrypted data without a password. The researchers write that they will not release any details in the form of a proof of concept (PoC) for exploit.
* https://borncity.com/win/2018/11/06/ssd-vulnerability-breaks...
> Microsoft is aware of reports of vulnerabilities in the hardware encryption of certain self-encrypting drives (SEDs). Customers concerned about this issue should consider using the software only encryption provided by BitLocker Drive Encryption™. On Windows computers with self-encrypting drives, BitLocker Drive Encryption™ manages encryption and will use hardware encryption by default. Administrators who want to force software encryption on computers with self-encrypting drives can accomplish this by deploying a Group Policy to override the default behavior. Windows will consult Group Policy to enforce software encryption only at the time of enabling BitLocker.
* https://msrc.microsoft.com/update-guide/en-us/vulnerability/...
> Although Windows ships with its own full volume encryption tool called BitLocker, SSDs that claimed to offer their own hardware-based encryption were trusted by the tool and left alone.
> Now though, after a recent update to Windows 10, Microsoft will assume that connected SSDs don't actually encrypt anything.
* https://www.techradar.com/news/microsoft-will-now-encrypt-ne...
The first and most obvious, is wear levelling between blocks of flash memory. Here the SSD controller tracks how often it erases blocks of memory which are probably tens to hundreds of bytes large, and tries to keep those counts nice and even. You’re probably already aware of that type of wear levelling.
But wear levelling across multiple blocks means that there’s nothing tracking how often each cell within a block of memory is being written to and erased, because that depends on exactly what data is written into the block. So if you’re writing data that has a repeating pattern that’s a multiple of your block length, then specific cells within that block will be written to more often than others. This impacts both the wear of the individual cells, but probably also write quality as well, because have two cells next to each other with vastly different stored values almost certainly adds noise when reading again (nature hates a gradient).
You can’t track wear on a per-cell level, because that would require an extreme amount of memory just to store counters, which could be better used to store data. But what you can to is transform the data your writing into “random” data to remove any patterns and produce even wear. Additionally the randomness will also reduce the variance in stored values between adjacent cells, improving write quality.
So encrypting the data provides a bunch of very useful adjacent benefits for a very small cost. Encryption algos like AES are deliberately designed to very high performance on extremely low power, memory constrained devices, and typically have a pretty low transistor count for dedicated crypto silicon. So using strong AES encryption in an SSD is pretty much a no-brainer. You get improved reliability (because better wear levelling), improved performance (because writes are more successful), and feature you charge extra money for (on device full disk encryption).
I'm assuming the reason this works is because the underlying block that gets written isn't the same one that has the old data and thus the probability of overwriting with the same data is low because the encryption key for a given write is somehow derived from block offset + length to make sure that a duplicate pattern for a given block will still encrypt differently?
If I understood that properly, this feels like a lot of complexity for unclear gain (not seeing how it improves write leveling vs at best downgrading the best case / average case to the worst case) and I haven't found any papers online. Is this mechanism something you actually first hand building or something you remember reading from some tech newspaper? Would love a primary source here.
Also, TRIM is only possible with drives that are still in working order. Very often you can't TRIM or secure delete a drive that is defective and returned by RMA. In that case you either need a very expensive no-disk-return support contract. Or you just use FDE.
And if you turn off TRIM you get a massive performance decrease.
The disadvantages are massive, such as significant slowdown when the drive gets filled. Yet the creators of dm-crypt are paranoid about enabling it by default:
https://wiki.archlinux.org/title/Dm-crypt/Specialties#Discar...
I couldn't understand ref 3: https://web.archive.org/web/20160709174950/http://www.saout....
Ref 4: "you have an information leak where filesystem-discarded blocks (by TRIM) can be identified by an attacker with low effort"
https://web.archive.org/web/20160709183108/http://www.saout....
I think people vastly overestimate the possibility to recover any data from a wiped HDD.
See for example this article by SANS [1]. To recover a single bit you have a better chance of flipping a coin to see if the bit was a zero or a one then you have when you are actually trying to reconstruct it with lab equipment.
[1] https://web.archive.org/web/20140621130410/https://digital-f...
But all modern HDDs retire sectors that exhibit a higher correctable error rate and replace them by reserve sectors. Those retired sectors then still contain readable data (maybe with some bit errors) if you know the appropriate factory mode commands. Overwriting the entire disk also won't overwrite retired sectors, except if the disk has an explicit function for it and you trust that function to work properly.
In short, you always need full disk encryption.
According to NIST 800-88 Rev. 1 a single overwrite is fine:
* https://en.wikipedia.org/wiki/Data_remanence#Feasibility_of_...
Furthermore, <50% is only an antipredictor for a single coin flip. If you have two bits - two coin flips where you care about the order - then there's four values, and you have to be <25% to be an antipredictor. Even then, an antipredictor only removes one possibility[0], so flipping the bits will only slightly improve your terrible chances of recovering the data.
> That is, if you toss a coin, you have a 50% chance of correctly choosing the value. In many instances, using a MFM to determine the prior value written to the hard drive was less successful than a simple coin toss.
More believably, the paper was written by Dr Craig Wright.
Now you perform a hdd recovery that is successful 70% of the time. That is still worse than the performance of the oracle coins which were correct, and if you invert the performance of the liars, they also beat the performance of the recovery.
If you have two coins, one which is always correct and one which is always incorrect, you can flip one of them to decide whether the other one is correct (and pick the opposite).
Check mate, statisticians!
Edit: And of course even a high of 92% is abysmal for a single bit, since the combined odds of multiple bits quickly goes to zero for any sizable amount of data.
Imagine the following method: take whatever the bit was, and set it to the opposite of that. 0% < 50%. Of course you can invert and get 100%, but that's a different method. It doesn't make the original any better.
The only requirement of the flash reset operation is that it consistently causes bits to read as 1 and that the normal write operation allows them to read as 0 again; it doesn't actually follow from that that an erased-but-not-reprogrammed block will have cell charge levels that are indistinguishable from each other based on the pre-erasure charge level.
Pro recovery compagny that are not shady know that SSD recovery with TRIM is impossible.
Say you have one root key and you derive per-file or per-block keys using various metadata (inode numbers, generation numbers, block addresses, whatever). You can't throw away derived keys though!
Or say you generate random keys per-file and you store those somewhere (it's annoying to have to store them). Now to throw those keys away you need to re-write the blocks containing them. If there's any behind-the-scenes copy-on-write going on then re-writing a block doesn't necessarily lose its old contents.
The only thing that's easy to throw away -maybe- is the top-level / root keys. But that means deleting the entire filesystem.
Well, yeah, that's why I said you encrypt the entire drive. If you do things that make it hard to throw your keys away, then it's gonna be hard to throw your keys away.
You can, AES-XTS does just this. Per-block keys can be derived on the fly from the root key and the block address. When the root key is gone, everything is gone.
Having to wipe an entire filesystem to securely delete a file is not useful.
It's basically the "quick format" of SSDs: "hey, all those blocks here, I don't care about them anymore, use them as if they were free..."
Without OS-side encryption, Secure Erase is the only reliable option (SSD encrypts everything with an internal key which then gets deleted by the secure erase command, leaving only random data behind)
Due to implementation details, SSDs can only use a block if it is clear. Thus trimming a block and waiting for long enough would be sufficient to erase the data if the driver actually enforced that the block will be reused.
So, it's not good enough, but this is not obvious at all.
Put the encrypted drive into a hydraulic press and flatten it into a thin sheet, then run that sheet through a chop saw, or just use tin-snips if your hydraulic press was powerful enough. A hydraulic press and a chop saw are a few hundred bucks whereas drive shredders can range from $30k to $200k.
Also a standard failure mode of SSDs is refusing to accept writes, so you'll have to handle that case.
Even if there is a massive 10% block reserve, you looking at a random 10% of an entire encrypted drive.
Figuring out how to just decrypt those blocks is a very hard challenge, then figuring out the SSD block mapping is going to be very challenging, and then for a chance to maybe get something valuable from that 10%.
Multiple very difficult challenges for only a chance of maybe recovering something useful.
Related, I just had a hard drive head crash. I was able to use dd_rescue to read out 40% of the drive before it fully gave out. It's amazing, but at least NTFS stores data everywhere. I recovered a few small plain text file, but not a single image was recoverable. It was pretty shocking to me.
Not always. I suppose it depends on your information security case. If your goal is to secure your kids laptop from the average thief that is heading to the pawn shop, maybe "secure erase" of encrypted drives may be sufficient.
If on the other hand one is protecting intellectual property, customer data and so on, then perhaps that average thief was hired by someone with significant resources. I would wager that a percentage of the people reading this comment are using a work laptop and have some IP on their drive that in the wrong hands could cost billions. Even some of the emails I've seen could do significant damages.
/dev/zero would be sufficient.
Also easier to confirm things worked (if desired) since you know what to expect on read-back.
But it depends on your risk profile, for most people a wipe-and-reuse is going to be fine, especially if the "reuser" is already a trusted entity.
Can we repurpose a die press to this task and if so, would a 100 ton AvE die press [1] be powerful enough?
https://wiki.archlinux.org/title/Solid_state_drive/Memory_ce...
https://www.usenix.org/events/fast11/tech/full_papers/Wei.pd...
Edit: see section 3.2.2 in the PDF (and the corresponding table 2):
> In most cases, overwriting the entire disk twice was sufficient to sanitize the disk, regardless of the previous state of the drive. There were three exceptions: about 1% (1 GB) of the data remained on Drive A after twenty passes
This is about normal overwriting, however. The fastest random overwriting program on Linux I know of is `shred`
https://wiki.archlinux.org/title/Solid_state_drive/Memory_ce...
And anyone who thought TRIM would be a reliable way to get rid of data to begin with didn't have an understanding of TRIM!
Securely erases all known forms of electronic data storage. Cheap, reliable, fun for the whole family!
Sometimes we would send out new ones to replace the old. When we got the old ones back, it was always unclear how to purge and recommission SSD/NVME drives.
My best attempt was using GNU shred, but it wasn’t recommended for flash-based storage back then.
I'm also unsure as to why you are getting drives back at all, any of your customers should not have any kinds of storage devices leave their site intact. At least that is the standard over here in Europe for healthcare and other industries dealing with sensitive data.
The thing you need to guard against is relocated/reserve sectors, in HDDs same as in SSDs. The proper way to do this is full disk encryption, and if that's not possible, physical destruction.
There’s very little need to sledgehammer anything given realistic attacker models.
Job done…
So it made sense to me that a physical erasure prior to recommission would be good. There’s also regulatory/compliance checkboxes (be them effective or not).
I think the pm-suspend/wake 'reinits' (for lack of a better word) the drive and doesn't set the magic frozen bit.
I'd love to know from someone who has the actual tech details vs. my half-remembering an explanation from a wiki.
And Yubikey don't leak secrets.
If your system is compromised to the point that someone gets access to the full disk decryption key protected by your Yubikey, you've got bigger problem than securely erasing the disk.
Need to recommission a disk? dd to the disk because why not. Some sectors didn't get dd'ed? Well, the bad guys need your Yubikey too.
So, really, what do we think about Yubikeys?
Are people now going to steal your Yubikey in addition to finding the sectors that weren't overwritten by dd?
and is there something that prevents someone from brute forcing that pin/password if they have access to the Yubikey?
I've not used a Yubikey in this way before, sounds really neat.
That shouldn't be the case, right?
I once used secure erase on a nvme SSD and found some of the partition table was still present when going to reformat, even though the operation indicated success. I eventually tracked it down to the drive being mistakenly mounted at the time of the secure erase. So there is your other failure mode, making sure you and your software utilities also perform the secure erase correctly.
ZFS should then throw all kinds of errors once it notices that all the super locks and other FS metadata is missing. But a scrub should cause ZFS to simply fix that via normal resilvering.
If you erase the volume, regardless of whether you had FileVault enabled or not, the key is deleted [0].
If FileVault isn’t enabled on a Mac with the T2 chip during the initial Setup
Assistant process, the volume is still encrypted, but the volume key is protected
only by the hardware UID in the Secure Enclave.and
When deleting a volume, its volume key is securely deleted by Secure Enclave
[0] https://www.apple.com/mideast/mac/docs/Apple_T2_Security_Chi...----------------------------------------------- Incorrect ramblings below: -----------------------------------------------
Apple recommends setting up FileVault on their SSDs. It is literally the only way to ensure that the data on the SSD is not recoverable.
And you should do this before you put anything ON the Mac.
If you add a file and only later encrypt the drive, you have no guarantee that that file still isn't somewhere readable one way or another.
This is important when you think about buying a Mac and then choose to return it 3 days later.
Apple states [0]:
Note: With a solid-state drive (SSD), secure erase options are not available in Disk Utility. For more security, consider turning on FileVault encryption when you start using your SSD drive.
On their dedicated encryption page [1] they do state that devices with T2 are encrypted by default: Note: If you have an iMac Pro or another Mac with an Apple T2 Security Chip, the data on your drive is already encrypted automatically. However, turning on FileVault provides further protection by requiring your login password to decrypt your data.
However I can't find any reference to see how to reset that built-in key.[0] https://support.apple.com/guide/disk-utility/erase-and-refor...
[1] https://support.apple.com/guide/mac-help/encrypt-mac-data-wi...
I don't think it's necessary to delete it.
But if you want, write the disk fully
If you want reuse... then a handful of fill/erase cycles with random data is probably your best bet, even then, there will still likely be some overprovisioned blocks with prior data.
Encryption and throwing away the key doesn't do more than random data to fill said drive.
Sure there would be performance implications, but who would care? You might just want to store a key for some full performance encrypted data that you would like to be able to actually remove access to. Sometimes performance is not the most important thing to optimize for.
Technical reasons are all over the place, because the only "convention" you could possibly be referring to is the practice of having layers of abstraction for compatibility purposes. If you want to re-design your entire storage stack to accommodate every new technology, then it's trivial to ensure deleteability in each from-scratch re-design. But as soon as you want to use flash memory to build a drop-in replacement for hard drives, it gets quite difficult to retain this property without making huge sacrifices to more desirable properties.
This has nothing in particular to do with flash vs spinning rust. A copy on write file system for example generates tons of information leaking copies all the time, but could trivially be be changed so that some files did not leak in that way.
This is truly one of those issues that exists simply because no one can be bothered to fix it.