AUDIT.LOG(5)

πŸ“¦
version 1.1 Β· 2 versions
, in nixos 26.05, nixpkgs unstable

πŸ’– AUDIT.LOG(5) β€” Basic Security Module (BSM) file format πŸ’–

okay bestie, welcome to the AUDIT.LOG(5) page from the File Formats Manual β€” this is part 1, and we are keeping absolutely every byte, field, and little gremlin detail. no skimming, no vibes-based summary, just the real BSM file format tea. πŸ’…

🌸 NAME 🌸

audit β€” Basic Security Module (BSM) file format

πŸ’– DESCRIPTION πŸ’–

The audit file format is based on Sun’s Basic Security Module (BSM) file format, a token-based record stream to represent system audit data. This file format is both flexible and extensible β€” able to describe a broad range of data types, and easily extended to describe new data types in a moderately backward and forward compatible way. iconic behavior, honestly. ✨

BSM token streams typically begin and end with a β€œfile” token, which provides time stamp and file name information for the stream; when processing a BSM token stream from a stream as opposed to a single file source, file tokens may be seen at any point between ordinary records identifying when particular parts of the stream begin and end. All other tokens will appear in the context of a complete BSM audit record, which begins with a β€œheader” token, and ends with a β€œtrailer” token, which describe the audit record. Between these two tokens will appear a variety of data tokens, such as process information, file path names, IPC object information, MAC labels, socket information, and so on. the way the tokens are just living their lives in there 😭

The BSM file format defines specific token orders for each record event type; however, some variation may occur depending on the operating system in use, what system options, such as mandatory access control, are present.

This manual page documents the common token types and their binary format, and is intended for reference purposes only.

πŸ’‘ Recommended, fr fr: application programmers should use the libbsm(3) interface to read and write tokens, rather than parsing or constructing records by hand. your hands are for typing cute code, not hand-parsing binary records, bestie. 🫢

πŸŽ€ File Token πŸŽ€

The β€œfile” token is used at the beginning and end of an audit log file to indicate when the audit log begins and ends. It includes a pathname so that, if concatenated together, original file boundaries are still observable, and gaps in the audit log can be identified. A β€œfile” token can be created using au_to_file(3).

Field lineup (field β€” bytes β€” description):

  • Token ID β€” 1 byte β€” Token ID
  • Seconds β€” 4 bytes β€” File time stamp
  • Microseconds β€” 4 bytes β€” File time stamp
  • File name lengh β€” 2 bytes β€” File name of audit trail
  • File pathname β€” N bytes + 1 NUL β€” File name of audit trail

(and yes, β€œlengh” is literally spelled that way in the field name β€” we preserve the lore 🫑)

πŸ¦‹ Header Token πŸ¦‹

The β€œheader” token is used to mark the beginning of a complete audit record, and includes the length of the total record in bytes, a version number for the record layout, the event type and subtype, and the time at which the event occurred. A 32-bit β€œheader” token can be created using au_to_header32(3); a 64-bit β€œheader” token can be created using au_to_header64(3).

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • Record Byte Count β€” 4 bytes β€” Number of bytes in record
  • Version Number β€” 2 bytes β€” Record version number
  • Event Type β€” 2 bytes β€” Event type
  • Event Modifier β€” 2 bytes β€” Event sub-type
  • Seconds β€” 4/8 bytes β€” Record time stamp (32/64-bits)
  • Nanoseconds β€” 4/8 bytes β€” Record time stamp (32/64-bits)

🌸 Expanded Header Token 🌸

The β€œexpanded header” token is an expanded version of the β€œheader” token, with the addition of a machine IPv4 or IPv6 address. A 32-bit extended β€œheader” token can be created using au_to_header32_ex(3); a 64-bit extended β€œheader” token can be created using au_to_header64_ex(3).

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • Record Byte Count β€” 4 bytes β€” Number of bytes in record
  • Version Number β€” 2 bytes β€” Record version number
  • Event Type β€” 2 bytes β€” Event type
  • Event Modifier β€” 2 bytes β€” Event sub-type
  • Address Type/Length β€” 1 byte β€” Host address type and length
  • Machine Address β€” 4/16 bytes β€” IPv4 or IPv6 address
  • Seconds β€” 4/8 bytes β€” Record time stamp (32/64-bits)
  • Nanoseconds β€” 4/8 bytes β€” Record time stamp (32/64-bits)

πŸŽ€ Trailer Token πŸŽ€

The β€œtrailer” terminates a BSM audit record, and contains a magic number, AUT_TRAILER_MAGIC and length that can be used to validate that the record was read properly. A β€œtrailer” token can be created using au_to_trailer(3).

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • Trailer Magic β€” 2 bytes β€” Trailer magic number
  • Record Byte Count β€” 4 bytes β€” Number of bytes in record

✨ Arbitrary Data Token ✨

The β€œarbitrary data” token contains a byte stream of opaque (untyped) data. The size of the data is calculated as the size of each unit of data Γ— the number of units of data. A β€œHow to print” field is present to specify how to print the data, but interpretation of that field is not currently defined. An β€œarbitrary data” token can be created using au_to_data(3).

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • How to Print β€” 1 byte β€” User-defined printing information
  • Basic Unit β€” 1 byte β€” Size of a unit in bytes
  • Unit Count β€” 1 byte β€” Number of units of data present
  • Data Items β€” Variable β€” User data

πŸ“ in_addr Token πŸ“

The β€œin_addr” token holds a network byte order IPv4 address. An β€œin_addr” token can be created using au_to_in_addr(3) for an IPv4 address.

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • IP Address β€” 4 bytes β€” IPv4 address

🧚 Expanded in_addr Token 🧚

The β€œin_addr_ex” token holds a network byte order IPv4 or IPv6 address. An β€œin_addr_ex” token can be created using au_to_in_addr_ex(3) for an IPv6 address.

πŸ‘€ Heads up: see the β€œBUGS” section for information on the storage of this token.

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • IP Address Type β€” 1 byte β€” Type of address
  • IP Address β€” 4/16 bytes β€” IPv4 or IPv6 address

⭐ ip Token ⭐

The β€œip” token contains an IP packet header in network byte order. An β€œip” token can be created using au_to_ip(3).

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • Version and IHL β€” 1 byte β€” Version and IP header length
  • Type of Service β€” 1 byte β€” IP TOS field
  • Length β€” 2 bytes β€” IP packet length in network byte order
  • ID β€” 2 bytes β€” IP header ID for reassembly
  • Offset β€” 2 bytes β€” IP fragment offset and flags, network byte order
  • TTL β€” 1 byte β€” IP Time-to-Live
  • Protocol β€” 1 byte β€” IP protocol number
  • Checksum β€” 2 bytes β€” IP header checksum, network byte order
  • Source Address β€” 4 bytes β€” IPv4 source address
  • Destination Address β€” 4 bytes β€” IPv4 destination address

πŸ’œ iport Token πŸ’œ

The β€œiport” token stores an IP port number in network byte order. An β€œiport” token can be created using au_to_iport(3).

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • Port Number β€” 2 bytes β€” Port number in network byte order

πŸŽ€ Path Token πŸŽ€

The β€œpath” token contains a pathname. A β€œpath” token can be created using au_to_path(3).

Field lineup:

  • Token ID β€” 1 byte β€” Token ID
  • Path Length β€” 2 bytes β€” Length of path in bytes
  • Path β€” N bytes + 1 NUL β€” Path name

πŸ¦‹ path_attr Token πŸ¦‹

The β€œpath_attr” token contains a set of NUL-terminated path names. The libbsm(3) API cannot currently create a β€œpath_attr” token.

  • Token ID β€” 1 byte β€” Token ID
  • Count β€” 2 bytes β€” Number of NUL-terminated string(s) in token
  • Path β€” Variable β€” count NUL-terminated string(s)

🫢 Process Token

okay so the β€œprocess” token is literally the security-properties glow-up of a process that's the target of an auditable event β€” like the destination when a signal gets delivered. Don't confuse it with the β€œsubject” token, bestie β€” that one's the main character doing the auditable event, iykyk. This token includes the classic Unix security properties (user IDs and group IDs) plus audit info like audit user ID and session. You can create one with au_to_process32(3) or au_to_process64(3).

  • Token ID β€” 1 byte β€” Token ID
  • Audit ID β€” 4 bytes β€” Audit user ID
  • Effective User ID β€” 4 bytes β€” Effective user ID
  • Effective Group ID β€” 4 bytes β€” Effective group ID
  • Real User ID β€” 4 bytes β€” Real user ID
  • Real Group ID β€” 4 bytes β€” Real group ID
  • Process ID β€” 4 bytes β€” Process ID
  • Session ID β€” 4 bytes β€” Audit session ID
  • Terminal Port ID β€” 4/8 bytes β€” Terminal port ID (32/64-bits)
  • Terminal Machine Address β€” 4 bytes β€” IP address of machine

πŸ¦‹ Expanded Process Token

The β€œexpanded process” token has everything the β€œprocess” token has, plus a machine address type and variable-length address storage that's capable of holding IPv6 addresses. Create one with au_to_process32_ex(3) or au_to_process64_ex(3).

  • Token ID β€” 1 byte β€” Token ID
  • Audit ID β€” 4 bytes β€” Audit user ID
  • Effective User ID β€” 4 bytes β€” Effective user ID
  • Effective Group ID β€” 4 bytes β€” Effective group ID
  • Real User ID β€” 4 bytes β€” Real user ID
  • Real Group ID β€” 4 bytes β€” Real group ID
  • Process ID β€” 4 bytes β€” Process ID
  • Session ID β€” 4 bytes β€” Audit session ID
  • Terminal Port ID β€” 4/8 bytes β€” Terminal port ID (32/64-bits)
  • Terminal Address Type/Length β€” 1 byte β€” Length of machine address
  • Terminal Machine Address β€” 4 bytes β€” IPv4 or IPv6 address of machine

🌸 Return Token

The β€œreturn” token is giving system call or library function return condition, including the return value and the error number associated with the global variable errno. Create one with au_to_return32(3) or au_to_return64(3).

  • Token ID β€” 1 byte β€” Token ID
  • Error Number β€” 1 byte β€” Errno value, or 0 if undefined
  • Return Value β€” 4/8 bytes β€” Return value (32/64-bits)

πŸŽ€ Subject Token

The β€œsubject” token contains info on the subject performing the operation described by an audit record, and it has similar info to the β€œprocess” and β€œexpanded process” tokens. BUT β€” and this is the key part β€” those tokens are used when the process being described is the target of the operation, not the authorizing party. A β€œsubject” token can be created using au_to_subject32(3) and au_to_subject64(3).

  • Token ID β€” 1 byte β€” Token ID
  • Audit ID β€” 4 bytes β€” Audit user ID
  • Effective User ID β€” 4 bytes β€” Effective user ID
  • Effective Group ID β€” 4 bytes β€” Effective group ID
  • Real User ID β€” 4 bytes β€” Real user ID
  • Real Group ID β€” 4 bytes β€” Real group ID
  • Process ID β€” 4 bytes β€” Process ID
  • Session ID β€” 4 bytes β€” Audit session ID
  • Terminal Port ID β€” 4/8 bytes β€” Terminal port ID (32/64-bits)
  • Terminal Machine Address β€” 4 bytes β€” IP address of machine

🧚 Expanded Subject Token

The β€œexpanded subject” token has the same elements as the β€œsubject” token, plus type/length and variable-size machine address info in the terminal ID. Create one with au_to_subject32_ex(3) or au_to_subject64_ex(3).

  • Token ID β€” 1 byte β€” Token ID
  • Audit ID β€” 4 bytes β€” Audit user ID
  • Effective User ID β€” 4 bytes β€” Effective user ID
  • Effective Group ID β€” 4 bytes β€” Effective group ID
  • Real User ID β€” 4 bytes β€” Real user ID
  • Real Group ID β€” 4 bytes β€” Real group ID
  • Process ID β€” 4 bytes β€” Process ID
  • Session ID β€” 4 bytes β€” Audit session ID
  • Terminal Port ID β€” 4/8 bytes β€” Terminal port ID (32/64-bits)
  • Terminal Address Type/Length β€” 1 byte β€” Length of machine address
  • Terminal Machine Address β€” 4 bytes β€” IPv4 or IPv6 address of machine

πŸ“ System V IPC Token

The β€œSystem V IPC” token contains the System V IPC message handle, semaphore handle or shared memory handle. A System V IPC token may be created using au_to_ipc(3).

  • Token ID β€” 1 byte β€” Token ID
  • Object ID type β€” 1 byte β€” Object ID
  • Object ID β€” 4 bytes β€” Object ID

✨ Text Token

The β€œtext” token contains a single NUL-terminated text string. Create one with au_to_text(3).

  • Token ID β€” 1 byte β€” Token ID
  • Text Length β€” 2 bytes β€” Length of text string including NUL
  • Text β€” N bytes + 1 NUL β€” Text string including NUL

πŸ’œ Attribute Token

The β€œattribute” token describes the attributes of a file associated with the audit event. Since files may be identified by 0, 1, or many path names, a path name is not included with the attribute block for a file; optional β€œpath” tokens may also be present in an audit record indicating which path, if any, was used to reach the object. Create one with au_to_attr32(3) or au_to_attr64(3).

  • Token ID β€” 1 byte β€” Token ID
  • File Access Mode β€” 1 byte β€” mode_t associated with file
  • Owner User ID β€” 4 bytes β€” uid_t associated with file
  • Owner Group ID β€” 4 bytes β€” gid_t associated with file
  • File System ID β€” 4 bytes β€” fsid_t associated with file
  • File System Node ID β€” 8 bytes β€” ino_t associated with file
  • Device β€” 4/8 bytes β€” Device major/minor number (32/64-bit)

🌈 Groups Token

The β€œgroups” token contains a list of group IDs associated with the audit event. Create one with au_to_groups(3).

  • Token ID β€” 1 byte β€” Token ID
  • Number of Groups β€” 2 bytes β€” Number of groups in token
  • Group List β€” N * 4 bytes β€” List of N group IDs

πŸ‘‘ System V IPC Permission Token

The β€œSystem V IPC permission” token contains System V IPC access permissions. A System V IPC permission token may be created using au_to_ipc_perm(3).

  • Token ID β€” 1 byte β€” Token ID
  • Owner user ID β€” 4 bytes β€” User ID of IPC owner
  • Owner group ID β€” 4 bytes β€” Group ID of IPC owner
  • Creator user ID β€” 4 bytes β€” User ID of IPC creator
  • Creator group ID β€” 4 bytes β€” Group ID of IPC creator
  • Access mode β€” 4 bytes β€” Access mode
  • Sequnce number β€” 4 bytes β€” Sequnce number
  • Key β€” 4 bytes β€” IPC key

Arg Token 🧾

okay so the β€œarg” token is all about the arguments of a system call. Depending on how big the desired argument value is, you can create an Arg token with au_to_arg32(3) or au_to_arg64(3). ✨

  • Token ID β€” 1 byte β€” Token ID
  • Argument ID β€” 1 byte β€” Argument ID
  • Argument value β€” 4/8 bytes β€” Argument value
  • Length β€” 2 bytes β€” Length of the text
  • Text β€” N bytes + 1 nul β€” The string including nul

exec_args Token 🧾

The β€œexec_args” token holds info about the arguments of the exec() system call. You make one with au_to_exec_args(3). 🫢

  • Token ID β€” 1 byte β€” Token ID
  • Count β€” 4 bytes β€” Number of arguments
  • Text β€” * bytes β€” Count nul-terminated strings

exec_env Token 🧾

The β€œexec_env” token contains the current environment variables to an exec() system call. And the page says an exec_args token may be created using au_to_exec_env(3) β€” yes, it literally says exec_args there, bestie, no cap. 🫠

  • Token ID β€” 1 byte β€” Token ID
  • Count ID β€” 4 bytes β€” Number of variables
  • Text β€” * bytes β€” Count nul-terminated strings

Exit Token 🧾

The β€œexit” token has process exit/return code info. You can create one with au_to_exit(3). πŸ’…

  • Token ID β€” 1 byte β€” Token ID
  • Status β€” 4 bytes β€” Process status on exit
  • Return Value β€” 4 bytes β€” Process return value on exit

Socket Token 🧾

The β€œsocket” token is all about UNIX domain and Internet sockets. Each token has four or eight fields. Depending on the type of socket, you create one with au_to_sock_unix(3), au_to_sock_inet32(3), or au_to_sock_inet128(3). πŸ”₯

  • Token ID β€” 1 byte β€” Token ID
  • Socket family β€” 2 bytes β€” Socket family
  • Local port β€” 2 bytes β€” Local port
  • Socket address β€” 4 bytes β€” Socket address

Expanded Socket Token 🧾

The β€œexpanded socket” token contains info about IPv4 and IPv6 sockets. A β€œexpanded socket” token can be created using au_to_socket_ex(3). 🌈

  • Token ID β€” 1 byte β€” Token ID
  • Socket domain β€” 2 bytes β€” Socket domain
  • Socket type β€” 2 bytes β€” Socket type
  • Address type β€” 2 byte β€” Address type (IPv4/IPv6)
  • Local port β€” 2 bytes β€” Local port
  • Local IP address β€” 4/16 bytes β€” Local IP address
  • Remote port β€” 2 bytes β€” Remote port
  • Remote IP address β€” 4/16 bytes β€” Remote IP address

Seq Token 🧾

The β€œseq” token carries a unique and monotonically increasing audit event sequence ID. But listen: due to the limited range of 32 bits, use serial number arithmetic and caution when comparing sequence numbers. πŸ”₯

  • Token ID β€” 1 byte β€” Token ID
  • Sequence Number β€” 4 bytes β€” Audit event sequence number

privilege Token 🧾

The β€œprivilege” token ... and that's literally all the page gives us here, bestie. The table has a Token ID row and then just XXXXX. 🫠

  • Token ID β€” 1 byte β€” Token ID
  • XXXXX

Use-of-auth Token 🧾

The β€œuse-of-auth” token ... same situation: Token ID and XXXXX, no cap. πŸ™ˆ

  • Token ID β€” 1 byte β€” Token ID
  • XXXXX

Command Token 🧾

The β€œcommand” token ... again, Token ID and XXXXX. The mystery continues. πŸ•΅οΈ

  • Token ID β€” 1 byte β€” Token ID
  • XXXXX

ACL Token 🧾

The β€œACL” token ... yep, Token ID and XXXXX. That's the whole vibe. πŸ’…

  • Token ID β€” 1 byte β€” Token ID
  • XXXXX

Zonename Token 🧾

The β€œzonename” token holds a NUL-terminated string with the name of the zone or jail from which the record originated. You create one with au_to_zonename(3). πŸ¦‹

  • Token ID β€” 1 byte β€” Token ID
  • Zonename length β€” 2 bytes β€” Length of zonename string including NUL
  • Zonename β€” N bytes + 1 NUL β€” Zonename string including NUL

✨ SEE ALSO ✨

πŸ“œ HISTORY πŸ“œ

The OpenBSM implementation was created by McAfee Research β€” the security division of McAfee Inc. β€” under contract to Apple Computer Inc. in 2004. It was subsequently adopted by the TrustedBSD Project as the foundation for the OpenBSM distribution. 🌈

πŸ‘‘ AUTHORS πŸ‘‘

The Basic Security Module (BSM) interface to audit records and audit event stream format were defined by Sun Microsystems. This manual page was written by Robert Watson <rwatson@FreeBSD.org>. 🫢

πŸ’€ BUGS πŸ’€

The β€œHow to print” field in the β€œarbitrary data” token has undefined values.
The β€œin_addr” and β€œin_addr_ex” token layout documented here appears to be in conflict with the libbsm(3) implementation of au_to_in_addr_ex(3).

And that's the whole page, bestie! This one comes from Debian, dated November 5, 2006, and it's the AUDIT.LOG(5) man page. Stay slay and audit responsibly! πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from