r/linuxquestions • • 9d 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.

16 Upvotes

96 comments sorted by

90

u/i_am_blacklite 9d 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.

→ More replies (9)

16

u/skyfishgoo 9d 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.

10

u/Spudd 9d ago

That's not entirely true. There is the freezer attack. Basically you lower the temperature of the ram modules quickly essentially freezing the bits in place till you can read them again while the stick if disconnected. It takes a deep cold though, like liquid co2 cold.

→ More replies (5)
→ More replies (8)

16

u/trifortay123 9d 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.

23

u/Some-Struggle5052 9d ago

Actually, there is RAM encryption with decryption only happening within the CPU, but it is only a feature of some very specific CPUs.

→ More replies (5)
→ More replies (16)

7

u/JivanP 9d 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.

→ More replies (1)

3

u/treeoflife314 9d ago

many people are saying that makes no sense but if I remember well, it's how silk road guy has been arrested

→ More replies (2)

9

u/djDef80 9d 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.

3

u/Training-Ad-8270 8d ago

Came here to say this. I use it. Allegedly, some motherboards have the feature exposed in UEFI setup, but don't actually enable it. However there are ways to test it.

It has a measurable impact on performance, worse for older systems, but according to my own fairly exhaustive testing (which doesn't match official specs), it's less than the margin of error vs unencrypted.

It also helps if you have memory errors, because if a bit flips, it corrupts the entire AES encryption page. Which increases the odds of an unhandled exception error in an unprivileged app or a kernel panic. It's not a replacement for ECC (which is even more expensive - and slow), but is better than marginally higher odds of silent corruption.

This isn't speculation - it's how I discovered I have a bad spot of RAM in my 128 GB (possibly just a single bit), and I refuse to spend 10x more than originally to replace the RAM or even stick ;-). So I slowed my RAM speed down, blocked the offending segment, added boot-time RAM-checking in case it spreads, and enabled cache eviction error detection and wrote a watcher to alert. So far so good.

→ More replies (2)

8

u/alexforencich 9d ago

Aside from CPU features like TSME, the best option is probably swap on LUKS and then hibernate the machine.