{"record":{"id":"3264cff2a7b01e88","repo":"Pumpkin-MC/Pumpkin","slug":"unknown-packet-type-0","errorCode":null,"errorMessage":"Unknown packet type: {0}","messagePattern":"Unknown packet type: (.+?)","errorType":"exception","errorClass":"PacketError","httpStatus":null,"severity":"warning","filePath":"crates/pumpkin-protocol/src/rcon.rs","lineNumber":60,"sourceCode":"        let bytes = body.as_bytes();\n        buf.put_slice(bytes);\n        buf.put_u8(0);\n        buf.put_u8(0);\n        buf\n    }\n}\n\n#[derive(Error, Debug)]\npub enum PacketError {\n    #[error(\"Invalid length\")]\n    InvalidLength,\n    #[error(\"Failed to send packet: {0}\")]\n    FailedSend(std::io::Error),\n    #[error(\"Missing packet null terminator\")]\n    MissingNullTerminator,\n    #[error(\"Invalid packet string body: {0}\")]\n    InvalidBody(std::str::Utf8Error),\n    #[error(\"Unknown packet type: {0}\")]\n    UnknownPacketType(i32),\n}\n\n#[derive(Debug, PartialEq, Eq)]\n/// Serverbound packet\npub struct Packet {\n    id: i32,\n    ptype: ServerboundPacket,\n    body: Box<str>,\n}\n\nimpl Packet {\n    pub fn deserialize(incoming: &mut Vec<u8>) -> Result<Option<Self>, PacketError> {\n        // We need at least 4 bytes to read the packet length header\n        if incoming.len() < 4 {\n            return Ok(None);\n        }\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/rcon.rs#L42-L78","documentation":"RconError::UnknownPacketType is thrown when an RCON packet's type field is an i32 that this implementation does not recognize. The Source RCON protocol defines only a few packet types (3=login, 2=command, 0=response/auth); any other value cannot be dispatched. This guards the server (or client) against protocol misuse and probing.","triggerScenarios":"Decoding an inbound RCON packet whose type field is outside the known set {0, 2, 3}; happens in Packet::decode when it calls the type-to-enum conversion with an unrecognized i32.","commonSituations":"A custom or buggy RCON client sending an invented packet type; a port scan or exploitation attempt sending random i32s; protocol version drift where a sender uses an extended type the receiver does not know.","solutions":["Identify the client producing the packet and fix its packet-type value to a defined one (SERVERDATA_AUTH=3, SERVERDATA_EXECCOMMAND=2, SERVERDATA_RESPONSE_VALUE=0).","Log the offending i32 and close or ignore the connection; treat it as protocol abuse.","Update the library if a new official packet type must be supported.","Reject the packet early after reading the type field instead of decoding the body."],"exampleFix":"// before: blindly sending a custom type\nlet packet = Packet { id, pkt_type: 99, body };\n\n// after: use a defined type\nuse PacketType::Command;\nlet packet = Packet { id, pkt_type: Command, body };","handlingStrategy":"validation","validationCode":"// validate the type field before dispatch\nconst VALID: [i32; 3] = [0, 2, 3];\nif !VALID.contains(&pkt_type) {\n    drop_connection(\"unknown RCON packet type\");\n}","typeGuard":"fn known_packet_type(t: i32) -> Option<PacketType> {\n    match t { 0 => Some(PacketType::Response), 2 => Some(PacketType::Command), 3 => Some(PacketType::Auth), _ => None }\n}","tryCatchPattern":"match decode_result {\n    Err(RconError::UnknownPacketType(t)) => {\n        warn!(\"rcon peer sent unknown type {t}; closing\");\n        connection.shutdown().await;\n    }\n    other => /* ... */,\n}","preventionTips":["Use the library's enum types instead of raw i32 when building packets.","Restrict RCON to trusted networks and require strong authentication.","Log unknown type values to spot misbehaving clients or scanners early."],"tags":["rust","rcon","protocol","unknown-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}