public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: linux-audit@redhat.com
Subject: Re: auditing access to directories with restricted access
Date: Wed, 04 Jun 2014 17:57:30 -0400	[thread overview]
Message-ID: <1904584.c66v8rouPX@x2> (raw)
In-Reply-To: <94D4A88F8AC34646A5288D11318F5D5B0D7B7FF3@GDUKADH841.uk1.r-org.net>

Hello,

On Wednesday, June 04, 2014 12:13:02 PM jon.bird@generaldynamics.uk.com wrote:
> I am trying to set up some audit rules to monitor failed accesses to a given
> folder - here is the basics:
> 
> -a exit,always -S open -k fk_open -F dir=/recorder/ -F success=0
> 
> Here are the permissions on the folder:
> 
> drwxrwx---    3 red      red           4096 Jun  4 10:39 recorder
> 
> and the contents:
> 
> drwxrwx---    3 red      red           4096 Jun  4 12:05 .
> drwxr-xr-x   21 root     root          1024 Jun  4 10:38 ..
> drwx------    2 root     root         16384 Apr 24 15:49 lost+found
> -rw-rw----    1 root     root             6 Jun  4 12:05 test.txt
> 
> If I run as user "red" ie. Who does have permission to write to this folder
> but then try and replace the "text.txt" file (which is owned by root) I
> get:
> 
> reduser@unit:~ echo test >test.txt
> -sh: can't create test.txt: Permission denied
> 
> Along with a corresponding entry in the audit log which is what I'm
> expected.
> 
> However if I run as another use which does not have permission to access
> this folder and try the same thing:
> 
> blackuser@unit:~ echo test >/recorder/test.txt
> -sh: can't create /recorder/test.txt: Permission denied
> 
> But I don't get anything captured in the audit log. I've tried a few
> incarnations of the rule, including setting up similar arrangements and
> having the daemon monitor the parent folder (thinking the access will show
> up there) but I can't get this scenario to be detected by the audit daemon.
> If I remove the file system filter (ie. So I see all failed accesses) then
> it does get logged but this generates way too much traffic to be of much
> use. I've also done an strace call around the command and verified that (in
> this latter scenario) is it definitely the open call which is generating
> the permission denied error and it is.
> 
> This is using audit-2.3.6 on a 3.2.55 kernel.
> 
> Any help appreciated,

This is a kernel problem. I recall seeing a patch on this mail list over a 
year ago purporting to allow audit events when path resolution failed. The 
issue as I remember goes something like this...

Files are really identified by device and inode number. In order to be more 
user friendly, we allow watches which pass a path name. The kernel really 
converts that to device and inode and watches for that. When an access gets 
denied such that the path cannot be converted to the device and inode to see 
if it matches a rule, then you won't get an event.

Like I said, I have seen a patch that supposedly fixed it by Eric Paris. But I 
don't know if it got replaced during some re-writes, or it didn't make it 
upstream, or it only provides results some of the time. But I really think its 
reasonable to expect to get a denied event as you described above. Maybe Eric 
can chime in about this.

-Steve

  reply	other threads:[~2014-06-04 21:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04 12:13 auditing access to directories with restricted access jon.bird
2014-06-04 21:57 ` Steve Grubb [this message]
2014-06-05  9:01   ` jon.bird
2014-06-18 11:54   ` Jonathan.Bird

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1904584.c66v8rouPX@x2 \
    --to=sgrubb@redhat.com \
    --cc=linux-audit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox