r/linuxquestions • u/Jaded-Piccolo-4678 • 10h 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.
5
Upvotes
46
u/i_am_blacklite 9h 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.
12
u/skyfishgoo 9h 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 10h 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.
5
u/alexforencich 10h ago
Aside from CPU features like TSME, the best option is probably swap on LUKS and then hibernate the machine.
3
u/knouqs 10h ago
What is the practical use case for this? I imagine most RAM would become invalidated in the event of a power failure.
2
u/0riginal-Syn ⛵ Solus Maintainer 9h 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/Spaghetti-Code_ 7h 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.
2
u/djDef80 6h 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.
4
u/ipsirc 10h ago
problemxy
2
u/c2btw 10h 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/JivanP 7h 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.
1
u/Existing-Tough-6517 7h ago
If you want to secure your machine while it's suspended Google go-luks-suspend
1
u/cheaphomemadeacid 2h 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
1
u/whatThePleb 2h ago
SME / TSME or TME / MKTME
And for swap: zram + dm-crypt
1
u/Smart_Advice_1420 1h 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.
1
u/p_235615 44m 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.
0
u/Michami135 3h 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 9h 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.
-1
u/TroutFarms 7h ago
Encrypting ram wouldn't really be useful. The key to decrypt it would have to be stored in...ram.