2 .\" Copyright (c) 2005-2006 Robert N. M. Watson
3 .\" Copyright (c) 2008 Apple Inc.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .Nd "Basic Security Module (BSM) file format"
36 file format is based on Sun's Basic Security Module (BSM) file format, a
37 token-based record stream to represent system audit data.
38 This file format is both flexible and extensible, able to describe a broad
39 range of data types, and easily extended to describe new data types in a
40 moderately backward and forward compatible way.
42 BSM token streams typically begin and end with a
44 token, which provides time stamp and file name information for the stream;
45 when processing a BSM token stream from a stream as opposed to a single file
46 source, file tokens may be seen at any point between ordinary records
47 identifying when particular parts of the stream begin and end.
48 All other tokens will appear in the context of a complete BSM audit record,
51 token, and ends with a
53 token, which describe the audit record.
54 Between these two tokens will appear a variety of data tokens, such as
55 process information, file path names, IPC object information, MAC labels,
56 socket information, and so on.
58 The BSM file format defines specific token orders for each record event type;
59 however, some variation may occur depending on the operating system in use,
60 what system options, such as mandatory access control, are present.
62 This manual page documents the common token types and their binary format, and
63 is intended for reference purposes only.
64 It is recommended that application programmers use the
66 interface to read and write tokens, rather than parsing or constructing
71 token is used at the beginning and end of an audit log file to indicate
72 when the audit log begins and ends.
73 It includes a pathname so that, if concatenated together, original file
74 boundaries are still observable, and gaps in the audit log can be identified.
77 token can be created using
79 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
80 .It Sy "Field Bytes Description"
81 .It "Token ID 1 byte Token ID"
82 .It "Seconds 4 bytes File time stamp"
83 .It "Microseconds 4 bytes File time stamp"
84 .It "File name length 2 bytes File name of audit trail"
85 .It "File pathname N bytes + 1 NUL File name of audit trail"
90 token is used to mark the beginning of a complete audit record, and includes
91 the length of the total record in bytes, a version number for the record
92 layout, the event type and subtype, and the time at which the event occurred.
95 token can be created using
96 .Xr au_to_header32 3 ;
99 token can be created using
100 .Xr au_to_header64 3 .
101 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
102 .It Sy "Field Bytes Description"
103 .It "Token ID 1 byte Token ID"
104 .It "Record Byte Count 4 bytes Number of bytes in record"
105 .It "Version Number 1 byte Record version number"
106 .It "Event Type 2 bytes Event type"
107 .It "Event Modifier 2 bytes Event sub-type"
108 .It "Seconds 4/8 bytes Record time stamp (32/64-bits)"
109 .It "Nanoseconds 4/8 bytes Record time stamp (32/64-bits)"
111 .Ss Expanded Header Token
114 token is an expanded version of the
116 token, with the addition of a machine IPv4 or IPv6 address.
119 token can be created using
120 .Xr au_to_header32_ex 3 ;
123 token can be created using
124 .Xr au_to_header64_ex 3 .
125 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
126 .It Sy "Field Bytes Description"
127 .It "Token ID 1 byte Token ID"
128 .It "Record Byte Count 4 bytes Number of bytes in record"
129 .It "Version Number 1 byte Record version number"
130 .It "Event Type 2 bytes Event type"
131 .It "Event Modifier 2 bytes Event sub-type"
132 .It "Address Type/Length 1 byte Host address type and length"
133 .It "Machine Address 4/16 bytes IPv4 or IPv6 address"
134 .It "Seconds 4/8 bytes Record time stamp (32/64-bits)"
135 .It "Nanoseconds 4/8 bytes Record time stamp (32/64-bits)"
140 terminates a BSM audit record, and contains a magic number,
141 .Dv AUT_TRAILER_MAGIC
142 and length that can be used to validate that the record was read properly.
145 token can be created using
146 .Xr au_to_trailer 3 .
147 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
148 .It Sy "Field Bytes Description"
149 .It "Token ID 1 byte Token ID"
150 .It "Trailer Magic 2 bytes Trailer magic number"
151 .It "Record Byte Count 4 bytes Number of bytes in record"
153 .Ss Arbitrary Data Token
156 token contains a byte stream of opaque (untyped) data.
157 The size of the data is calculated as the size of each unit of data
158 multiplied by the number of units of data.
161 field is present to specify how to print the data, but interpretation of
162 that field is not currently defined.
165 token can be created using
167 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
168 .It Sy "Field Bytes Description"
169 .It "Token ID 1 byte Token ID"
170 .It "How to Print 1 byte User-defined printing information"
171 .It "Basic Unit 1 byte Size of a unit in bytes"
172 .It "Unit Count 1 byte Number of units of data present"
173 .It "Data Items Variable User data"
178 token holds a network byte order IPv4 address.
181 token can be created using
184 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
185 .It Sy "Field Bytes Description"
186 .It "Token ID 1 byte Token ID"
187 .It "IP Address 4 bytes IPv4 address"
189 .Ss Expanded in_addr Token
192 token holds a network byte order IPv4 or IPv6 address.
195 token can be created using
196 .Xr au_to_in_addr_ex 3
201 section for information on the storage of this token.
202 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
203 .It Sy "Field Bytes Description"
204 .It "Token ID 1 byte Token ID"
205 .It "IP Address Type 1 byte Type of address"
206 .It "IP Address 4/16 bytes IPv4 or IPv6 address"
211 token contains an IP packet header in network byte order.
214 token can be created using
216 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
217 .It Sy "Field Bytes Description"
218 .It "Token ID 1 byte Token ID"
219 .It "Version and IHL 1 byte Version and IP header length"
220 .It "Type of Service 1 byte IP TOS field"
221 .It "Length 2 bytes IP packet length in network byte order"
222 .It "ID 2 bytes IP header ID for reassembly"
223 .It "Offset 2 bytes IP fragment offset and flags, network byte order"
224 .It "TTL 1 byte IP Time-to-Live"
225 .It "Protocol 1 byte IP protocol number"
226 .It "Checksum 2 bytes IP header checksum, network byte order"
227 .It "Source Address 4 bytes IPv4 source address"
228 .It "Destination Address 4 bytes IPv4 destination address"
233 token stores an IP port number in network byte order.
236 token can be created using
238 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
239 .It Sy "Field Bytes Description"
240 .It "Token ID 1 byte Token ID"
241 .It "Port Number 2 bytes Port number in network byte order"
246 token contains a pathname.
249 token can be created using
251 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
252 .It Sy "Field Bytes Description"
253 .It "Token ID 1 byte Token ID"
254 .It "Path Length 2 bytes Length of path in bytes"
255 .It "Path N bytes + 1 NUL Path name"
260 token contains a set of NUL-terminated path names.
263 API cannot currently create a
266 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
267 .It Sy "Field Bytes Description"
268 .It "Token ID 1 byte Token ID"
269 .It "Count 2 bytes Number of NUL-terminated string(s) in token"
270 .It "Path Variable count NUL-terminated string(s)"
275 token contains a description of the security properties of a process
276 involved as the target of an auditable event, such as the destination for
278 It should not be confused with the
280 token, which describes the subject performing an auditable event.
281 This includes both the traditional
283 security properties, such as user IDs and group IDs, but also audit
284 information such as the audit user ID and session.
287 token can be created using
288 .Xr au_to_process32 3
290 .Xr au_to_process64 3 .
291 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
292 .It Sy "Field Bytes Description"
293 .It "Token ID 1 byte Token ID"
294 .It "Audit ID 4 bytes Audit user ID"
295 .It "Effective User ID 4 bytes Effective user ID"
296 .It "Effective Group ID 4 bytes Effective group ID"
297 .It "Real User ID 4 bytes Real user ID"
298 .It "Real Group ID 4 bytes Real group ID"
299 .It "Process ID 4 bytes Process ID"
300 .It "Session ID 4 bytes Audit session ID"
301 .It "Terminal Port ID 4/8 bytes Terminal port ID (32/64-bits)"
302 .It "Terminal Machine Address 4 bytes IP address of machine"
304 .Ss Expanded Process Token
307 token contains the contents of the
309 token, with the addition of a machine address type and variable length
310 address storage capable of containing IPv6 addresses.
313 token can be created using
314 .Xr au_to_process32_ex 3
316 .Xr au_to_process64_ex 3 .
317 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
318 .It Sy "Field Bytes Description"
319 .It "Token ID 1 byte Token ID"
320 .It "Audit ID 4 bytes Audit user ID"
321 .It "Effective User ID 4 bytes Effective user ID"
322 .It "Effective Group ID 4 bytes Effective group ID"
323 .It "Real User ID 4 bytes Real user ID"
324 .It "Real Group ID 4 bytes Real group ID"
325 .It "Process ID 4 bytes Process ID"
326 .It "Session ID 4 bytes Audit session ID"
327 .It "Terminal Port ID 4/8 bytes Terminal port ID (32/64-bits)"
328 .It "Terminal Address Type/Length 4 bytes Length of machine address"
329 .It "Terminal Machine Address 4 bytes IPv4 or IPv6 address of machine"
334 token contains a system call or library function return condition, including
335 return value and error number associated with the global variable
339 token can be created using
342 .Xr au_to_return64 3 .
343 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
344 .It Sy "Field Bytes Description"
345 .It "Token ID 1 byte Token ID"
346 .It "Error Number 1 byte Errno value, or 0 if undefined"
347 .It "Return Value 4/8 bytes Return value (32/64-bits)"
352 token contains information on the subject performing the operation described
353 by an audit record, and includes similar information to that found in the
358 However, those tokens are used where the process being described is the
359 target of the operation, not the authorizing party.
362 token can be created using
363 .Xr au_to_subject32 3
365 .Xr au_to_subject64 3 .
366 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
367 .It Sy "Field Bytes Description"
368 .It "Token ID 1 byte Token ID"
369 .It "Audit ID 4 bytes Audit user ID"
370 .It "Effective User ID 4 bytes Effective user ID"
371 .It "Effective Group ID 4 bytes Effective group ID"
372 .It "Real User ID 4 bytes Real user ID"
373 .It "Real Group ID 4 bytes Real group ID"
374 .It "Process ID 4 bytes Process ID"
375 .It "Session ID 4 bytes Audit session ID"
376 .It "Terminal Port ID 4/8 bytes Terminal port ID (32/64-bits)"
377 .It "Terminal Machine Address 4 bytes IP address of machine"
379 .Ss Expanded Subject Token
382 token consists of the same elements as the
384 token, with the addition of type/length and variable size machine address
385 information in the terminal ID.
388 token can be created using
389 .Xr au_to_subject32_ex 3
391 .Xr au_to_subject64_ex 3 .
392 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
393 .It Sy "Field Bytes Description"
394 .It "Token ID 1 byte Token ID"
395 .It "Audit ID 4 bytes Audit user ID"
396 .It "Effective User ID 4 bytes Effective user ID"
397 .It "Effective Group ID 4 bytes Effective group ID"
398 .It "Real User ID 4 bytes Real user ID"
399 .It "Real Group ID 4 bytes Real group ID"
400 .It "Process ID 4 bytes Process ID"
401 .It "Session ID 4 bytes Audit session ID"
402 .It "Terminal Port ID 4/8 bytes Terminal port ID (32/64-bits)"
403 .It "Terminal Address Type/Length 1 byte Length of machine address"
404 .It "Terminal Machine Address 4 bytes IPv4 or IPv6 address of machine"
406 .Ss System V IPC Token
409 token contains the System V IPC message handle, semaphore handle or shared
411 A System V IPC token may be created using
413 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
414 .It Sy "Field Bytes Description"
415 .It "Token ID 1 byte Token ID"
416 .It "Object ID type 1 byte Object ID"
417 .It "Object ID 4 bytes Object ID"
422 token contains a single NUL-terminated text string.
425 token may be created using
427 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
428 .It Sy "Field Bytes Description"
429 .It "Token ID 1 byte Token ID"
430 .It "Text Length 2 bytes Length of text string including NUL"
431 .It "Text N bytes + 1 NUL Text string including NUL"
436 token describes the attributes of a file associated with the audit event.
437 As files may be identified by 0, 1, or many path names, a path name is not
438 included with the attribute block for a file; optional
440 tokens may also be present in an audit record indicating which path, if any,
441 was used to reach the object.
444 token can be created using
448 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
449 .It Sy "Field Bytes Description"
450 .It "Token ID 1 byte Token ID"
451 .It "File Access Mode 1 byte mode_t associated with file"
452 .It "Owner User ID 4 bytes uid_t associated with file"
453 .It "Owner Group ID 4 bytes gid_t associated with file"
454 .It "File System ID 4 bytes fsid_t associated with file"
455 .It "File System Node ID 8 bytes ino_t associated with file"
456 .It "Device 4/8 bytes Device major/minor number (32/64-bit)"
461 token contains a list of group IDs associated with the audit event.
464 token can be created using
466 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
467 .It Sy "Field Bytes Description"
468 .It "Token ID 1 byte Token ID"
469 .It "Number of Groups 2 bytes Number of groups in token"
470 .It "Group List N * 4 bytes List of N group IDs"
472 .Ss System V IPC Permission Token
474 .Dq System V IPC permission
475 token contains a System V IPC access permissions.
476 A System V IPC permission token may be created using
477 .Xr au_to_ipc_perm 3 .
478 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
479 .It Sy "Field Bytes Description"
480 .It "Token ID 1 byte Token ID"
481 .It Li "Owner user ID" Ta "4 bytes" Ta "User ID of IPC owner"
482 .It Li "Owner group ID" Ta "4 bytes" Ta "Group ID of IPC owner"
483 .It Li "Creator user ID" Ta "4 bytes" Ta "User ID of IPC creator"
484 .It Li "Creator group ID" Ta "4 bytes" Ta "Group ID of IPC creator"
485 .It Li "Access mode" Ta "4 bytes" Ta "Access mode"
486 .It Li "Sequence number" Ta "4 bytes" Ta "Sequence number"
487 .It Li "Key" Ta "4 bytes" Ta "IPC key"
492 token contains information about arguments of the system call.
493 Depending on the size of the desired argument value, an Arg token may be
498 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
499 .It Sy "Field Bytes Description"
500 .It "Token ID 1 byte Token ID"
501 .It Li "Argument ID" Ta "1 byte" Ta "Argument ID"
502 .It Li "Argument value" Ta "4/8 bytes" Ta "Argument value"
503 .It Li "Length" Ta "2 bytes" Ta "Length of the text"
504 .It Li "Text" Ta "N bytes + 1 nul" Ta "The string including nul"
509 token contains information about arguments of the exec() system call.
510 An exec_args token may be created using
511 .Xr au_to_exec_args 3 .
512 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
513 .It Sy "Field Bytes Description"
514 .It "Token ID 1 byte Token ID"
515 .It Li "Count" Ta "4 bytes" Ta "Number of arguments"
516 .It Li "Text" Ta "* bytes" Ta "Count nul-terminated strings"
521 token contains current environment variables to an exec() system call.
522 An exec_args token may be created using
523 .Xr au_to_exec_env 3 .
524 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
525 .It Sy "Field Bytes Description"
526 .It "Token ID 1 byte Token ID"
527 .It Li "Count ID" Ta "4 bytes" Ta "Number of variables"
528 .It Li "Text" Ta "* bytes" Ta "Count nul-terminated strings"
533 token contains process exit/return code information.
536 token can be created using
538 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
539 .It Sy "Field Bytes Description"
540 .It "Token ID 1 byte Token ID"
541 .It "Status 4 bytes Process status on exit"
542 .It "Return Value 4 bytes Process return value on exit"
547 token contains information about UNIX domain and Internet sockets.
548 Each token has four or eight fields.
549 Depending on the type of socket, a socket token may be created using
550 .Xr au_to_sock_unix 3 ,
551 .Xr au_to_sock_inet32 3
553 .Xr au_to_sock_inet128 3 .
554 .Bl -column -offset 3n ".Sy Field Name Width XX" ".Sy XX Bytes XXXX" ".Sy Description"
555 .It Sy "Field" Ta Sy Bytes Ta Sy Description
556 .It Li "Token ID" Ta "1 byte" Ta "Token ID"
557 .It Li "Socket family" Ta "2 bytes" Ta "Socket family"
558 .It Li "Local port" Ta "2 bytes" Ta "Local port"
559 .It Li "Socket address" Ta "4 bytes" Ta "Socket address"
561 .Ss Expanded Socket Token
564 token contains information about IPv4 and IPv6 sockets.
567 token can be created using
568 .Xr au_to_socket_ex 3 .
569 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
570 .It Sy "Field Bytes Description"
571 .It Li "Token ID" Ta "1 byte" Ta "Token ID"
572 .It Li "Socket domain" Ta "2 bytes" Ta "Socket domain"
573 .It Li "Socket type" Ta "2 bytes" Ta "Socket type"
574 .It Li "Address type" Ta "2 byte" Ta "Address type (IPv4/IPv6)"
575 .It Li "Local port" Ta "2 bytes" Ta "Local port"
576 .It Li "Local IP address" Ta "4/16 bytes" Ta "Local IP address"
577 .It Li "Remote port" Ta "2 bytes" Ta "Remote port"
578 .It Li "Remote IP address" Ta "4/16 bytes" Ta "Remote IP address"
583 token contains a unique and monotonically increasing audit event sequence ID.
584 Due to the limited range of 32 bits, serial number arithmetic and caution
585 should be used when comparing sequence numbers.
586 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
587 .It Sy "Field Bytes Description"
588 .It "Token ID 1 byte Token ID"
589 .It "Sequence Number 4 bytes Audit event sequence number"
595 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
596 .It Sy "Field Bytes Description"
597 .It "Token ID 1 byte Token ID"
599 .Ss Use-of-auth Token
603 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
604 .It Sy "Field Bytes Description"
605 .It "Token ID 1 byte Token ID"
611 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
612 .It Sy "Field Bytes Description"
613 .It "Token ID 1 byte Token ID"
619 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
620 .It Sy "Field Bytes Description"
621 .It "Token ID 1 byte Token ID"
626 token holds a NUL-terminated string with the name of the zone or jail from
627 which the record originated.
630 token can be created using
631 .Xr au_to_zonename 3 .
632 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
633 .It Sy "Field Bytes Description"
634 .It "Token ID 1 byte Token ID"
635 .It "Zonename length 2 bytes Length of zonename string including NUL"
636 .It "Zonename N bytes + 1 NUL Zonename string including NUL"
646 The OpenBSM implementation was created by McAfee Research, the security
647 division of McAfee Inc., under contract to Apple Computer Inc.\& in 2004.
648 It was subsequently adopted by the TrustedBSD Project as the foundation for
649 the OpenBSM distribution.
651 The Basic Security Module (BSM) interface to audit records and audit event
652 stream format were defined by Sun Microsystems.
654 This manual page was written by
655 .An Robert Watson Aq rwatson@FreeBSD.org .
661 token has undefined values.
667 token layout documented here appears to be in conflict with the
670 .Xr au_to_in_addr_ex 3 .