Pumpkin-MC/Pumpkin · error

Connection request length

Error message

Connection request length {connection_request_len} exceeds limit {MAX_PACKET_DATA_SIZE}

What it means

Thrown by SLogin::read when the VarUInt-prefixed connection request blob in a Bedrock login packet exceeds MAX_PACKET_DATA_SIZE. The check runs before allocation to prevent memory-exhaustion from hostile or malformed login packets. The packet is rejected with an InvalidData error.

Solutions

  1. Verify the client's protocol version matches the server
  2. Capture and decode the login packet to check the real connection_request size
  3. For a legitimate oversized login (rare), raise MAX_PACKET_DATA_SIZE in crates/pumpkin-protocol/src/bedrock/server/login.rs
Defensive patterns

Strategy: validation

Validate before calling

fn connection_request_len_ok(len: usize) -> bool { len <= MAX_PACKET_DATA_SIZE }

Type guard

fn checked_len(len: u32) -> Option<usize> { usize::try_from(len).ok().filter(|&l| l <= MAX_PACKET_DATA_SIZE) }

Try / catch

match SLogin::read(reader) {
    Err(e) if e.kind() == ErrorKind::InvalidData => { disconnect(peer, "malformed login"); Ok(()) }
    Err(e) => Err(e),
    Ok(login) => authenticate(login),
}

Prevention

When it happens

Trigger: A client sends a Login packet whose connection_request length field exceeds MAX_PACKET_DATA_SIZE; typically crafted packets, fuzzing, or a stream desync where a later field is misread as the length prefix.

Common situations: Modified Bedrock clients, DoS probes against the login handler, or version mismatch causing field-boundary misalignment.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/21fbacab91840ee0. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin-protocol/src/bedrock/server/login.rs:23

use crate::{MAX_PACKET_DATA_SIZE, codec::var_uint::VarUInt, serial::PacketRead};

#[packet(1)]
pub struct SLogin {
    // https://mojang.github.io/bedrock-protocol-docs/html/LoginPacket.html
    //#[serial(big_endian)]
    pub protocol_version: i32,

    // https://mojang.github.io/bedrock-protocol-docs/html/connectionRequest.html
    pub jwt: Vec<u8>,
    pub raw_token: Vec<u8>,
}

impl PacketRead for SLogin {
    fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {
        let protocol_version = i32::read_be(reader)?;
        let connection_request_len = VarUInt::read(reader)?.0 as usize;
        if connection_request_len > MAX_PACKET_DATA_SIZE {
            return Err(Error::new(
                ErrorKind::InvalidData,
                format!(
                    "Connection request length {connection_request_len} exceeds limit {MAX_PACKET_DATA_SIZE}"
                ),
            ));
        }

        let jwt_len = u32::read(reader)? as usize;
        if jwt_len > MAX_PACKET_DATA_SIZE {
            return Err(Error::new(
                ErrorKind::InvalidData,
                format!("JWT length {jwt_len} exceeds limit {MAX_PACKET_DATA_SIZE}"),
            ));
        }
        let mut jwt = vec![0; jwt_len];
        reader.read_exact(&mut jwt)?;

        let raw_token_len = u32::read(reader)? as usize;

View on GitHub (pinned to 8d4639e25a)