|English||Chinese (Simplified) (zh_CN)|
|Chapter 17. Security Event Auditing|
|The FreeBSD operating system includes support for security event auditing. Event auditing supports reliable, fine-grained, and configurable logging of a variety of security-relevant system events, including logins, configuration changes, and file and network access. These log records can be invaluable for live system monitoring, intrusion detection, and postmortem analysis. FreeBSD implements Sun(TM)'s published Basic Security Module (BSM) Application Programming Interface (API) and file format, and is interoperable with the Solaris(TM) and Mac OS(R) X audit implementations.|
|Understand UNIX(R) and FreeBSD basics (crossref:basics[basics,FreeBSD Basics]).|
|Be familiar with the basics of kernel configuration/compilation (crossref:kernelconfig[kernelconfig,Configuring the FreeBSD Kernel]).|
|Have some familiarity with security and how it pertains to FreeBSD (crossref:security[security,Security]).|
|_event_: an auditable event is any event that can be logged using the audit subsystem. Examples of security-relevant events include the creation of a file, the building of a network connection, or a user logging in. Events are either "attributable", meaning that they can be traced to an authenticated user, or "non-attributable". Examples of non-attributable events are any events that occur before authentication in the login process, such as bad password attempts.|
|_class_: a named set of related events which are used in selection expressions. Commonly used classes of events include "file creation" (fc), "exec" (ex), and "login_logout" (lo).|
|_record_: an audit log entry describing a security event. Records contain a record event type, information on the subject (user) performing the action, date and time information, information on any objects or arguments, and a success or failure condition.|
|_selection expression_: a string containing a list of prefixes and audit event class names used to match events.|
|User space support for event auditing is installed as part of the base FreeBSD operating system. Kernel support is available in the [.filename]#GENERIC# kernel by default, and man:auditd can be enabled by adding the following line to [.filename]#/etc/rc.conf#:|
# service auditd start
|<<event-selection>> summarizes the default audit event classes:|
| Class Name
|Match all event classes.
|authentication and authorization
|Administrative actions performed on the system as a whole.
|Application defined action.
|Audit calls to the `close` system call.
|Audit program execution. Auditing of command line arguments and environmental variables is controlled via man:audit_control using the `argv` and `envv` parameters to the `policy` setting.
|file attribute access
|Audit the access of object attributes such as man:stat and man:pathconf.
|Audit events where a file is created as a result.
|Audit events where file deletion occurs.
|file attribute modify
|Audit events where file attribute modification occurs, such as by man:chown, man:chflags, and man:flock.
|Audit events in which data is read or files are opened for reading.
|Audit events in which data is written or files are written or modified.
|Audit use of the `ioctl` system call.
|Audit various forms of Inter-Process Communication, including POSIX pipes and System V IPC operations.
|Audit man:login and man:logout events.
|Audit non-attributable events.
|Match no audit events.
|Audit events related to network actions such as man:connect and man:accept.
|Audit miscellaneous events.
|Audit process operations such as man:exec and man:exit.
|Each audit event class may be combined with a prefix indicating whether successful/failed operations are matched, and whether the entry is adding or removing matching for the class and type. <<event-prefixes>> summarizes the available prefixes:|
|Audit successful events in this class.
|Audit failed events in this class.
|Audit neither successful nor failed events in this class.
|Do not audit successful events in this class.
|Do not audit failed events in this class.
|[.filename]#audit_warn#: a customizable shell script used by man:auditd to generate warning messages in exceptional situations, such as when space for audit records is running low or when the audit trail file has been rotated.|
|The [.filename]#audit_control# File|
|If the `dist` field is set to `on` or `yes`, hard links will be created to all trail files in [.filename]#/var/audit/dist#.|
|The `minfree` entry defines the minimum percentage of free space for the file system where the audit trail is stored.|
|The `policy` entry specifies a comma-separated list of policy flags controlling various aspects of audit behavior. The `cnt` indicates that the system should continue running despite an auditing failure (this flag is highly recommended). The other flag, `argv`, causes command line arguments to the man:execve system call to be audited as part of command execution.|