aa-logprof drops exec denials
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| apparmor (Ubuntu) |
Fix Released
|
High
|
Steve Beattie | ||
| Precise |
Fix Released
|
High
|
Steve Beattie | ||
Bug Description
aa-logprof works great for profiles that are in complain mode only. It will not pickup denials that are from an enforcing mode profile however, which reduces its utility. This is confirmed on Ubuntu 10.10 (apparmor 2.5.1), Ubuntu 11.04 (apparmor 2.6.1) and Ubuntu 11.10 (apparmor 2.70~beta1).
This is a regression. aa-logprof has in the past worked fine with denials
removed: rls-mgr-p-tracking
Jamie, can you describe how you hit this, as I'm unable to reproduce it. In the example below auditd is not running:
$ cat tmp/my.sh
#!/bin/sh
cat "$@" > /dev/null
$ cat /etc/apparmor.
# Last Modified: Mon Mar 26 10:59:48 2012
#include <tunables/global>
/home/ubuntu/
#include <abstractions/base>
/bin/cat rix,
/bin/dash ix,
/home/
}
$ sudo aa-status | grep my.sh
/home/
/home/
$ tmp/my.sh /etc/fstab
cat: /etc/fstab: Permission denied
$ sudo aa-logprof
Reading log entries from /var/log/syslog.
Updating AppArmor profiles in /etc/apparmor.d.
Enforce-mode changes:
Profile: /home/ubuntu/
Path: /etc/fstab
Mode: r
Severity: 3
1 - #include <abstractions/
[2 - /etc/fstab]
(A)llow / [(D)eny] / (G)lob / Glob w/(E)xt / (N)ew / Abo(r)t / (F)inish / (O)pts
Adding /etc/fstab r to profile.
Profile: /home/ubuntu/
Path: /etc/resolv.conf
Mode: r
Severity: 2
1 - #include <abstractions/
[2 - /etc/resolv.conf]
(A)llow / [(D)eny] / (G)lob / Glob w/(E)xt / (N)ew / Abo(r)t / (F)inish / (O)pts
Profile: /home/ubuntu/
Path: /etc/resolv.conf
Mode: r
Severity: 2
1 - #include <abstractions/
[2 - /etc/resolv.conf]
(A)llow / [(D)eny] / (G)lob / Glob w/(E)xt / (N)ew / Abo(r)t / (F)inish / (O)pts
Adding /etc/resolv.conf r to profile.
= Changed Local Profiles =
The following local profiles were changed. Would you like to save them?
[1 - /home/ubuntu/
(S)ave Changes / [(V)iew Changes] / Abo(r)t
= Changed Local Profiles =
The following local profiles were changed. Would you like to save them?
[1 - /home/ubuntu/
(S)ave Changes / [(V)iew Changes] / Abo(r)t
Writing updated profile for /home/ubuntu/
$ cat /etc/apparmor.
# Last Modified: Mon Mar 26 11:04:45 2012
#include <tunables/global>
/home/ubuntu/
#include <abstractions/base>
/bin/cat rix,
/bin/dash ix,
/etc/fstab r,
/etc/resolv.conf r,
/home/
}
(note that resolv.conf access rejection was from a prior run of my.sh)
1. Create /tmp/foo.sh:
#!/bin/sh
cat /etc/fstab
grep root /etc/passwd
2. chmod 755 /tmp/foo.sh
3. sudo aa-genprof /tmp/foo.sh
Writing updated profile for /tmp/foo.sh.
Setting /tmp/foo.sh to complain mode.
...
[(S)can system log for AppArmor events] / (F)inish
(press 'f' (ie, don't run /tmp/foo.sh in another terminal or anything)
Reloaded AppArmor profiles in enforce mode.
...
Finished generating profile for /tmp/foo.sh.
4. verify it is loaded
$ sudo aa-status|grep foo
/tmp/foo.sh
5. run the script:
$ /tmp/foo.sh
/bin/sh: Can't open /tmp/foo.sh
6. run aa-logprof
$ sudo aa-logprof
Reading log entries from /var/log/syslog.
Updating AppArmor profiles in /etc/apparmor.d.
Enforce-mode changes:
Profile: /tmp/foo1.sh
Path: /tmp/foo1.sh
Mode: r
Severity: unknown
[1 - /tmp/foo1.sh]
(press 'a')
= Changed Local Profiles =
The following local profiles were changed. Would you like to save them?
[1 - /tmp/foo1.sh]
(S)ave Changes / [(V)iew Changes] / Abo(r)t
(press 's')
Writing updated profile for /tmp/foo1.sh.
8. Verify the profile was updated:
$ $ cat /etc/apparmor.
# Last Modified: Mon Mar 26 13:40:50 2012
#include <tunables/global>
/tmp/foo.sh {
#include <abstractions/base>
/bin/dash ix,
/tmp/foo.sh r,
}
9. Run the script:
$ /tmp/foo1.sh
/tmp/foo1.sh: 2: cat: Permission denied
/tmp/foo1.sh: 3: grep: Permission denied
10. run aa-logprof:
$ sudo aa-logprof
Reading log entries from /var/log/syslog.
Updating AppArmor profiles in /etc/apparmor.d.
(notice I wasn't prompted).
11. Run the script:
$ /tmp/foo1.sh
/tmp/foo1.sh: 2: cat: Permission denied
/tmp/foo1.sh: 3: grep: Permission denied
I'm not sure what this is as I did see it work a couple of time. I think this might be a timestamp checking issue. If I went slowly between running aa-genprof and aa-logprof it would work. If I went more quickly, it would not. This is not a result of kernel rate limiting, because I have entries in dmesg for the cat and grep denials.
So the issue here is that, due to logprof not taking into account some logging changes, it was dropping 'exec' events that occurred when the profile in question was in enforcing mode; it would catch it if it was in complain mode (because of the generated null profile on exec in complain mode). I've sent a patch for review to the upstream mailing list: https:/
However, with just that patch applied, I get a couple of perl warnings that patch 3/4 in that series addresses.
+ aa-logprof dropes exec denials
+ aa-logprof drops exec denials
This bug was fixed in the package apparmor - 2.7.102-0ubuntu3
---------------
apparmor (2.7.102-0ubuntu3) precise; urgency=low
[ Jamie Strandboge ]
* debian/
to describe Ubuntu's two-stage policy load and how to add utilize it
when developing policy (LP: #974089)
[ Serge Hallyn ]
* debian/
removed once stacked profiles are supported and used by lxc.
(LP: #978297)
[ Steve Beattie ]
* debian/
for change_profile onexec (LP: #963756)
* debian/
debian/
to support the 'in' keyword for value lists, and make mount
operations aware of 'in' keyword so they can affect the flags build
list (LP: #959560)
* debian/
exec events in complain mode (LP: #872446)
* debian/
dovecot imap-login profile (LP: #978584)
* debian/
log parsing library from dropping apparmor network events that
contain ip addresses or ports in them (LP: #800826)
* debian/
syntax and usage in apparmor.d(5) manpage (LP: #979095)
* debian/
for profiles without attachment specification (LP: #963756,
LP: #978038)
* debian/
loading policy to kernels without compat patches (LP: #968956)
* debian/
grant access to /proc/attr api (LP: #979135)
-- Steve Beattie <email address hidden> 2012年4月12日 06:17:42 -0500