<div dir="ltr">Hello-<div><br></div><div>  Given that AppArmor is already installed in Ubuntu I was looking at ways to use it for system wide audit rather than also enabling the k/auditd framework. If AppArmor is already inspecting system calls no need to do it twice for performance. I recognize this is not really what AppArmor was designed for but the profile below has gotten me close. My problem now is that the 'audit network' rule is logging every sendmsg/recvmsg whereas all I want are connect, accept and bind calls. It looks like AppArmor 3.0 will introduce permissions I could filter on, but is there anyway to do this today? Logging each send/recv is not going to be performant even if I filter the results in userland. Other comments on improving this profile welcome!</div><div><br></div><div><div>#vim:syntax=apparmor</div><div># Experimental -- attempt to use AppArmor as an audit function.</div><div># MIT License - Alex Maestretti 2016</div><div># AppArmor is already inspecting system calls by default in Ubuntu.</div><div># If we can use it to audit, we don't need to turn on the k/auditd </div><div># framework and can save some performance cost.</div><div># Goals are file integrity, network sockets and process execution.</div><div><br></div><div>profile global /** flags=(complain) {</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span># Allow all top level rule types</div><div>        #file,  ## can't allow all 'file' as we get a pattern overload when we try to audit below </div><div>        # audit ALL network syscalls, even send/recv, very verbose</div><div>        # selecting network permissions (connect, accept, bind) only supported in 3.0</div><div>        audit network,</div><div>        capability,</div><div>        # audit mounts and process injection w/ ptrace</div><div>        audit mount,</div><div>        audit ptrace,</div><div>        signal,</div><div>        dbus,</div><div>        </div><div>        # These top level rules aren't implemented yet, but mentioned in docs</div><div>        #unix,</div><div>        #audit chown,</div><div>        #audit chmod,</div><div>        #audit setuid,</div><div>        #ipc,</div><div>        #rlimit,</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span># allow all file accesses, except execute</div><div>        /** rwlkm,</div><div>        # audit all executions. i - inherit current confinement, x - execute</div><div>        audit /** ix,</div><div>        </div><div>        # audit specific file reads / writes for File Integrity Monitoring</div><div>        audit /tmp/file.txt rw,</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span># doesn't seem to work, but doesn't break anything, would be nice to audit CAPs, maybe evaluating rules in order      </div><div>        audit capability chown,</div><div>}</div></div></div>