# Feather 18w06a Exploit Research — Changes vs 1.12.2

This file documents whether the 1.12.2 exploits (from `exploits.md`) still work in snapshot 18w06a,
and what has changed. All findings are **verified against the code** in `18w06a-decompiledSrc`.

---

## Quick summary

| Exploit | Still works? | Notes |
|---|---|---|
| §1 Update suppression | **YES** | `Utils.run` exception swallow + `PacketUtils.ensureOnSameThread` re-queue both intact |
| §2 `fallImmediately` flag | **YES** | Identical semantics, toggle moved from `populateChunk` to `decorate` |
| §2 `shouldSignal` flag | **YES** | Instance field (was already instance in 1.12.2), identical semantics |
| §2 `doTicksImmediately` flag | **NO — REMOVED** | No equivalent mechanism exists |
| §3 Double tile tick scheduling | **YES** | Byte-for-byte identical vulnerability |
| §4 Word tearing | **YES** | `BitStorage.set()` two-unsynchronized-RMW pattern intact |
| §5 Chunk hashmap races | **PARTIALLY MITIGATED** | Map now `Long2ObjectMaps.synchronize`-wrapped; population no longer re-enters shared map from worker threads; residual non-atomicity in unload path |
| §6 Async lines | **YES** | `World.getBlockState`/`setBlockState` still trigger chunk gen; generation now runs on dedicated WorldGen worker threads instead of calling thread |
| §7 Glass threads | **YES** | `StainedGlassBlock.onAdded/onRemoved` → `BeaconBlock.updateBeam` → `HttpUtil.DOWNLOAD_THREAD_FACTORY` fully intact |
| §8 Falling block swaps | **YES** | Block-type-only match, un-gated TileEntityData merge, anvil damage all intact |
| §9 Savestates | **YES** | `RegionFile.writeChunkData` still silently drops chunks ≥256 sectors |
| §9.7 Race-forged item metadata | **PARTIALLY BROKEN** | Dispenser equip race + double hand read still exist, but `SkullItem.useOn` metadata→skull-type consumer removed; skull types are now distinct items; no `DyeItem.useOn` re-read |

---

## §1 Tick phases & update suppression

### Changes

- **`commandFunctions` phase moved** from position 5 (after `players`) to position 2 (after `jobs`).
  New order: `jobs → commandFunctions → levels → connection → players → tickables`.
  Old order: `jobs → levels → connection → players → commandFunctions → tickables`.
  This changes the relative ordering of function execution vs world ticking, but does not affect
  the update suppression mechanism itself.

### What still works

- `PacketUtils.ensureOnSameThread` (`network/PacketUtils.java:7-18`) — re-queues packets from
  netty threads to `pendingEvents` queue, throws `DifferentThreadException`.
- `MinecraftServer.pendingEvents` (`server/MinecraftServer.java:162`) — `Queues.newArrayDeque()`,
  drained in the `jobs` phase.
- `Utils.run` (`util/Utils.java:65-77`) — catches `ExecutionException`/`InterruptedException`,
  logs, and **returns without rethrowing**. The core swallow mechanism.
- `Connection.channelRead0` (`network/Connection.java:114-121`) — catches `DifferentThreadException`
  only (re-queue path).
- `ConnectionListener.tick` (`server/network/ConnectionListener.java:150-188`) — local → crash,
  remote → kick + disableAutoRead. Unchanged.
- `ServerWorld.tick()` (`server/world/ServerWorld.java:161-207`) — phases intact:
  `super.tick()` → mobSpawner → chunkSource → time → `doScheduledTicks(false)` → `tickChunks()`
  → chunkMap → villages → portalForcer → `doBlockEvents()`.
- `doScheduledTicks` (`ServerWorld.java:540-595`) — scheduled block tick errors **rethrow** as
  `CrashException` (crashes server). Only the re-queued packet task errors in `jobs` get swallowed.

### Verdict: **UPDATE SUPPRESSION STILL WORKS**

The core mechanism (crash a packet task during `jobs` phase → `Utils.run` swallows → world-phase
updates never execute) is fully intact.

---

## §2 Global flags

### `FallingBlock.fallImmediately` — **STILL EXISTS**

- Field: `block/FallingBlock.java:17` — `public static boolean fallImmediately`
- `tryFall` (`FallingBlock.java:41-66`): same instant-fall branch at line 44.
- Chunk generators still toggle it during `decorate()` (not `populateChunk` — that method no longer
  exists):
  - Overworld: `OverworldChunkGenerator.java:85` (true) / `99` (false)
  - Nether: `NetherChunkGenerator.java:269` / `283`
  - End: `TheEndChunkGenerator.java:181` / `195`
- **Change**: toggle is now in `decorate()` not `populateChunk()`. The "terrace population" exploit
  window is now the `DECORATED` chunk status step.

### `RedstoneWireBlock.shouldSignal` — **STILL EXISTS**

- Field: `block/RedstoneWireBlock.java:61` — `private boolean shouldSignal = true`
- Used in `doUpdatePower`: set false (208) → query neighbor signal (209) → restore true (210).
- `getDirectSignal`/`getSignal`/`isSignalSource` all check it. Same semantics.

### `ServerWorld.doTicksImmediately` — **REMOVED**

- No field exists anywhere in the codebase. Zero matches in any `.java` file.
- `ServerWorld.scheduleTick` now only queues via `addScheduledTick` into the two sets.
- The `doScheduledTicks(boolean flush)` parameter `flush` could theoretically bypass the time gate,
  but **nothing in the codebase calls `doScheduledTicks(true)`** — only `doScheduledTicks(false)` at
  `ServerWorld.java:195`.
- **Impact**: Instant tile ticks (ITT) for piston-based instant wire and instant-falling sand setups
  **cannot be triggered via this flag**. The mechanism is gone.

### `DragonEggBlock` — **NO reference to `fallImmediately`**

- `DragonEggBlock.java:50` is `if (world.isClient)`, not a `fallImmediately` check.
- The egg still inherits `FallingBlock`'s gravity behavior via `onAdded`/`updateShape` → `tick` →
  `tryFall`, so `fallImmediately` still applies to it through the parent class.

---

## §3 Double tile tick scheduling — **FULLY INTACT**

All six prerequisites are byte-for-byte identical:

| Component | File & Line | Status |
|---|---|---|
| `equals` on pos + block | `ScheduledTick.java:27-34` | Identical |
| `hashCode` on pos only | `ScheduledTick.java:37-39` | Identical |
| `compareTo` with unique `id` | `ScheduledTick.java:41-53` | Identical |
| `implements Comparable` | `ScheduledTick.java:6` | Identical |
| Dual HashSet / TreeSet | `ServerWorld.java:97-98` | Identical |
| Size mismatch crash check | `ServerWorld.java:544-546` | Identical |
| HashSet.contains() guard on add | `ServerWorld.java:468-474` | Identical |

The HashMap treeification exploit still works: 9+ ticks at the same BlockPos with different
blocks/times → bucket treeifies → `contains()` uses `compareTo` → bypasses guard → duplicates
enter → sets diverge → `IllegalStateException("TickNextTick list out of synch")`.

### Impact

- Instant wire / wireless redstone: **still possible**
- Anvil repairing via double ticks: **still possible**
- Server crash via out-of-synch: **still possible**
- Falling block swaps in the End with double ticks: **still possible**

---

## §4 Word tearing — **FULLY INTACT**

### `BitStorage.set()` (`util/BitStorage.java:28-41`)

Two unsynchronized read-modify-write ops for straddled values:
- Line 35: `this.data[j] = ...` (low bits)
- Line 39: `this.data[k] = ...` (high bits)

No synchronization, no volatile, no atomic operations.

### `BitStorage.get()` (`util/BitStorage.java:43-55`)

Non-atomic read of straddled values — reads `data[j]` and `data[k]` in two separate accesses.

### `BitStorage.getRaw()` (`util/BitStorage.java:57-59`)

Returns direct reference to internal `long[] data` — no defensive copy. Exploited by
`PalettedContainer.read/write` for serialization.

### `PalettedContainer` (`world/chunk/PalettedContainer.java`)

- Uses `BitStorage` for all block state storage (line 24: `protected BitStorage storage`)
- Network serialization reads/writes via `getRaw()` (lines 96, 102)
- Palette types: `LinearPalette` (bits ≤4), `HashMapPalette` (5-8), `GlobalPalette` (≥9)
- `GlobalPalette` (`GlobalPalette.java:13-22`) maps via `Block.STATE_REGISTRY.getId/get`
  → invalid torn ids → null → treated as `Blocks.AIR`

### `WorldChunk.setBlockState` (`world/chunk/WorldChunk.java:374-444`)

Re-read-after-write at line 397 (write) → line 405 (re-read check). A torn write can cause the
re-read to return garbage, making `setBlockState` return `null` or succeed unexpectedly.

### `WorldChunkSection` counters (`world/chunk/WorldChunkSection.java:28-45`)

Non-atomic `nonAirBlockCount`/`randomTickingBlockCount` — `++`/`--` are plain read-modify-write.

### Impact

- Invalid/1.13+ block states and unbreakable blocks via word tearing: **still possible**
- Silk touch bedrock path: **still possible** (requires async thread access to BitStorage)

---

## §5 Chunk hashmap races — **PARTIALLY MITIGATED**

### Key change: `ServerChunkCache.chunks` is now synchronized

- `ServerChunkCache.java:44`: `private final Long2ObjectMap<WorldChunk> chunks =
  Long2ObjectMaps.synchronize(new ChunkMap(8192));`
- Individual `get`/`put`/`remove` operations are each internally synchronized on the map.
- `getGeneratedChunk` (lines 107-113) and `finalizeChunk` (lines 175-202) use explicit
  `synchronized(this.chunks)` blocks for compound operations.

### What's gone

- **No 2x2 population grid in `WorldChunk`** — the old `WorldChunk.populate()` that loaded diagonal
  neighbors and triggered re-entrant population through the shared map no longer exists.
- Population now runs on dedicated `WorldGen-Scheduler`/`WorldGen-Worker-N` threads via
  `WorldGenRegion`, which works on a localized `ChunkAccess[]` array, not the shared hashmap.

### What remains

- The unload `tick()` path (`ServerChunkCache.java:262-285`) still does a compound
  **get → check `removed` → `unload`/`save` → `remove`** where the monitor is released between
  individual `get` and `remove` calls. Another thread could `put` a chunk between them.
- `getLoadedChunks()`/`unloadAllChunks()` iterate `this.chunks.values()` — iterators over a
  synchronized fastutil map are **not separately synchronized**.

### Verdict

The classic 1.12.2 chunk hashmap race (raw unsynchronized map + re-entrant population + unlocked
unload get/remove) is **substantially mitigated**. The residual non-atomicity in the unload path
is much narrower and harder to exploit. **Wormhole/duplicated chunks via this path are unlikely
to work in the same way.**

---

## §6 Async lines — **STILL EXISTS (with pipeline change)**

### What's the same

- `World.getBlockState` (`world/World.java:643-651`) and `setBlockState` (`World.java:263-310`)
  both call `getChunk(pos)` with no loaded-chunk guard → can trigger chunk generation.
- No thread-safety/affinity check blocks off-thread `getChunk` calls.

### What changed

- Chunk generation is now routed through a threaded pipeline:
  - `Scheduler.java:45` — "WorldGen-Scheduler" thread + `Scheduler.java:51-55` — `ForkJoinPool`
    of "WorldGen-Worker-N" threads.
  - `ServerChunkCache.getChunk` (lines 115-127) → `getChunkGenerationFuture().get()` blocks on
    the worker thread rather than performing generation on the calling thread.
- The calling thread (e.g., a "Downloader %d" glass thread) still **triggers** generation and blocks,
  but the actual `populate`/`decorate` runs on the WorldGen workers.

### Impact

- Async lines (block updates running concurrently with server thread via chunk generation from
  non-server threads): **still possible**, but generation executes on dedicated worker threads
  instead of the calling thread. This changes the timing and interleaving characteristics but
  the fundamental concurrency remains.

---

## §7 Glass threads — **FULLY INTACT**

### `StainedGlassBlock` (`block/StainedGlassBlock.java`)

- `onAdded` (lines 49-55): calls `BeaconBlock.updateBeam(world, pos)` at line 52 (when
  `!world.isClient`).
- `onRemoved` (lines 58-64): calls `BeaconBlock.updateBeam(world, pos)` at line 61.
- Identical to 1.12.2.

### `StainedGlassPaneBlock` (`block/StainedGlassPaneBlock.java`)

- `onAdded` (lines 28-34): calls `BeaconBlock.updateBeam` at line 31.
- `onRemoved` (lines 37-43): calls `BeaconBlock.updateBeam` at line 40.
- Identical to 1.12.2.

### `BeaconBlock.updateBeam` (`block/BeaconBlock.java:72-100`)

- `HttpUtil.DOWNLOAD_THREAD_FACTORY.submit(...)` at line 73 — spawns "Downloader %d" daemon thread.
- The submitted `Runnable` calls `world.getChunk(pos)` at line 76, then `world.getBlockState(blockPos)`
  at line 84 — off-thread chunk loading and block reads.
- The beacon block-entity update is now deferred to the server thread via `((ServerWorld)world).executeTask(...)`
  (lines 86-95), but the **read/generation side still runs on the downloader thread**.

### `HttpUtil.DOWNLOAD_THREAD_FACTORY` (`util/HttpUtil.java:36-44`)

- `newCachedThreadPool` of daemon threads named `"Downloader %d"`. Unchanged from 1.12.2.

### Impact

- Glass thread exploit (placing stained glass triggers off-thread world mutation): **fully intact**.
- Foundation for word tearing (§4) and async lines (§6): **still available**.

---

## §8 Falling block swaps — **FULLY INTACT**

### `FallingBlock.tryFall` (`block/FallingBlock.java:41-66`)

Same swap window: check at line 42, removal deferred to entity first tick (lines 44-49).

### `FallingBlockEntity.tick` (`entity/FallingBlockEntity.java:97-192`)

- **First tick** (lines 105-113): `getBlockState(blockPos).getBlock() == block` → deletes the
  block in the world. **Block-type match only, no state/metadata check.** Sand converter works.
- **Landing** (lines 142-185): `setBlockState(blockPos2, this.state,
  NOTIFY_NEIGHBORS | NOTIFY_LISTENERS)` at line 157. Places with flags.
- **NBT merge** (lines 162-177): `TileEntityData` copy from entity to landed block.
  **Un-gated** — no `requireOpForPlacingWithNbt()` check in this path.
- **Anvil damage** (lines 195-217): same `AnvilBlock.damage` → `brokeAnvil` → `pop` chain.

### Impact

- Sand converters (white↔red sand, gravel): **still possible**
- Anvil repairing: **still possible**
- End gateway / bedrock creation via falling-block swaps: **still possible**
- Un-gated NBT placement bypass via TileEntityData merge: **still possible**

---

## §9 Savestates — **FULLY INTACT**

### `RegionFile.writeChunkData` (`world/chunk/storage/RegionFile.java:132-140`)

```java
int l = (size + 5) / 4096 + 1;
if (l >= 256) {
   return;  // silently drops the chunk
}
```

Chunks whose compressed data exceeds ~1,044,475 bytes (~255 sectors / ~1MB) are silently not
written. No error, no exception, no logging. **Identical to 1.12.2.**

### `AnvilChunkStorage.saveChunk` (`world/chunk/storage/AnvilChunkStorage.java:177-200`)

No size check anywhere in the save path.

### `ServerChunkCache` save/unload (`server/world/chunk/ServerChunkCache.java`)

No size awareness in `save` (lines 223-247) or `tick` unload (lines 263-285).

### No `ChunkTooLargeException`

Does not exist in the codebase. The drop is 100% silent.

### Impact

- Savestate/rollback exploit: **still possible**. Make a chunk exceed ~1MB → unload → removed from
  memory but never written to disk → previous on-disk state persists on reload.

---

## §9.7 Race-forged item metadata — **PARTIALLY BROKEN**

### What still exists

| Piece | Status | Location |
|---|---|---|
| Dispenser equip = empty-slot filter + unconditional write | **INTACT** | `ArmorItem.java:43-60` |
| `CanPickUpItemsFilter` empty-slot gate | **INTACT** | `EntityFilter.java:88` |
| Shield → OFF_HAND mapping | **INTACT** | `MobEntity.java:833` |
| Two hand reads in placement path | **STRUCTURALLY PRESENT** | `ServerPlayNetworkHandler.java:639` + `ServerPlayerInteractionManager.java:303` |
| Shield max damage = 336 | **UNCHANGED** | `Item.java:1126` |

### What's gone

| Piece | Status | Detail |
|---|---|---|
| `SkullItem.useOn` metadata→skull type | **REMOVED** | No `useOn` override in `SkullItem.java`. Skull types are now distinct items (`SKELETON_SKULL`, `WITHER_SKELETON_SKULL`, `PLAYER_HEAD`, `ZOMBIE_HEAD`, `CREEPER_HEAD`, `DRAGON_HEAD` registered at `Item.java:1011-1018`). |
| `BlockItem.useOn` metadata→placed state | **REMOVED** | `BlockItem.useOn` (`BlockItem.java:33-36`) delegates to `place()` which uses block-property-driven placement, no `getBlockMetadata`/`getStateFromMetadata`. |
| `DyeItem.useOn` metadata re-read | **REMOVED** | `DyeItem.java` (42 lines) has no `useOn`. Color is bound to the item instance (`this.color`), not metadata. |
| Mining produces `skull:<damage>` item | **REMOVED** | `Block.getPickItem` (`Block.java:652-654`) returns `new ItemStack(this)` — no damage value minting. |

### Verdict

The dispensing race primitive (empty-slot filter → unconditional offhand write) and the double
hand read in the placement path still exist structurally. However, the **payoff is dead**:
- No metadata consumer in `SkullItem.useOn` to mint skull types from damage values.
- No `BlockItem.useOn` metadata path to forge block variants.
- No `DyeItem.useOn` to forge dye effects.
- Mining produces clean items, not `skull:<damage>` items.

A race that lands a shield into the placement hand would simply place the dispatch item's block
and consume the shield — an order-flip side effect, not an arbitrary-damage forge.

---

## §11 Quick file index (18w06a line numbers)

- `server/MinecraftServer.java` — `tickWorlds` (640-706), `pendingEvents` (162), `executeTask` (1249-1264).
- `server/world/ServerWorld.java` — `tick` (161-207), `addScheduledTick` (468-474),
  `doScheduledTicks` (540-595), class decl (92), `executeTask` (1082-1084), sets at 97-98.
- `server/world/ScheduledTick.java` — whole file (63 lines).
- `util/Utils.java` — `run` swallows ExecutionException/InterruptedException (65-77).
- `util/BitStorage.java` — `set` split write (28-41), `getRaw` (57-59).
- `server/network/ConnectionListener.java` — `tick` (150-188), local crash (178), remote kick (181-188).
- `network/Connection.java` — `channelRead0` (114-121), `tick` (216-225).
- `network/PacketUtils.java` — `ensureOnSameThread` (7-18).
- `server/network/handler/ServerPlayNetworkHandler.java` — handlers with `ensureOnSameThread`.
- `world/World.java` — `getBlockState` (643-651), `setBlockState` (263-310), `getChunkAt` (251-257).
- `world/chunk/WorldChunk.java` — `setBlockState` (374-444), `getBlockState` (334-372).
- `world/chunk/WorldChunkSection.java` — counters (28-45).
- `world/chunk/PalettedContainer.java` — setBits/palettes (36-52), read/write (96-154).
- `world/chunk/GlobalPalette.java` — STATE_REGISTRY mapping (13-22).
- `server/world/chunk/ServerChunkCache.java` — `chunks` map (44, synchronized), `getLoadedChunk`
  (77-87), `getGeneratedChunk` (107-113), `getChunk` (115-127), `finalizeChunk` (175-202),
  unload `tick` (262-285), `save` (223-247).
- `block/FallingBlock.java` — `fallImmediately` (17), `tryFall` (41-66).
- `entity/FallingBlockEntity.java` — `tick` (97-192), first-tick block delete (105-113),
  landing (142-185), NBT merge (162-177), anvil (195-217).
- `block/BeaconBlock.java` — `updateBeam` (72-100).
- `block/StainedGlassBlock.java` — onAdded/onRemoved (49-64); `StainedGlassPaneBlock.java` (28-43).
- `block/RedstoneWireBlock.java` — `shouldSignal` (61).
- `world/gen/chunk/OverworldChunkGenerator.java` — `decorate` fallImmediately toggle (85/99).
- `world/chunk/storage/RegionFile.java` — `writeChunkData` 1MB skip (132-140).
- `world/chunk/storage/AnvilChunkStorage.java` — `saveChunk` (177-200).
- `item/ArmorItem.java` — `dispense` two-phase equip (43-60).
- `entity/EntityFilter.java` — `CanPickUpItemsFilter` (88).
- `entity/living/mob/MobEntity.java` — `getEquipmentSlot` shield→OFF_HAND (825-838).
- `item/SkullItem.java` — no `useOn` override (52 lines total).
- `item/BlockItem.java` — `useOn` (33-36), `place` (38-75).
- `item/DyeItem.java` — no `useOn` (42 lines total).
- `item/ShieldItem.java` — max damage 336.
- `util/HttpUtil.java` — `DOWNLOAD_THREAD_FACTORY` (36-44).
- `block/RedstoneWireBlock.java` — `shouldSignal` (61).
