PaperMC / PaperMC/Waterfall

supportsForge disables packet ID range check — out-of-range IDs cause AIOOBE; EntityMap off-by-one

Open
#872 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
752
Forks
307
Avg merge
15h 48m
Merged PRs (30d)
7

Description

The patch that adds Forge support (0016-Allow-invalid-packet-ids-for-forge-servers.patch) introduces two issues when supportsForge is active:

1. Packet ID range bypass

DirectionData.hasPacket returns:

return supportsForge || i >= 0 && i <= MAX_PACKET_ID;

When supportsForge is true, the range check is completely short-circuited. createPacket then indexes protocolData.packetConstructors[id] (array size MAX_PACKET_ID+1 = 256) with an unchecked packet ID from the wire. A negative varint or value > 255 → ArrayIndexOutOfBoundsException.

supportsForge is set when a forge user connects to a forge server via ServerConnector.handleLogin.

2. EntityMap off-by-one

The same patch adds a guard in EntityMap.rewrite:

if (packetId < 0 || packetId > ints.length || packetId > varints.length) return;

Uses > instead of >=, so packetId == ints.length passes the check but then accesses ints[ints.length] → AIOOBE.

Impact

Both are caught by Netty error handling → the affected connection is closed. Memory-safe; no data leak or cross-player impact. A forge client or forge backend can trigger self-disconnection with an out-of-range packet ID.

Suggested fix
  1. When supportsForge and the ID is outside [0, MAX_PACKET_ID], skip/forward the raw packet instead of indexing into the constructor array.
  2. Change the EntityMap guard to >=:
if (packetId < 0 || packetId >= ints.length || packetId >= varints.length) return;

Checked at Waterfall master@150a002.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace DirectionData.hasPacket and createPacket, then follow supportsForge from ServerConnector.handleLogin. Inspect EntityMap.rewrite and the referenced Forge-support patch; verify that out-of-range packet IDs no longer cause array access failures and that the EntityMap boundary case is handled without AIOOBE.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.