# CVE-2026-112659 — WebKit/JSC Type Confusion → Arbitrary Code Execution

**Component:** JavaScriptCore (DFG/FTL JIT compiler)  
**WebKit Bugzilla:** 321982  
**Impact:** Arbitrary code execution via malicious web content  
**Credit:** OpenAI Codex Security (Amy Burnett), Chris Rohlf with Anthropic Research  
**Apple description:** "A type confusion issue was addressed with improved memory handling"  
**Fixed in:** Safari 27.2, iOS 26.7.2, macOS Golden Gate 27.2, visionOS 27.2  
**Status:** Fix under embargo (not yet in WebKit open source, Bugzilla restricted)

## Analysis Approach

Cannot binary diff WebKit/JSC between 26.6.2 and 26.7.2 (dyld_shared_cache extraction blocked on Windows). Analysis based on:
1. Related bug patterns (WebKit bug 321705 — PhaseShift, same bug range)
2. JSC DFG exploitation literature (DarkSword, Exodus Intel spill, HackTricks)
3. 26.6.2 JSC symbol analysis (10.6 MB symbol dump, 41.5 MB binary)
4. Ghidra analysis (in progress)

## Related Bug: WebKit Bug 321705 (PhaseShift)

Bug 321705 is 277 bugs before 321982, in the same component, same timeframe (Sept-Oct 2026). Its mechanism:

1. DFG `Spread` node in abstract interpreter resolves realm from node's origin
2. `FixupPhase` resolves realm from `child1()`'s origin
3. Cross-realm inlined call → structure proof checked against wrong realm
4. Watchpoint watches one realm, proof protects another
5. Replacing iterator on proof's realm doesn't fire watchpoint
6. `CheckStructure` folded away
7. `ArrayWithDouble` ↔ `ArrayWithContiguous` confusion
8. **Result:** addrof/fakeobj primitives

**Fix (321705):** `Spread` path uses `node->child1()`'s realm, matching watchpoint check.

## Candidate Type Confusion Sites for Bug 321982

Given bug 321982 is a type confusion "addressed with improved memory handling" (not "improved checks"), the fix likely involves:
- A memory management change (structure tracking, object lifetime, or barrier)
- NOT just a validation check addition

### Candidate 1: Abstract Interpreter `executeEffects` — Array Operation Node

**Functions:**
- `JSC::DFG::AbstractInterpreter<InPlaceAbstractState>::executeEffects` @ `0x198f90494`
- `JSC::DFG::AbstractInterpreter<AtTailAbstractState>::executeEffects` @ `0x1999afe90`

The abstract interpreter `executeEffects` handles ~200+ DFG node types. Each case must correctly model the node's effects on abstract values. A mismatch between:
- What the AI thinks a value's type is (abstract value)
- What the value actually is at runtime

...causes type confusion. Bug 321705 was specifically in the `Spread` case. Bug 321982 could be in:
- `GetByVal` / `PutByVal` — array element access with wrong indexing type
- `NewArrayWithSpread` — spread into new array with wrong element type assumption
- `ArraySlice` / `ArrayConcat` — creates new array from existing, type assumption wrong
- `CallVarargs` with spread — argument spreading with stale type info
- `ForwardVarargs` — forwarding arguments with wrong assumed types

### Candidate 2: FixupPhase Realm/Structure Mismatch

**Function:** `JSC::DFG::FixupPhase::fixupNode` @ `0x19994d670`

FixupPhase converts generic operations into specialized ones based on type feedback. If it specializes based on one realm's structures but the operation executes in another realm:
- `blessArrayOperation` @ `0x19996afe4` — selects array mode, could choose wrong mode
- `checkArray` @ `0x19996d3d4` — validates array structure, could check wrong structure
- `setSaneChainIfPossible` @ `0x19996b414` — sets chain optimization, could use stale chain

### Candidate 3: `canDoFastSpread` with Stale State

**Function:** `JSC::DFG::Graph::canDoFastSpread` @ `0x199939040`

This function decides if a spread operation can take the fast path (no iterator protocol). If it makes this decision based on stale abstract values (e.g., after a structure transition that wasn't tracked), the fast path runs on an array whose actual type differs from the assumed type.

### Candidate 4: FTL Lowering Discrepancy

**Functions:**
- `JSC::FTL::LowerDFGToB3::compileNode` @ `0x199083444`
- `JSC::FTL::LowerDFGToB3::compileCallOrConstructVarargsSpread` (multiple)
- `JSC::FTL::LowerDFGToB3::compileForwardVarargsWithSpread` @ `0x1991c0948`
- `JSC::FTL::LowerDFGToB3::getSpreadLengthFromInlineCallFrame` @ `0x19919bb18`

The FTL compiler lowers DFG IR to B3 IR. If the lowering makes different assumptions than the abstract interpreter about a node's type effects:
- `compileForwardVarargsWithSpread` contains recursive lambda for spread argument processing
- `getSpreadLengthFromInlineCallFrame` computes length — wrong length → buffer overflow

### Candidate 5: HavingABadTime Watchpoint Race

**Function:** `JSC::DFG::Graph::isWatchingHavingABadTimeWatchpoint` @ `0x198f03060`

The "having a bad time" watchpoint fires when the global object enters a state where indexed property access can't be optimized. If this watchpoint doesn't fire correctly (similar to 321705's realm mismatch but for a different watchpoint type), the JIT continues using fast indexed access on objects that require slow-path checks.

## Exploitation Pattern (Based on 321705 and DarkSword)

### Step 1: Trigger Type Confusion
```javascript
// Force DFG/FTL compilation of target function
function trigger(arr) {
    // Operation that DFG specializes for ArrayWithDouble
    // but actually operates on ArrayWithContiguous after transition
    return [...arr];  // or Array.from(arr), or arr.slice(), etc.
}

// Warm up with double arrays
for (let i = 0; i < 10000; i++) {
    trigger([1.1, 2.2, 3.3]);
}

// Trigger type confusion by causing unexpected structure transition
// (specific mechanism depends on the bug)
```

### Step 2: Build Primitives
```javascript
// addrof: Store object, read back as double (ArrayWithDouble mode on ArrayWithContiguous)
function addrof(obj) {
    confused_array[0] = obj;  // Stored as JSValue (pointer)
    return f64[0];            // Read as double (raw bits)
}

// fakeobj: Store double, read back as object (reverse direction)
function fakeobj(addr) {
    f64[0] = addr;           // Write raw bits
    return confused_array[0]; // Read as JSValue (pointer)
}
```

### Step 3: Arbitrary R/W via Butterfly
```javascript
// Create fake JSArray with controlled butterfly pointer
// butterfly[i] reads/writes arbitrary memory at butterfly_addr + i*8
```

### Step 4: Code Execution (PAC bypass needed on arm64e)
Options on iOS 26.6.2:
- JIT page writable-executable window
- PAC signing oracle via dyld (if CVE-2026-20700 pattern applies)
- Return-oriented programming with PAC-signed gadgets
- Overwrite JIT code during compilation window

## Key Binary Addresses (26.6.2 JSC)

| Function | Address | Role |
|----------|---------|------|
| `executeEffects` (InPlace) | 0x198f90494 | Main AI — models node effects |
| `executeEffects` (AtTail) | 0x1999afe90 | Post-block AI |
| `fixupNode` | 0x19994d670 | Converts generic → specialized ops |
| `canDoFastSpread` | 0x199939040 | Decides fast spread path |
| `compileSpread` | 0x198f037f4 | DFG code gen for Spread |
| `compileCheckStructure` | 0x198f1575c | DFG structure check |
| `compileNewArrayWithSpread` | 0x198f07518 | DFG new array + spread |
| `isWatchingHavingABadTimeWatchpoint` | 0x198f03060 | Bad-time watchpoint |
| `LowerDFGToB3::compileNode` | 0x199083444 | FTL lowering entry |
| `filterByValue` (AtTail) | 0x1999c1ec4 | Filters abstract value |
| `filterByValue` (AbstractValue) | 0x1997eb4a4 | Core value filtering |
| `blessArrayOperation` | 0x19996afe4 | Array mode selection |
| `checkArray` | 0x19996d3d4 | Array structure validation |
| `speculateArray` | 0x198f284dc | Array speculation |

## Ghidra Decompilation Findings (26.6.2 JSC)

Ghidra headless analysis completed on 26.6.2 JavaScriptCore (41.5 MB → 537 MB analysis DB).
144 DFG type-confusion-related functions decompiled (7 MB output).

### executeEffects Spread Handling (Case 0x125)

Decompiled from `AbstractInterpreter<AtTailAbstractState>::executeEffects` @ 0x1999afe90:

```c
case 0x125:  // Spread node
    sVar8 = *(short *)((*(ulong *)pNVar99 & 0xff00ffffffffffff) + 0x12);
    if ((sVar8 != 0x175) && (sVar8 != 0x178)) {
        // Check if fast spread is possible
        pGVar45 = *(Graph **)(this_00 + 8);
        pAVar40 = AtTailAbstractState::forNode(...);
        uVar48 = Graph::canDoFastSpread(pGVar45, param_2, pAVar40);
        if ((uVar48 & 1) == 0) {
            SoftwareBreakpoint(0xc471, 0x1999bf568);  // CRASH if can't fast spread
        }
    }
    // Register structures from global object (offsets 0x96e0, 0x96e8)
    pNVar99 = Graph::registerStructure(..., *(Structure **)(*(long *)(this + 0x10) + 0x96e0), ...);
    // ... build RegisteredStructureSet and set abstract value
```

**Key observations:**
1. `canDoFastSpread` receives `param_2` (the Spread node itself), NOT `child1()` (the operand)
2. The graph pointer comes from `this_00 + 8`, and the abstract value from `AtTailAbstractState::forNode`
3. If `canDoFastSpread` returns false, it's a hard crash (SoftwareBreakpoint) — not a fallback to slow path
4. Structures are registered from a fixed offset (0x96e0, 0x96e8) on the global object — this assumes a specific realm

### executeEffects NewArrayWithSpread (Case 0x124)

```c
case 0x124:  // NewArrayWithSpread
    uVar48 = Graph::isWatchingHavingABadTimeWatchpoint(*(Graph **)(this + 8), param_2);
    if ((uVar48 & 1) == 0) {
        SoftwareBreakpoint(...);  // CRASH if not watching
    }
    pGVar45 = *(Graph **)(this + 8);
    CodeOrigin::CodeOrigin(&local_260, param_2);
    lVar60 = Graph::globalObjectFor(pGVar45, &local_260);
    // Get structure from global object at offset 0x3c4
    pSVar32 = (Structure *)(DAT_... + ((ulong)*(uint *)(lVar60 + 0x3c4) & 0xfffffffe));
    // Set abstract value from that structure
    AbstractValue::set(pAVar40, *(Graph **)pAVar86, pSVar32);
```

**Key observations:**
1. Uses `globalObjectFor` with the node's `CodeOrigin` — resolves realm from node origin
2. Structure at offset 0x3c4 from the global object determines the resulting array's type
3. If this resolves to the wrong realm (cross-realm inlining), the wrong structure is used
4. This is exactly the pattern from bug 321705 — realm mismatch in Spread optimization

### Candidate Bug Pattern for 321982

Given that 321705 fixed the realm resolution in `Spread` case to use `child1()`'s origin:
- Bug 321982 may be in `NewArrayWithSpread` (case 0x124) where `globalObjectFor` still resolves from the node's own `CodeOrigin`, not from the operand's origin
- Or in another node type that has a similar realm mismatch
- The "improved memory handling" fix language suggests the fix involves structure tracking or memory barrier changes, not just a realm check correction

## Blockers and Next Steps

### Blockers
1. **dyld_shared_cache extraction** — Cannot get 26.7.2 JSC binary on Windows
2. **Bugzilla embargo** — Bug 321982 not public
3. **Fix commit not in open source** — WebKitGTK advisory hasn't published this CVE yet

### Next Steps
1. **Ghidra analysis** — Import 26.6.2 JSC, decompile `executeEffects` and `canDoFastSpread` to understand control flow
2. **WSL/Docker** — Try Linux-based dyld extraction tools in WSL
3. **On-device testing** — Use Safari Web Inspector on iPhone to trigger DFG compilation and observe type transitions
4. **Fuzzing approach** — Build JS fuzzer targeting array type transitions + spread operations + cross-realm calls
5. **WebKit open source monitoring** — Watch for Bugzilla 321982 derestriction

## Assessment

Without the 26.7.2 binary diff, we cannot definitively identify the exact bug. However:
- The bug is almost certainly in the DFG/FTL JIT compiler's handling of array type transitions
- It likely involves a discrepancy between abstract interpretation and actual runtime behavior
- Spread operations and cross-realm scenarios are the most probable triggers
- The "improved memory handling" description suggests a fix involving structure tracking or GC barriers, not just a bounds check

**Exploitation feasibility on 26.6.2:** HIGH once the exact trigger is identified. The addrof/fakeobj primitive chain is well-documented for JSC type confusion bugs. The main challenge is the arm64e PAC bypass for code execution.
