We have IoT gateways that run Linux 5.4.31 kernel. These gateways need to manage thousands of devices which are mobile and each has a unique encryption key. The idea is to fetch the key of a device from a server (via secure channel) when the device enters the range, use it for decryption as long as the device is in the range and delete the key from memory when it leaves. Decryption must be done on the gateway since we have to do specific actions depending on the received data.
We want to store the keys on RAM unencrypted because we don't want the overhead of decrypting the keys for each time we access them. We have following assumptions:
- Physical access to the gateways are not possible.
- The service is running under a non-root user.
- An attacker might gain access to the gateway as a non-root user (that is different from the service user if that matters).
- An attacker might pull off a buffer overflow attack.
What are the options of an attacker to access the encryption keys on the RAM under these assumptions if
- We store the keys on a statically allocated memory (via static keyword in C, not in stack)
- We store the keys on dynamically allocated memory (it would probably be one-time allocation since we have limited resources).
Also what restrictions should we put on a non-root user, e.g. they can't access swap memory, core dumps, install packages, use gdb, etc. to prevent access to the process RAM?
Note: If the attacker has root access then they can access to all the keys using the private key that is used to access the server anyway, so we do not consider this case for this question.