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 04-02-2012, 09:12 AM   #1
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Log all root activity with actual uid


Because of PCI requirements we need to log all commands issued by root with uid of the "original" user - that is, we always login via ssh with personal accounts and then "su" to root. All commands issued by us after su-ing to root must be logged with our personal uid.
I have tried with:
* auditd, it doesn't log all commands & those logged are with only root's uid.

* pam_loginuid.so, added this to files sshd, su, su-l, sudo:
session required pam_loginuid.so
session include common-session
This should (quote) "Audit allows you to consistently track a user's actions from login right through logout no matter which identities this user might adopt by using audit IDs that are created upon login and handed down to any child process of the original login process."
But it doesn't keep users uid.

* and by adding this to /root/.bashrc:
PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION")'
This sends all commands to /var/log/messages, but only with root's uid.

So so far all in vain, after "su -" everything logged is logged only with roots uid.
We could use "sudo", but that is very unpractical for several reasons (no tab-completion for "root-only" directories/files, problems piping output, bash built-in commands doesn't work..)

So does anybody have an idea how to get this logging to work?
 
Old 04-02-2012, 09:15 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Sounds to me that using "sudo -i" could be of use. When doing that instead of "su -" you will have environmental variables in your shell e.g. $SUDOUSER which gives you much more clarity over who the shell actually is.
 
1 members found this post helpful.
Old 04-02-2012, 11:06 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by pingu View Post
I have tried with: auditd, it doesn't log all commands & those logged are with only root's uid.
Audit logs the auid but we don't know your rule set ('auditctl -l') and the result (say 'ausearch -ts today -ul [LOGINUID]').


Quote:
Originally Posted by pingu View Post
So does anybody have an idea how to get this logging to work?
I don't do this for PCI-DSS but I use a mix of the CAPP and LSPP rule sets + sudo as entry point + rootsh which provides command and output logging.
 
1 members found this post helpful.
Old 04-03-2012, 03:52 AM   #4
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Original Poster
Rep: Reputation: 127Reputation: 127
acid_kewpie: Thanks a lot, I knew about "sudo -i" but never heard about that environmental variable! (Only, at least in SLES, it's $SUDO_USER).

unSpawn:
Sorry, I should've been more informative here. The reason for not giving more info about my auditd config is that I've read a lot about it and found nothing to aid me. My conclusion was that auditd simply could not do what I wanted.

Now even though acid_kewpie's suggestion is sufficient, I still would like to dig deeper into auditd.
All my tries with it has given the same: "su -" sets auid to "0"
Now since I've messed around a lot with auditd, the last thing I did yesterday was to restore original config so unfortunately I can't really tell exactly what I was trying.
But maybe you can put me in the right direction here, as I said I have read a lot about auditd without finding anything relevant about this specific issue.
 
Old 04-03-2012, 05:37 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
I'd say load one of the rule sets I mentioned like
Code:
sed -e "s|^#-a|-a|g" /usr/share/doc/audit-1.8/lspp.rules|grep -v ^#|grep .|xargs -iX auditctl 'X'
or add rules to your default audit.rules like with
Code:
find /sbin /bin /usr/sbin /usr/bin -type f -printf "auditctl -a always,exit -F path=%p -F perm=x -k BIN_test\n"|/bin/sh
and post the output after Doing Stuff.
 
  


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
activity log linuxhippy Slackware 5 11-16-2005 06:55 PM
how to log port activity irfanhab Linux - General 4 06-18-2005 12:07 AM
suspicious log activity hoedad Linux - Newbie 3 07-26-2004 07:33 AM
Wrong uid in /var/log/messages wfhoney Linux - Security 1 02-12-2004 01:57 PM
Uid problem, can't log in computergirl Linux - General 5 05-23-2003 06:09 PM

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

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