
My most recent submission to the Apple Security Bounty. Fixed in iOS 27.2
/usr/lib/libarchive.2.dylib (as shipped in iOS 27.0 / 24A437) writes two bytes past a 1024-byte heap allocation while parsing an ISO 9660 image containing a Joliet name table.
In build_pathname_utf16be(), the pathname-separator stores are not bounded:
if (build_pathname_utf16be(p, max, len, file->parent) != 0)
return (-1);
p[*len] = 0;
p[*len + 1] = '/';
*len += 2;
When the parent pathname is 1024 bytes, *len == 1024 and the function writes p[1024] and p[1025] past malloc(1024). The length check that returns "Pathname is too long" runs after these stores.
The two bytes written are 0x00 0x2f. In the attached standalone PoC, they corrupt an adjacent pointer/length object and produce Target Flag-confirmed arbitrary write, redirected execution, and register control. Separately, the same crafted file reaches iOS's ArchiveService through Files and causes a reproducible PAC-authentication crash in libarchive's ISO 9660 cleanup path.
The ISO 9660 Joliet reader reconstructs directory paths recursively in build_pathname_utf16be(). After processing a parent directory, it appends a UTF-16BE path separator using two stores:
if (build_pathname_utf16be(p, max, len, file->parent) != 0)
return (-1);
p[*len] = 0; /* no check that *len + 2 <= max */
p[*len + 1] = '/';
*len += 2;
These stores are performed without first verifying that at least two bytes remain in the destination buffer. If the reconstructed parent pathname is exactly 1024 bytes long, *len equals the allocation size when the stores execute. The function then writes 0x00 at offset 1024 and / at offset 1025, outside the 1024-byte utf16be_path allocation.
The pathname-length validation that returns “Pathname is too long” occurs only after these stores. Consequently, the function reports the error after the out-of-bounds write has already modified adjacent heap memory.
The attached Xcode project calls the public libarchive API:
archive_read_open_memory → archive_read_next_header
It uses a crafted ISO 9660/Joliet image and shapes its own heap so that the two-byte overwrite affects an adjacent pointer/length object. One launch demonstrates:
_COMM_PAGE_ASB_TARGET_VALUE is written to _COMM_PAGE_ASB_TARGET_ADDRESS and to a separately mapped address, with the mapped write verified by readback._COMM_PAGE_ASB_TARGET_ADDRESS and called._COMM_PAGE_ASB_TARGET_VALUE is present in x0 at the redirected execution target.The PoC is a normally launched, sandboxed application on a physical device. The Target Flag values are read at runtime and are not hardcoded.
PoC/, using scheme poc. The product is libarchive2.app, bundle identifier eliya.m.asb.xcrun devicectl device process launch --console --terminate-existing eliya.m.asb
poc.iso on launch without additional user interaction.libarchive2 PoC: document poc.iso
commpage TARGET_VALUE=0x08acf5210b466b05 TARGET_ADDRESS=0xc7df4e66456a598b
write *(0x00000001001f0010) = 0x08acf5210b466b05 verified by readback
write *(0xc7df4e66456a598b) = 0x08acf5210b466b05 far=0xc7df4e66456a598b x6=0x08acf5210b466b05
result: success
I transferred the same crafted input to an iPhone17,1 running iOS 27.0 (24A437) and a iPhone14,5 on iOS 26.7 (23H24). After the file was received I tapped the file once in Files. This invoked the archive handling/extraction path.
Files handed the input to:
/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/XPCServices/ArchiveService.xpc/ArchiveService
Attacker-controlled-file reachability result with one user tap :)
The supplied file is named target.zip, but its content is an ISO 9660 image. ArchiveService selected the ISO 9660 reader based on the file content. Its crafted directory chain produces a 1024-byte parent pathname, triggering the out-of-bounds stores.
The crash occurs during cleanup immediately after the free of iso9660->utf16be_path and before the free of iso9660->utf16be_previous_path:
ldr x8, [sp, #0x10] ; iso9660
ldr x0, [x8, #0x1f0] ; iso9660->utf16be_path
bl free ; return address corresponds to cleanup + 208
ldr x8, [sp, #0x10]
ldr x0, [x8, #0x200] ; iso9660->utf16be_previous_path
bl free
The captured register state is consistent with the overwritten qword being 1024 bytes after the 1024-byte path allocation:
x0 = 0x1030ec5c0
x8 = 0x1030ec9c0 x8 - x0 = 1024
[x8] = 0x0aa00000002f00 low 16 bits = 0x2f00
x9 = [x8 + 8] = 7
The low 16 bits 0x2f00 match the two bytes written by the vulnerable stores. The subsequent autdb failure in mfm_free is consistent with authentication of a corrupted pointer-bearing allocator field.
Eliya M.