AUDIT2ALLOW(1)

πŸ“¦
version 3.11 Β· 4 versions
, in centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ‘‘ AUDIT2ALLOW πŸ’…

okay bestie, welcome to audit2allow β€” it lives in section 1 of the General Commands Manual and it's genuinely iconic.

✨ NAME ✨

audit2allow β€” generate SELinux policy allow/dontaudit rules from logs of denied operations 🫢

also in the house: audit2why β€” translates SELinux audit messages into a description of why the access was denied. plot twist: it's literally just audit2allow -w. no cap.


🌸 SYNOPSIS 🌸

audit2allow [options]

πŸ’– OPTIONS πŸ’–

one bullet per flag, no skips, we eat every single one πŸ“

  • -a | --all β€” read input from the audit and message log. heads up, this conflicts with -i 😭
  • -b | --boot β€” read input from audit messages since the last boot. also beefs with -i.
  • -d | --dmesg β€” read input from the output of /bin/dmesg. lowkey important: when auditd is running, not all audit messages show up via dmesg, so use "ausearch -m avc | audit2allow" or -a instead πŸ’€
  • -D | --dontaudit β€” generate dontaudit rules. default is allow, so this flips the vibe.
  • -e | --explain β€” fully explain the generated output. give us the whole story bestie.
  • -h | --help β€” print a short usage message ✨
  • -i <inputfile> | --input <inputfile> β€” read input from <inputfile>
  • --interface-info=<interface_info_file> β€” read interface information from <interface_info_file>
  • -l | --lastreload β€” read input only from after the last policy reload
  • -m <modulename> | --module <modulename> β€” generate module/require output <modulename>
  • -M <modulename> β€” generate a loadable module package. conflicts with -o πŸ™ˆ
  • -C β€” generate CIL output. conflicts with -M.
  • -p <policyfile> | --policy <policyfile> β€” policy file to use for analysis
  • --perm-map <perm_map_file> β€” read the permission map from <perm_map_file>
  • -o <outputfile> | --output <outputfile> β€” append output to <outputfile>
  • -r | --requires β€” generate require output syntax for loadable modules
  • -N | --noreference β€” do not generate reference policy, traditional style allow rules instead. this is the default behavior, so it's giving "if it ain't broke" πŸ’…
  • -R | --reference β€” generate reference policy using installed macros. it tries to match denials against interfaces and may be inaccurate β€” so double check, queen πŸ‘‘
  • -t <type_regex> | --type=<type_regex> β€” only process messages with a type that matches this regex
  • -x | --xperms β€” generate extended permission access vector rules πŸ”₯
  • -w | --why β€” translates SELinux audit messages into a description of why the access was denied
  • -v | --verbose β€” turn on verbose output

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea. this utility scans the logs for messages that got logged when the system denied permission for operations, and it generates a snippet of policy rules which, if loaded into policy, might have allowed those operations to succeed. however β€” and this is the part we do NOT skip β€” this utility only generates Type Enforcement (TE) allow rules. certain permission denials may need other kinds of policy changes, like adding an attribute to a type declaration to satisfy an existing constraint, adding a role allow rule, or modifying a constraint. and if the reason is unclear, the audit2why(8) utility may be used to diagnose it. iykyk πŸ’œ

bestie, be careful. πŸ™ˆ care must be exercised while acting on the output of this utility, to make sure the operations being permitted do not pose a security threat. often it is better to define new domains and/or types, or make other structural changes to narrowly allow an optimal set of operations to succeed, as opposed to blindly implementing the sometimes broad changes recommended by this utility. certain permission denials are not fatal to the application, in which case it may be preferable to simply suppress logging of the denial via a 'dontaudit' rule rather than an 'allow' rule. periodt. πŸ’…

🌈 EXAMPLE 🌈

NOTE: These examples are for systems using the audit package. If you do not use the audit package, the AVC messages will be in /var/log/messages. Please substitute /var/log/messages for /var/log/audit/audit.log in the examples.

πŸŽ€ Using audit2allow to generate module policy

$ cat /var/log/audit/audit.log | audit2allow -m local > local.te
$ cat local.te
module local 1.0;

require {
        class file {  getattr open read };

        type myapp_t;
        type etc_t;
 };

allow myapp_t etc_t:file { getattr open read };
<review local.te and customize as desired>

πŸŽ€ Using audit2allow to generate module policy using reference policy

$ cat /var/log/audit/audit.log | audit2allow -R -m local > local.te
$ cat local.te
policy_module(local, 1.0)

gen_require(`
        type myapp_t;
        type etc_t;
')

files_read_etc_files(myapp_t)
<review local.te and customize as desired>

πŸŽ€ Building module policy using Makefile

# SELinux provides a policy devel environment under
# /usr/share/selinux/devel including all of the shipped
# interface files.
# You can create a te file and compile it by executing

$ make -f /usr/share/selinux/devel/Makefile local.pp

# This make command will compile a local.te file in the current
# directory. If you did not specify a "pp" file, the make file
# will compile all "te" files in the current directory.  After
# you compile your te file into a "pp" file, you need to install
# it using the semodule command.

$ semodule -i local.pp

πŸŽ€ Building module policy manually

# Compile the module
$ checkmodule -M -m -o local.mod local.te

# Create the package
$ semodule_package -o local.pp -m local.mod

# Load the module into the kernel
$ semodule -i local.pp

πŸŽ€ Using audit2allow to generate and build module policy

$ cat /var/log/audit/audit.log | audit2allow -M local
Generating type enforcement file: local.te

Compiling policy: checkmodule -M -m -o local.mod local.te
Building package: semodule_package -o local.pp -m local.mod

******************** IMPORTANT ***********************

In order to load this newly created policy package into the kernel,
you are required to execute

semodule -i local.pp

πŸŽ€ Using audit2allow to generate monolithic (non-module) policy

$ cd /etc/selinux/$SELINUXTYPE/src/policy
$ cat /var/log/audit/audit.log | audit2allow >> domains/misc/local.te
$ cat domains/misc/local.te
allow cupsd_config_t unconfined_t:fifo_file { getattr ioctl };
<review domains/misc/local.te and customize as desired>
$ make load

πŸ’œ AUTHOR πŸ’œ

This manual page was written by Manoj Srivastava <srivasta@debian.org>, for the Debian GNU/Linux system. It was updated by Dan Walsh <dwalsh@redhat.com> 🫢

The audit2allow utility has contributions from several people, including Justin R. Smith and Yuichi Nakamura. and Dan Walsh.


and that's the whole page, bestie ✨ this one's from Security Enhanced Linux, dated October 2010, and it's AUDIT2ALLOW(1) in the manual. go forth and audit responsibly πŸ’…πŸ¦‹