XAR Archive (.xar)

Extensible archive used by macOS installers.

Overview

A xar file has a header (magic xar!, header size, version, compressed and uncompressed TOC lengths, checksum algorithm), a zlib-compressed XML table of contents and a heap of file data. Each file entry has an encoding (gzip, bzip2, LZMA, none) and checksums.

Where it is used

  • macOS flat installer packages (.pkg) and Safari extensions.

History

  • Created in 2004 by the OpenDarwin project.

Status today

  • Actively used on macOS.

Structures read by the implementation

Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.

XarArchiveModule.Mount buffer h · XarArchiveModule.cs

OffsetSizeTypeFieldNotes
0x04bytes–
0x42u16 BEHeader Size
0x88u64 BEToc Compressed
0x108u64 BEToc Size

XarArchiveModule.Probe buffer h · XarArchiveModule.cs

OffsetSizeTypeFieldNotes
0x04bytes–
0x42u16 BE–

XarCarver.Verify buffer h · XarCarver.cs

OffsetSizeTypeFieldNotes
0x01u8–
0x11u8–
0x21u8–
0x31u8–
0x42u16 BEHeader Size
0x62u16 BEVersion
0x88i64 BEToc Compressed

Constants

General XarArchiveModule

NameValueTypeNotes
Magic“xar!”u8.ToArray()byte[]

Implementation limits reader

ClassNameValueNotes
XarArchiveModuleMaxTocSize64 << 20

Signatures and magic strings referenced

TextWhereContext
xar!XarArchiveModuleprivate static readonly byte[] Magic = “xar!”u8.ToArray();
Structures and constants were extracted from: Carving/Plugins/Xar/XarCarver.cs, Modules/FileSystems/XarArchiveModule.cs. Prose sections are a summary from public sources; verify details before relying on them.