2 .\" Copyright (c) 2005-2006 Robert N. M. Watson
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" $P4: //depot/projects/trustedbsd/openbsm/man/audit.log.5#16 $
33 .Nd "Basic Security Module (BSM) file format"
37 file format is based on Sun's Basic Security Module (BSM) file format, a
38 token-based record stream to represent system audit data.
39 This file format is both flexible and extensible, able to describe a broad
40 range of data types, and easily extended to describe new data types in a
41 moderately backward and forward compatible way.
43 BSM token streams typically begin and end with a
45 token, which provides time stamp and file name information for the stream;
46 when processing a BSM token stream from a stream as opposed to a single file
47 source, file tokens may be seen at any point between ordinary records
48 identifying when particular parts of the stream begin and end.
49 All other tokens will appear in the context of a complete BSM audit record,
52 token, and ends with a
54 token, which describe the audit record.
55 Between these two tokens will appear a variety of data tokens, such as
56 process information, file path names, IPC object information, MAC labels,
57 socket information, and so on.
59 The BSM file format defines specific token orders for each record event type;
60 however, some variation may occur depending on the operating system in use,
61 what system options, such as mandatory access control, are present.
63 This manual page documents the common token types and their binary format, and
64 is intended for reference purposes only.
65 It is recommended that application programmers use the
67 interface to read and write tokens, rather than parsing or constructing
72 token is used at the beginning and end of an audit log file to indicate
73 when the audit log begins and ends.
74 It includes a pathname so that, if concatenated together, original file
75 boundaries are still observable, and gaps in the audit log can be identified.
78 token can be created using
80 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
81 .It Sy "Field Bytes Description"
82 .It "Token ID 1 byte Token ID"
83 .It "Seconds 4 bytes File time stamp"
84 .It "Microseconds 4 bytes File time stamp"
85 .It "File name lengh 2 bytes File name of audit trail"
86 .It "File pathname N bytes + 1 NUL File name of audit trail"
91 token is used to mark the beginning of a complete audit record, and includes
92 the length of the total record in bytes, a version number for the record
93 layout, the event type and subtype, and the time at which the event occurred.
96 token can be created using
97 .Xr au_to_header32 3 ;
100 token can be created using
101 .Xr au_to_header64 3 .
102 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
103 .It Sy "Field Bytes Description"
104 .It "Token ID 1 byte Token ID"
105 .It "Record Byte Count 4 bytes Number of bytes in record"
106 .It "Version Number 2 bytes Record version number"
107 .It "Event Type 2 bytes Event type"
108 .It "Event Modifier 2 bytes Event sub-type"
109 .It "Seconds 4/8 bytes Record time stamp (32/64-bits)"
110 .It "Nanoseconds 4/8 bytes Record time stamp (32/64-bits)"
112 .Ss Expanded Header Token
115 token is an expanded version of the
117 token, with the addition of a machine IPv4 or IPv6 address.
120 token can be created using
121 .Xr au_to_header32_ex 3 ;
124 token can be created using
125 .Xr au_to_header64_ex 3 .
126 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
127 .It Sy "Field Bytes Description"
128 .It "Token ID 1 byte Token ID"
129 .It "Record Byte Count 4 bytes Number of bytes in record"
130 .It "Version Number 2 bytes Record version number"
131 .It "Event Type 2 bytes Event type"
132 .It "Event Modifier 2 bytes Event sub-type"
133 .It "Address Type/Length 1 byte Host address type and length"
134 .It "Machine Address 4/16 bytes IPv4 or IPv6 address"
135 .It "Seconds 4/8 bytes Record time stamp (32/64-bits)"
136 .It "Nanoseconds 4/8 bytes Record time stamp (32/64-bits)"
141 terminates a BSM audit record, and contains a magic number,
142 .Dv TRAILER_PAD_MAGIC
143 and length that can be used to validate that the record was read properly.
146 token can be created using
147 .Xr au_to_trailer 3 .
148 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
149 .It Sy "Field Bytes Description"
150 .It "Token ID 1 byte Token ID"
151 .It "Trailer Magic 2 bytes Trailer magic number"
152 .It "Record Byte Count 4 bytes Number of bytes in record"
154 .Ss Arbitrary Data Token
157 token contains a byte stream of opaque (untyped) data.
158 The size of the data is calculated as the size of each unit of data
159 multipled by the number of units of data.
162 field is present to specify how to print the data, but interpretation of
163 that field is not currently defined.
166 token can be created using
168 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
169 .It Sy "Field Bytes Description"
170 .It "Token ID 1 byte Token ID"
171 .It "How to Print 1 byte User-defined printing information"
172 .It "Basic Unit 1 byte Size of a unit in bytes"
173 .It "Unit Count 1 byte Number of units of data present"
174 .It "Data Items Variable User data"
179 token holds a network byte order IPv4 or IPv6 address.
182 token can be created using
184 for an IPv4 address, or
185 .Xr au_to_in_addr_ex 3
190 section for information on the storage of this token.
192 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
193 .It Sy "Field Bytes Description"
194 .It "Token ID 1 byte Token ID"
195 .It "IP Address Type 1 byte Type of address"
196 .It "IP Address 4/16 bytes IPv4 or IPv6 address"
198 .Ss Expanded in_addr Token
205 section for information on the storage of this token.
206 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
207 .It Sy "Field Bytes Description"
208 .It "Token ID 1 byte Token ID"
214 token contains an IP packet header in network byte order.
217 token can be created using
219 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
220 .It Sy "Field Bytes Description"
221 .It "Token ID 1 byte Token ID"
222 .It "Version and IHL 1 byte Version and IP header length"
223 .It "Type of Service 1 byte IP TOS field"
224 .It "Length 2 bytes IP packet length in network byte order"
225 .It "ID 2 bytes IP header ID for reassembly"
226 .It "Offset 2 bytes IP fragment offset and flags, network byte order"
227 .It "TTL 1 byte IP Time-to-Live"
228 .It "Protocol 1 byte IP protocol number"
229 .It "Checksum 2 bytes IP header checksum, network byte order"
230 .It "Source Address 4 bytes IPv4 source address"
231 .It "Destination Address 4 bytes IPv4 destination address"
233 .Ss Expanded ip Token
237 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
238 .It Sy "Field Bytes Description"
239 .It "Token ID 1 byte Token ID"
245 token stores an IP port number in network byte order.
248 token can be created using
250 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
251 .It Sy "Field Bytes Description"
252 .It "Token ID 1 byte Token ID"
253 .It "Port Number 2 bytes Port number in network byte order"
258 token contains a pathname.
261 token can be created using
263 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
264 .It Sy "Field Bytes Description"
265 .It "Token ID 1 byte Token ID"
266 .It "Path Length 2 bytes Length of path in bytes"
267 .It "Path N bytes + 1 NUL Path name"
272 token contains a set of NUL-terminated path names.
275 API cannot currently create a
278 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
279 .It Sy "Field Bytes Description"
280 .It "Token ID 1 byte Token ID"
281 .It "Count 2 bytes Number of NUL-terminated string(s) in token"
282 .It "Path Variable count NUL-terminated string(s)"
287 token contains a description of the security properties of a process
288 involved as the target of an auditable event, such as the destination for
290 It should not be confused with the
292 token, which describes the subject performing an auditable event.
293 This includes both the traditional
295 security properties, such as user IDs and group IDs, but also audit
296 information such as the audit user ID and session.
299 token can be created using
300 .Xr au_to_process32 3
302 .Xr au_to_process64 3 .
303 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
304 .It Sy "Field Bytes Description"
305 .It "Token ID 1 byte Token ID"
306 .It "Audit ID 4 bytes Audit user ID"
307 .It "Effective User ID 4 bytes Effective user ID"
308 .It "Effective Group ID 4 bytes Effective group ID"
309 .It "Real User ID 4 bytes Real user ID"
310 .It "Real Group ID 4 bytes Real group ID"
311 .It "Process ID 4 bytes Process ID"
312 .It "Session ID 4 bytes Audit session ID"
313 .It "Terminal Port ID 4/8 bytes Terminal port ID (32/64-bits)"
314 .It "Terminal Machine Address 4 bytes IP address of machine"
316 .Ss Expanded Process Token
319 token contains the contents of the
321 token, with the addition of a machine address type and variable length
322 address storage capable of containing IPv6 addresses.
325 token can be created using
326 .Xr au_to_process32_ex 3
328 .Xr au_to_process64_ex 3 .
329 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
330 .It Sy "Field Bytes Description"
331 .It "Token ID 1 byte Token ID"
332 .It "Audit ID 4 bytes Audit user ID"
333 .It "Effective User ID 4 bytes Effective user ID"
334 .It "Effective Group ID 4 bytes Effective group ID"
335 .It "Real User ID 4 bytes Real user ID"
336 .It "Real Group ID 4 bytes Real group ID"
337 .It "Process ID 4 bytes Process ID"
338 .It "Session ID 4 bytes Audit session ID"
339 .It "Terminal Port ID 4/8 bytes Terminal port ID (32/64-bits)"
340 .It "Terminal Address Type/Length 1 byte Length of machine address"
341 .It "Terminal Machine Address 4 bytes IPv4 or IPv6 address of machine"
346 token contains a system call or library function return condition, including
347 return value and error number associated with the global variable
351 token can be created using
354 .Xr au_to_return64 3 .
355 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
356 .It Sy "Field Bytes Description"
357 .It "Token ID 1 byte Token ID"
358 .It "Error Number 1 byte Errno value, or 0 if undefined"
359 .It "Return Value 4/8 bytes Return value (32/64-bits)"
364 token contains information on the subject performing the operation described
365 by an audit record, and includes similar information to that found in the
370 However, those tokens are used where the process being described is the
371 target of the operation, not the authorizing party.
374 token can be created using
375 .Xr au_to_subject32 3
377 .Xr au_to_subject64 3 .
378 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
379 .It Sy "Field Bytes Description"
380 .It "Token ID 1 byte Token ID"
381 .It "Audit ID 4 bytes Audit user ID"
382 .It "Effective User ID 4 bytes Effective user ID"
383 .It "Effective Group ID 4 bytes Effective group ID"
384 .It "Real User ID 4 bytes Real user ID"
385 .It "Real Group ID 4 bytes Real group ID"
386 .It "Process ID 4 bytes Process ID"
387 .It "Session ID 4 bytes Audit session ID"
388 .It "Terminal Port ID 4/8 bytes Terminal port ID (32/64-bits)"
389 .It "Terminal Machine Address 4 bytes IP address of machine"
391 .Ss Expanded Subject Token
394 token consists of the same elements as the
396 token, with the addition of type/length and variable size machine address
397 information in the terminal ID.
400 token can be created using
401 .Xr au_to_subject32_ex 3
403 .Xr au_to_subject64_ex 3 .
404 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
405 .It Sy "Field Bytes Description"
406 .It "Token ID 1 byte Token ID"
407 .It "Audit ID 4 bytes Audit user ID"
408 .It "Effective User ID 4 bytes Effective user ID"
409 .It "Effective Group ID 4 bytes Effective group ID"
410 .It "Real User ID 4 bytes Real user ID"
411 .It "Real Group ID 4 bytes Real group ID"
412 .It "Process ID 4 bytes Process ID"
413 .It "Session ID 4 bytes Audit session ID"
414 .It "Terminal Port ID 4/8 bytes Terminal port ID (32/64-bits)"
415 .It "Terminal Address Type/Length 1 byte Length of machine address"
416 .It "Terminal Machine Address 4 bytes IPv4 or IPv6 address of machine"
418 .Ss System V IPC Token
421 token contains the System V IPC message handle, semaphore handle or shared
423 A System V IPC token may be created using
425 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
426 .It Sy "Field Bytes Description"
427 .It "Token ID 1 byte Token ID"
428 .It "Object ID type 1 byte Object ID"
429 .It "Object ID 4 bytes Object ID"
434 token contains a single NUL-terminated text string.
437 token may be created using
439 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
440 .It Sy "Field Bytes Description"
441 .It "Token ID 1 byte Token ID"
442 .It "Text Length 2 bytes Length of text string including NUL"
443 .It "Text N bytes + 1 NUL Text string including NUL"
448 token describes the attributes of a file associated with the audit event.
449 As files may be identified by 0, 1, or many path names, a path name is not
450 included with the attribute block for a file; optional
452 tokens may also be present in an audit record indicating which path, if any,
453 was used to reach the object.
456 token can be created using
460 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
461 .It Sy "Field Bytes Description"
462 .It "Token ID 1 byte Token ID"
463 .It "File Access Mode 1 byte mode_t associated with file"
464 .It "Owner User ID 4 bytes uid_t associated with file"
465 .It "Owner Group ID 4 bytes gid_t associated with file"
466 .It "File System ID 4 bytes fsid_t associated with file"
467 .It "File System Node ID 8 bytes ino_t associated with file"
468 .It "Device 4/8 bytes Device major/minor number (32/64-bit)"
473 token contains a list of group IDs associated with the audit event.
476 token can be created using
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 "Number of Groups 2 bytes Number of groups in token"
482 .It "Group List N * 4 bytes List of N group IDs"
484 .Ss System V IPC Permission Token
486 .Dq System V IPC permission
487 token contains a System V IPC access permissions.
488 A System V IPC permission token may be created using
489 .Xr au_to_ipc_perm 3 .
490 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
491 .It Sy "Field Bytes Description"
492 .It "Token ID 1 byte Token ID"
493 .It Li "Owner user ID" Ta "4 bytes" Ta "User ID of IPC owner"
494 .It Li "Owner group ID" Ta "4 bytes" Ta "Group ID of IPC owner"
495 .It Li "Creator user ID" Ta "4 bytes" Ta "User ID of IPC creator"
496 .It Li "Creator group ID" Ta "4 bytes" Ta "Group ID of IPC creator"
497 .It Li "Access mode" Ta "4 bytes" Ta "Access mode"
498 .It Li "Sequnce number" Ta "4 bytes" Ta "Sequnce number"
499 .It Li "Key" Ta "4 bytes" Ta "IPC key"
504 token contains informations about arguments of the system call.
505 Depending on the size of the desired argument value, an Arg token may be
510 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
511 .It Sy "Field Bytes Description"
512 .It "Token ID 1 byte Token ID"
513 .It Li "Argument ID" Ta "1 byte" Ta "Argument ID"
514 .It Li "Argument value" Ta "4/8 bytes" Ta "Argument value"
515 .It Li "Length" Ta "2 bytes" Ta "Length of the text"
516 .It Li "Text" Ta "N bytes + 1 nul" Ta "The string including nul"
521 token contains informations about arguements of the exec() system call.
522 An exec_args token may be created using
523 .Xr au_to_exec_args 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" Ta "4 bytes" Ta "Number of arguments"
528 .It Li "Text" Ta "* bytes" Ta "Count null-terminated strings"
533 token contains current eviroment variables to an exec() system call.
534 An exec_args token may be created using
535 .Xr au_to_exec_env 3 .
536 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
537 .It Sy "Field Bytes Description"
538 .It "Token ID 1 byte Token ID"
539 .It Li "Count ID" Ta "4 bytes" Ta "Number of variables"
540 .It Li "Text" Ta "* bytes" Ta "Count nul-terminated strings"
545 token contains process exit/return code information.
548 token can be created using
550 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
551 .It Sy "Field Bytes Description"
552 .It "Token ID 1 byte Token ID"
553 .It "Status 4 bytes Process status on exit"
554 .It "Return Value 4 bytes Process return value on exit"
559 token contains informations about UNIX domain and Internet sockets.
560 Each token has four or eight fields.
561 Depend on type of socket a socket token may be created using
562 .Xr au_to_sock_unix 3 ,
563 .Xr au_to_sock_inet32 3 or
564 .Xr au_to_sock_inet128 3 .
565 .Bl -column -offset ind ".Sy Field Name Width XX" ".Sy XX Bytes XXXX" ".Sy Description"
566 .It Sy "Field" Ta Sy Bytes Ta Sy Description
567 .It Li "Token ID" Ta "1 byte" Ta "Token ID"
568 .It Li "Socket family" Ta "2 bytes" Ta "Socket family"
569 .It Li "Local port" Ta "2 bytes" Ta "Local port"
570 .It Li "Socket address" Ta "4 bytes" Ta "Socket address"
572 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
573 .It Sy "Field Bytes Description"
574 .It "Token ID 1 byte Token ID"
575 +.It Li "Socket domain" Ta "4 bytes" Ta "Socket domain"
576 +.It Li "Socket family" Ta "2 bytes" Ta "Socket family"
577 +.It Li "Address type" Ta "1 byte" Ta "Address type (IPv4/IPv6)"
578 +.It Li "Local port" Ta "2 bytes" Ta "Local port"
579 +.It Li "Local IP address" Ta "4/16 bytes" Ta "Local IP address"
580 +.It Li "Remote port" Ta "2 bytes" Ta "Remote port"
581 +.It Li "Remote IP address" Ta "4/16 bytes" Ta "Remote IP address"
583 .Ss Expanded Socket Token
587 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
588 .It Sy "Field Bytes Description"
589 .It "Token ID 1 byte Token ID"
595 token contains a unique and monotonically increasing audit event sequence ID.
596 Due to the limited range of 32 bits, serial number arithmetic and caution
597 should be used when comparing sequence numbers.
598 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
599 .It Sy "Field Bytes Description"
600 .It "Token ID 1 byte Token ID"
601 .It "Sequence Number 4 bytes Audit event sequence number"
607 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
608 .It Sy "Field Bytes Description"
609 .It "Token ID 1 byte Token ID"
612 .Ss Use-of-auth Token
616 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
617 .It Sy "Field Bytes Description"
618 .It "Token ID 1 byte Token ID"
625 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
626 .It Sy "Field Bytes Description"
627 .It "Token ID 1 byte Token ID"
634 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
635 .It Sy "Field Bytes Description"
636 .It "Token ID 1 byte Token ID"
643 .Bl -column -offset 3n ".No Terminal Address Type/Length" ".No N bytes + 1 NUL"
644 .It Sy "Field Bytes Description"
645 .It "Token ID 1 byte Token ID"
656 The OpenBSM implementation was created by McAfee Research, the security
657 division of McAfee Inc., under contract to Apple Computer Inc.\& in 2004.
658 It was subsequently adopted by the TrustedBSD Project as the foundation for
659 the OpenBSM distribution.
661 The Basic Security Module (BSM) interface to audit records and audit event
662 stream format were defined by Sun Microsystems.
664 This manual page was written by
665 .An Robert Watson Aq rwatson@FreeBSD.org .
671 token has undefined values.
677 token layout documented here appears to be in conflict with the
682 .Xr au_to_in_addr_ex 3 .