Pumpkin-MC/Pumpkin · error

extra_data length exceeds limit

Error message

extra_data length exceeds limit

What it means

Thrown while decoding an item descriptor's extra_data when its declared VarUInt length exceeds 1 MiB (1_048_576 bytes). The guard prevents the decoder from allocating an attacker-controlled buffer before read_exact. The packet is rejected with an InvalidData error.

Solutions

  1. Verify client/server protocol versions match
  2. If the new protocol legitimately allows larger extra_data, raise the 1_048_576 limit in the decoder
  3. Re-check the field order in the serializer for your client version to rule out offset drift
Defensive patterns

Strategy: validation

Validate before calling

fn extra_data_len_ok(len: usize) -> bool { len <= 1_048_576 }

Type guard

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

Try / catch

if let Err(e) = decode_item_stack_request(buf) {
    if e.kind() == std::io::ErrorKind::InvalidData { drop_packet(peer); return Ok(()); }
    return Err(e.into());
}

Prevention

When it happens

Trigger: A client sends an ItemStackRequest where the extra_data length field for an item descriptor is > 1048576; seen with malformed packets, fuzzing, or a version mismatch that shifts field boundaries so a later field is misread as the length.

Common situations: Protocol version drift after a Bedrock update, hostile clients probing for allocation DoS, or corrupted network streams.

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/be82678be8614959. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin-protocol/src/bedrock/server/item_stack_request.rs:57

impl PacketRead for StackRequestItem {
    fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {
        let descriptor_type = VarUInt::read(reader)?.0;
        let _legacy_type = u8::read(reader)?;
        let (identifier, metadata_value) = match descriptor_type {
            0 => (None, VarInt(0)),
            1 => (Some(String::read(reader)?), VarInt::read(reader)?),
            _ => {
                return Err(Error::new(
                    ErrorKind::InvalidData,
                    format!("unknown stack request item descriptor type {descriptor_type}"),
                ));
            }
        };
        let count = i16::read(reader)? as u16;
        let block_runtime_id = VarUInt::read(reader)?;
        let data_len = VarUInt::read(reader)?.0 as usize;
        if data_len > 1_048_576 {
            return Err(Error::new(
                ErrorKind::InvalidData,
                "extra_data length exceeds limit",
            ));
        }
        let mut extra_data = vec![0; data_len];
        reader.read_exact(&mut extra_data)?;
        Ok(Self {
            identifier,
            metadata_value,
            count,
            block_runtime_id,
            extra_data,
        })
    }
}

#[derive(Debug)]
pub enum ItemStackRequestAction {

View on GitHub (pinned to 8d4639e25a)