I want to store some data in a variable (and I know variables are stored in memory). Does that data in memory get encrypted? Also, is it possible for software to be able to read the variable names stored in memory and be able to actually extract the data from it?
One of the techniques to prevent the data accessed across different guests/domains/zones/realms is memory encryption. With memory encryption in place, even if any of the isolation techniques have been compromised, the data being accessed is still protected by cryptography.
But with advancements in memory encryption, the RAM can actually be always encrypted, with data being decrypted only within the CPU.
Full memory encryption Encryption, which prevents data visibility in the event of its unauthorized access or theft, is commonly used to protect Data in Motion and Data at Rest and increasingly recognized as an optimal method for protecting Data in Use. There have been multiple projects to encrypt memory.
Android 5.0 up to Android 9 support full-disk encryption. Full-disk encryption uses a single key—protected with the user's device password—to protect the whole of a device's userdata partition. Upon boot, the user must provide their credentials before any part of the disk is accessible.
Memory is not encrypted on any platform I know about. It would be of limited value anyway, because the processor must, in general, operate on plaintext data, so the data must be in plaintext on the machine somewhere.
Instead, modern operating systems (and most historical ones) use memory protection to allow only certain processes access to certain memory pages. Every memory page comes with read, write, and (sometimes) execute permissions. The operating system kernel is in charge of handling those permissions on context switch to grant or deny access to memory pages per-process as needed.
Saltzer and Schroeder's 1975 paper The Protection of Information in Computer Systems describe a mechanism using segments, rather than pages, but the principle has remained unchanged for decades.
Typically, any process-owned memory page is readable by a process with high-enough privilege; the OS kernel certainly can modify any page of memory, and it can choose to delegate that privilege to user processes too. The ptrace(2)
system call on Linux provides a debugger-backdoor that can be used to implement read-only memory inspection systems such as strace(1)
or ltrace(1)
or gdb(1)
, or memory-modification systems such as gdb(1)
and ptrace
-based sandbox environments.
Or, a core file can be dumped, under certain situations (see core(5)
and setrlimit(2)
manpages), containing the contents of the process's memory. This is one reason why it is important to clear memory of important data before release.
I was part of a team that worked on encrypting pointers (non-PTO link) in running programs. The overhead was amazing, and the number of corner cases was even more astonishing. Using these techniques for common programs is probably not practical, though I could imagine a restricted environment where encrypted memory or control structures is a feasible approach. (Though probably other techniques would be more appropriate.)
Okay, so I want to store some data in a variable (which, I know, variables are stored in memory) - does that data in memory get encrypted?
NO
Also, is it possible for software to be able to read the variable names stored in memory and be able to actually extract the data from it?
Names or values?
For values:
You mean a different program, not yours, to access it and read it? Yes, it's possible, depending on OS it may be tricky or trickier, but doable.
For names: Depends on how you build your software - if you leave debug info in it - it's very easy to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With