LinuxQuestions.org
Visit Jeremy's Blog.
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 02-09-2016, 03:56 PM   #1
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
getting samhain notifications about session files in /var/lib/php5/


I'm getting tons upon tons of samhain notices and I've been picking through them hoping to determine if there's really anything wrong. One of the greatest sources of spurious notifications is the sess_* files created by apache in /var/lib/php5. Some example filenames:
Code:
-rw-------  1 www-data www-data    202 Feb  9 21:17 sess_vdp08n6gnm7v46m4p34qk20641
-rw-------  1 www-data www-data    160 Feb  9 21:28 sess_vpemr9har228gmrvccuo3k1g76
-rw-------  1 www-data www-data     50 Feb  9 21:22 sess_vuv83getivrgjo7imn7v5k1uu5
I cannot seem to determine how to edit my /etc/samhain/samhainrc files to prevent notifications when these files are created, modified, and deleted. The directive in the samhainrc file that calls for these notifications is apparently this one:
Code:
[ReadOnly]
dir = 99/var
which, if i'm not mistaken, says that the /var directory is to be read-only so any changes should trigger a report UNLESS one of the subsequent exceptions countermands this directive. I have in fact added a couple of ignore directives hoping to prevent the notifications:
Code:
[IgnoreAll]
# all kinds of dir directives here
# this doesn't work
file = /var/lib/php5/sess_*
# recently added this one which doesn't work either
dir = /var/lib/php5/sess_*
I only just added that last directive a few minutes ago. Prior to adding it, I was getting (and I believe I still am) notifications like this one:
Code:
-----BEGIN MESSAGE-----
2016-02-09T18:53:01+0000 some-hostname.ec2.internal
<log sev="CRIT" tstamp="2016-02-09T18:52:47+0000" msg="POLICY [ReadOnly] --------T-" path="/var/lib/php5" ctime_old="2016-02-09T15:50:18" ctime_new="2016-02-09T16:39:04" mtime_old="2016-02-09T15:50:18" mtime_new="2016-02-09T16:39:04"  />
-----BEGIN SIGNATURE-----
6BDB4C19F3778FE68D638FDE65F121EFA787A944E63D507F
000678 1447117289::some-hostname.ec2.internal
-----END MESSAGE-----
Then if I refresh my samhain log file and catalog and restart samhain, I might get a dozen notifications like this:
Code:
-----BEGIN MESSAGE-----
2016-02-09T21:07:36+0000 some-hostname.ec2.internal
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_0lkqer22tljq2af6d4fck7irr7" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_0gbcmpv5rhj1955q19msnd7ib1" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_0fg2nps8v4ci8m0o3s7buiplk1" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_0fd8squb717siqqbravtomhv31" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_0e71o8e9kf42vocvdglne2ltc0" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_0caj76bhn387m166gh8mehd2n0" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_0btk0ovauk8t48ioradmbc0fh1" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_08ddnl3ii6tbnhn9pjgdsre675" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_06ta137npbk19olkmopl3k86s0" />
<log sev="CRIT" tstamp="2016-02-09T21:07:36+0000" msg="POLICY NODIRECTORY" path="/var/lib/php5/sess_05c0p7qs6tna87va34bnfuha64" />
-----BEGIN SIGNATURE-----
97A44019EE9BC11BEE479C35A7144974BA5B7E3B6843E926
000002 1455051774::some-hostname.ec2.internal
-----END MESSAGE-----
I believe these files are clearly benign. How can I prevent the samhain notifications? I would consider adding an ignoreall for /var/lib/php5 but there is one other directory in there which seems to need monitoring, namely /var/lib/php5/modules.

Any help would be much appreciated.
 
Old 02-11-2016, 05:29 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Try this?
Code:
[IgnoreAll]
# Report no modifications for these files/directories. Access failures will still be reported.
dir=-1/var/lib/php5/
BTW monitoring PHP session files is not likely going to give you much of a heads up things are awry (IMHO).

Last edited by unSpawn; 02-11-2016 at 05:31 PM.
 
Old 02-12-2016, 02:50 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Thank you so much for your suggestion. I've tried numerous things.
Quote:
Originally Posted by unSpawn View Post
Try this?
Code:
[IgnoreAll]
# Report no modifications for these files/directories. Access failures will still be reported.
dir=-1/var/lib/php5/
I've looked at the documentation regarding these recursion depth settings and it sounds like this would prevent samhain from looking inside the folder at all. I'm not certain but I think this presents a problem because I do want samhain to keep an eye on one of its sub-folders, /var/lib/php5/modules. Or don't I? I don't really know what gets put into that folder.

Quote:
Originally Posted by unSpawn View Post
BTW monitoring PHP session files is not likely going to give you much of a heads up things are awry (IMHO).
I have no interest in monitoring these files at all. It was due to the default settings in samhainrc that the /var folder is being monitored:
Code:
[ReadOnly]
dir = 99/var

[IgnoreAll]
dir = -1/var/cache
dir = -1/var/backups
#dir = -1/var/games
#dir = -1/var/gdm
dir = -1/var/lock
dir = -1/var/mail
dir = -1/var/run
dir = -1/var/spool
dir = -1/var/tmp
#dir = -1/var/lib/texmf
#dir = -1/var/lib/scrollkeeper
 
Old 02-13-2016, 03:11 AM   #4
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 sneakyimp View Post
I'm not certain but I think this presents a problem because I do want samhain to keep an eye on one of its sub-folders, /var/lib/php5/modules.
You could try (as in test things yourself before questioning them?) first blocking /var/lib/php5 and then explicitly enabling /var/lib/php5/modules in a section below it?


Quote:
Originally Posted by sneakyimp View Post
Or don't I?
PHP documentation say it puts dynamic libraries there. Find out how and when these libraries get there, who owns them and if the mechanism that puts them there alters those files?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Judging samhain notifications. Are these problematic? If not, I could use config help sneakyimp Linux - Security 3 07-08-2014 05:54 PM
[SOLVED] Sanity Check: plausible reason for mtime change on /var/lib/php5 leslie_jones Linux - Security 2 02-11-2012 08:44 AM
Information about the /var/lib/php/session file kaplan71 Linux - Software 1 07-19-2010 11:53 AM
Can Samhain log my entries in /var/log/secure and /var/log/mesage to a central server abefroman Linux - Software 2 04-13-2008 04:13 PM
Files in /var/lib/dpkg directory kushalkoolwal Debian 3 05-04-2007 02:05 PM

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

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