LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-04-2015, 05:00 AM   #16
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57

Ssh is only taken as a sample of code that prevents password theft from ram, not for actual ssh connections.

The modifications would be just additional code that uses the password as a passphrase to mount selected truecrypt-clone containers, probably by calling the CLI of the truecrypt clone using the C system() call.

Or modify the truecrypt clone sources instead. They'd have protection against ptrace would they not?

Could use a separate original instance of ssh for ssh connections if wanted.

Last edited by Ulysses_; 01-04-2015 at 05:22 AM.
 
Old 01-04-2015, 06:03 AM   #17
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
You just broke your security.

The system() is not a secure library function. It permits side effects as it has to use bash to interpret the actual command - and that, at a minimum, exposes your password on the command line, or to debugging attached to the shell. Also see side effects - bash also interprets any special characters that may be in the command string.

ssh already supports multiple connections (see port forwarding).

Last edited by jpollard; 01-04-2015 at 06:05 AM.
 
Old 01-04-2015, 06:13 AM   #18
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
Surely attaching to a shell that lives for a few milliseconds must be a challenge. What do you mean by special characters in the command string?
 
Old 01-04-2015, 07:20 AM   #19
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
The simple things - ()*`';|$ And there are more. As for "that lives for a few milliseconds"?

Security is not a state - it is a process of doing things and paying attention to the details. ANY thing that can expose a secret is exposing that secret. And just how long does it take when something hangs for a while? Or what happens if an error occurs? Or what happens if something simple like a file name with rm -rf * occurs? Or one with a file name like "printenv >/tmp/public_file", or files with blanks embedded (ran across one using authors names - wasn't a problem for years, until there was a chinese name like fāng'àn... Handling special characters is NOT a simple process, and isn't static.) And since system() is using a shell, WHICH shell? Solaris/AIX/Linux don't all use the same one, and then there is Windows.

http://xkcd.com/327/

There is also the issue of systems that track process (pacct records, audit records,...) some will record every parameter.... and thus record any passwords that happen to be on the command line.

The system() function (along with popen, printf, sprintf, ...) are not secure library functions.

Last edited by jpollard; 01-04-2015 at 07:30 AM.
 
Old 01-04-2015, 09:39 AM   #20
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
Are you talking about invalid arguments in the ssh command line?

Invalid arguments in system() cannot appear because they are hardcoded in the C source code in my usage, except the password/passphrase. Any special characters in the passphrase are trivial to check and say "Sorry, passphrase must only contain letters a-z, A-Z or digits 0-9."

For absolute security, it could be a direct call to the truecrypt-like software's main() function if the sources are build into one.

Last edited by Ulysses_; 01-04-2015 at 09:42 AM.
 
Old 01-04-2015, 10:31 AM   #21
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You should also consider what happens to the password when the script stops running. It is still in RAM and can be found by scanning RAM for it.
 
Old 01-04-2015, 01:55 PM   #22
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Here's an idea. Have a password file inside an encrypted container. All you need to do is mount this container and use the password file inside for opening any further containers. That way you put the password only once and it isn't stored in RAM.
 
Old 01-04-2015, 03:19 PM   #23
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by Ulysses_ View Post
Are you talking about invalid arguments in the ssh command line?
Yes.
Quote:

Invalid arguments in system() cannot appear because they are hardcoded in the C source code in my usage, except the password/passphrase. Any special characters in the passphrase are trivial to check and say "Sorry, passphrase must only contain letters a-z, A-Z or digits 0-9."
You think so? the shell is a very powerful tool - and it can import things that will change how the command is interpreted. Things like line termination, parameter separation, even .bashrc... which can contain any number of commands.

And limiting the passphrase in that manner makes it easier to hack. Passwords SHOULD have a character set as large as possible. It makes for much stronger passwords.

Quote:
For absolute security, it could be a direct call to the truecrypt-like software's main() function if the sources are build into one.
At which point you are rewriting the entire truecrypt-like program to be a function, and NOT using the system() library function.

Note, you are now expanding the scope of ssh - and making it harder to validate.

It is already hard enough as it is.

Besides, you could use fork/exec yourself and set the parameters how you like - and completely bypass the shell entirely. Though that doesn't prevent the exposure of a password in the applications parameter list, or possibly through the application environment. It is still possible to also substitute a different program. Consider what might happen within a chroot jail - what it puts as the program name can be anything.

And yes - this is stretching. But you do have to consider all the places and things that ssh is being used now.
 
Old 01-05-2015, 06:26 AM   #24
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
Looks like preventing theft of a password from ram is hopeless against malware with root privileges. Only normal user malware can be prevented from stealing a password. And even that with a lot of precaution.

Would a truecrypt clone use the same tricks as ssh against ptrace? Is this trick a common practise in security software?
 
Old 01-05-2015, 07:25 AM   #25
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Should, but normally isn't done. It makes debugging very difficult. One reference for disabling ptrace outside of programming tricks is at http://fedoraproject.org/wiki/Featur...inuxDenyPtrace.

Though this is about cross security domain blocks, the capability to disable ptrace is in the system.
 
Old 01-05-2015, 08:45 AM   #26
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
There is some software in the windows world that allows you to automatically enter passwords to forms and other places.

How would the linux equivalent protect against theft of passwords from ram?

When firefox stores passwords, how does it ensure they cannot be stolen from ram?

Last edited by Ulysses_; 01-05-2015 at 08:49 AM.
 
Old 01-05-2015, 01:49 PM   #27
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by Ulysses_ View Post
There is some software in the windows world that allows you to automatically enter passwords to forms and other places.

How would the linux equivalent protect against theft of passwords from ram?
Windows doesn't protect against the theft.
Quote:

When firefox stores passwords, how does it ensure they cannot be stolen from ram?
It doesn't.

1. only the owner (and root) may access the memory.
2. all other processes are blocked.

As I have said earlier, it is possible for SELinux security labels to define a compartment that even root cannot access. But it is a bit tricky to setup, but once setup is very easy to use.

Last edited by jpollard; 01-05-2015 at 02:13 PM.
 
Old 01-05-2015, 02:54 PM   #28
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,246

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Quote:
Originally Posted by Ulysses_ View Post
When firefox stores passwords, how does it ensure they cannot be stolen from ram?
Yes, the answer is "it doesn't". That is waaaay beyond the standard of due diligence that anyone's actually expected to do.

I think it's worth pointing out that any malware capable of doing that would have to have been written specifically to target a single specific version of Firefox.

Also: I did a quick Amazon search for related material, and this one certainly looks relevant: http://www.amazon.ca/dp/1118825098

Finally, I'd recommend approaching this from the reverse angle. In order to answer "how would I prevent malware from stealing passwords from RAM" (and evaluate the risk of that actually happening), you first need to answer: "how would I write malware that steals passwords from RAM?"

Last edited by dugan; 01-05-2015 at 03:02 PM.
 
1 members found this post helpful.
Old 01-05-2015, 03:05 PM   #29
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by dugan View Post
Finally, I'd recommend approaching this from the reverse angle. In order to answer "how would I prevent malware from stealing passwords from RAM" (and evaluate the risk of that actually happening), you first need to answer: "how would I write malware that steals passwords from RAM?"
That is the right question.
 
Old 01-05-2015, 03:10 PM   #30
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,246

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Quote:
Originally Posted by Ulysses_ View Post
Let's say a script prompts for a password and then uses the password to open an encrypted container or login to somewhere remotely or whatever.

If the script keeps the password in ram while it's looping doing whatever its purpose is, can NON-root malware steal the password?
You realize that the malware that would most likely be used to steal that password is a keylogger, right?

Last edited by dugan; 01-05-2015 at 03:19 PM.
 
  


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
could SystemTap be used by malicious person to steal ssh password easily ? wzis Linux - Security 4 05-03-2014 07:43 PM
how to specify password for sudo command when running bg process? sneakyimp Linux - Newbie 9 06-30-2010 02:14 PM
Freeing I/O resource held by zombie process kronesr Linux - Software 2 02-22-2010 11:29 AM
child process usses same amount of ram as parent process socialjazz Programming 7 10-19-2006 05:48 PM
Forward X / Steal a process sval Linux - General 0 12-30-2004 10:32 AM

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

All times are GMT -5. The time now is 03:38 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