AUDIT.LOG(5)
π 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βcountNUL-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_tassociated with file - Owner User ID β
4 bytesβuid_tassociated with file - Owner Group ID β
4 bytesβgid_tassociated with file - File System ID β
4 bytesβfsid_tassociated with file - File System Node ID β
8 bytesβino_tassociated 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 thelibbsm(3)implementation ofau_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
- nixos 26.05: openbsm 1.1
- nixpkgs unstable: openbsm 1.1
- Copyright (c) 2005-2006 Robert N. M. Watson
- Copyright (c) 2008 Apple Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms