LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-30-2015, 04:46 PM   #1
Stuffe
LQ Newbie
 
Registered: Dec 2014
Posts: 14

Rep: Reputation: Disabled
Can process ram be secured?


I would like to run a service that relies on a secret key that I really do not want to fall into the hands of hackers. That would be a complete disaster really. I am not a Linux export so this might be dumb, but this is my idea:
Have a program load the secret key from a file and into a variable (ram) and then (thoroughly) delete the file. The program would never stop running and if it did, I would have to copy the key to the server again from offline storage. But is there a way to have kernel level protection of process ram, so that no other process can read it?
The reason why I like the idea of storing it in ram is that if the computer is turned off, the data becomes unrecoverable after only a few seconds.

Again, I don't know if this is dumb. What do you guys think?
 
Old 01-30-2015, 04:58 PM   #2
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I know libgcrypt supports secure memory:
Quote:
Libgcrypt uses a concept known as secure memory, which is a region of memory set aside for storing sensitive data. Because such memory is a scarce resource, it needs to be setup in advanced to a fixed size. Further, most operating systems have special requirements on how that secure memory can be used. For example, it might be required to install an application as “setuid(root)” to allow allocating such memory. Libgcrypt requires a sequence of initialization steps to make sure that this works correctly. The following examples show the necessary steps.
https://www.gnupg.org/documentation/...ng-the-library

You could for example use the 'gcry_malloc_secure' function to allocate secure memory.
 
Old 01-30-2015, 05:10 PM   #3
cepheus11
Member
 
Registered: Nov 2010
Location: Germany
Distribution: Gentoo
Posts: 286

Rep: Reputation: 91
Quote:
Originally Posted by Stuffe View Post
Have a program load the secret key from a file and into a variable (ram) and then (thoroughly) delete the file.
Why would the key be in a file in the first place? If the key has been on an unencrypted disk at some point in time, you already lost: The filesystem driver might move the file around for performance/resources/load balancing/fragmentation reasons and not sanitize the old version, and modern filesystems have a journal which contains traces of previous file operations. Do NOT allow key data to get on disk!

Persistent encryption systems work with a container header which is used to calculate the key with data provided from user-supplied password(s) and/or keyfile(s). In linux, the software is called cryptsetup-LUKS. Use it, instead of writing your own. If you are not a real security genius, chances are that your own software forgets to secure data from being written to disk (think swap...).

Last edited by cepheus11; 01-31-2015 at 03:40 PM.
 
Old 01-30-2015, 10:31 PM   #4
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
In linux in a c program you can lock a part of memory or whole process memory(If it is small or your are root) using mlock and mlockall functions. Then after using that memory you have to zero out it. Them unlock them. This function prevents the kernel from swapping the memory to swap also.
 
Old 01-31-2015, 01:20 PM   #5
Stuffe
LQ Newbie
 
Registered: Dec 2014
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thank you for the feedback guys. I will keep these things in mind. veerain, couldn't you theoretically just DLL inject into the program ram space though?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to know a process use ram? tyl90 Linux - Newbie 3 11-14-2011 09:10 PM
RAM used by process landysaccount Linux - Newbie 3 11-27-2008 06:51 AM
What about non secured cmd lines through AIM ?? (ssh like, non secured) frenchn00b Debian 2 11-17-2008 01:52 AM
child process usses same amount of ram as parent process socialjazz Programming 7 10-19-2006 05:48 PM
process to use more than 2GB RAM simplyrahul Linux - General 12 10-27-2004 08:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration