r/linuxquestions • u/Jaded-Piccolo-4678 • 14d ago
Ram Encryption
Are there any tools or projects that targets linux and that encrypts your RAM after for example 10 minutes of inactivity or some sort of this ?
Of course it's not gonna encrypt literally every byte in RAM, but most of em and keep only maybe few processes alive and not froze , so you can decrypt back after typing a passphrase.
14
Upvotes
91
u/i_am_blacklite 14d ago
If you need to protect yourself from someone that has the capabilities to extract data directly from physical RAM then you need so much more help than you're going to get from a reddit post.
17
u/skyfishgoo 14d ago
if you don't want anyone to access whats saved in ram when you are not at your machine then just shut it down.
ram forgets when it loses power.
16
u/trifortay123 14d ago
You can't just toggle ram encryption. The point of ram is quick access storages directly for the CPU to use. It's can't just simply be encrypted. If the glowies take your stuff it's over anyways. If a hacker takes your stuff it's over anyways. The point of encryption is to keep your data safe at rest. Just like if you have full disk encryption. If that computer OS already on and booted up. You're screwed. But if they get ahold of it powered off you're fine. Now I do recommend encrypting swap space. It'll generate a random key every boot so if it gets turned off some ram can't be extracted from the disk because it's encrypted.
4
u/knouqs 14d ago
What is the practical use case for this? I imagine most RAM would become invalidated in the event of a power failure.
3
u/treeoflife314 14d ago
many people are saying that makes no sense but if I remember well, it's how silk road guy has been arrested
9
u/djDef80 14d ago
If you have a modern AMD CPU you may have memory encryption available in the bios under tsme -transparent secure memory encryption. All you have to do is toggle it on to benefit. Otherwise this feature is generally reserved for server grade Intel CPUs.
8
u/alexforencich 14d ago
Aside from CPU features like TSME, the best option is probably swap on LUKS and then hibernate the machine.
7
u/JivanP 14d ago
Vendor-specific implementations of RAM-level encryption do exist at the hardware level, such as Intel's SGX (Software Guard Extensions). This allows processes to decide that they want certain data they put in RAM to be encrypted, tell the CPU to do this, and tell the CPU to only keep decrypted versions of that data in the CPU's own registers, never writing that data to RAM in its decrypted form.
This is mostly useful for programs that handle extremely sensitive data (such as cryptographic secret keys) that they do not want any other process potentially getting access to via an OS-level vulnerability or adversarial subsystem. That is, it's for protecting one process's data from other processes that might try to read that data.
Despite this, there is basically no reason to be interested in "full-RAM encryption" in the same way that full-disk encryption is a thing, because the only benefit of this would be to keep data in RAM encrypted at rest, but the ability to get data out of RAM at rest is almost impossible in practice.
3
u/Spaghetti-Code_ 14d ago
You could look into CPU enclaves, but it's a more limited scenario. Homomorphic encryption too, but these are not designed for general purpose usage.
3
u/whatThePleb 14d ago
SME / TSME or TME / MKTME
And for swap: zram + dm-crypt
3
u/p_235615 14d ago
Some AMD EPYC server CPUs do exactly this - Secure Memory Encryption (SME) https://docs.amd.com/v/u/en-US/memory-encryption-white-paper
But not sure if any cheap consumer market CPUs can do something like that, so you will have to pay quite big to get that feature.
2
u/Existing-Tough-6517 14d ago
If you want to secure your machine while it's suspended Google go-luks-suspend
2
u/cheaphomemadeacid 14d ago
https://techblog.dev/posts/2023/08/encrypted-swap-partition-support-hibernation-suspend-resume-linux/ try looking at this instead, the idea is that once you "shutdown" and hibernate you get some safety
2
u/Ozmataz__Buckshank 14d ago
Usually motherboards do this with specific options. I know there is Data Scrambler, I can't remember the others... At least it's like this on AM5 motherboards.
4
u/ipsirc 14d ago
problemxy
2
u/0riginal-Syn ⛵ Solus Maintainer 14d ago
No, and there is no real practical reason to do so. Others have mentioned you can power off, but you can also HIbernate (suspend to disk) which takes everything and moves it to the disk, which I am assuming you have encrypted. That said I do not recommend it.
I have run a cyber and regulation business for the last 16 years. It is found to be a little paranoid on security, but this is not something I would concern myself with. If this was a major security concern for a user, there would be something already built and running on every system. Are there ways? Yeah, but they are very tough to do properly as long as you have proper security on your system (encryption, locking system when away, strong password / mfa).
2
u/c2btw 14d ago
Tails.is is where I would look for stuff like this. And this isn't going to be something's that togeled on and off, for one you would have to reread and then rewright the entirety of ram every time. 2 why. It's eitrer encyoted from boot or not at all
1
u/Smart_Advice_1420 14d ago
Sure. Create an encrypted ramfs mounted as a loopback device and point your application at that. Alternatively, handle it like some sort of zram and max out swappiness.
0
u/Michami135 14d ago
A better option might be to rig the inside of your case so it kills the power if opened. Light sensors, contact switches, mercury tilt sensors, etc.
-2
u/skreak 14d ago
The idea of encrypting ram makes so little sense I can't even think of an analogy to explain how little sense it makes.
-2
u/TroutFarms 14d ago
Encrypting ram wouldn't really be useful. The key to decrypt it would have to be stored in...ram.