{"record":{"id":"8ce3ccee3a23bc40","repo":"slackhq/nebula","slug":"errpackettooshort","errorCode":"ErrPacketTooShort","errorMessage":"packet too short","messagePattern":"packet too short","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"handshake/errors.go","lineNumber":9,"sourceCode":"package handshake\n\nimport \"errors\"\n\nvar (\n\tErrInitiateOnResponder     = errors.New(\"initiate called on responder\")\n\tErrInitiateAlreadyCalled   = errors.New(\"initiate already called\")\n\tErrInitiateNotCalled       = errors.New(\"initiate must be called before ProcessPacket for initiators\")\n\tErrPacketTooShort          = errors.New(\"packet too short\")\n\tErrPublicKeyMismatch       = errors.New(\"public key mismatch between certificate and handshake\")\n\tErrIncompleteHandshake     = errors.New(\"handshake completed without receiving required content\")\n\tErrMachineFailed           = errors.New(\"handshake machine has failed\")\n\tErrUnknownSubtype          = errors.New(\"unknown handshake subtype\")\n\tErrMissingContent          = errors.New(\"expected handshake content but message was empty\")\n\tErrUnexpectedContent       = errors.New(\"received unexpected handshake content\")\n\tErrInvalidRemoteIndex      = errors.New(\"peer sent an invalid index in handshake payload\")\n\tErrIndexAllocation         = errors.New(\"failed to allocate local index\")\n\tErrNoCredential            = errors.New(\"no handshake credential available for cert version\")\n\tErrAsymmetricCipherKeys    = errors.New(\"noise produced only one cipher key\")\n\tErrMultiMessageUnsupported = errors.New(\"multi-message handshake patterns are not yet supported by the manager\")\n\tErrSubtypeMismatch         = errors.New(\"packet subtype does not match handshake machine subtype\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/handshake/errors.go#L1-L23","documentation":"ErrPacketTooShort is returned by Machine.ProcessPacket (and packet decoding helpers like newPacket) when the received byte slice is shorter than the length declared in the packet header. The input cannot be a valid handshake packet and is discarded. Importantly, this does NOT mark the machine as failed — it is treated as a corrupt/short datagram.","triggerScenarios":"Passing a buffer of fewer bytes than header.Len to ProcessPacket, e.g. a truncated UDP datagram, a test payload like []byte{1,2,3}, or an incorrectly sized read buffer.","commonSituations":"UDP packet truncation on lossy networks or MTU issues; reading a partial datagram; feeding plain (non-handshake) traffic into the handshake processor; test cases verifying malformed-packet handling.","solutions":["Check len(packet) >= header length before calling ProcessPacket and discard/log short packets.","Fix the socket read path so full datagrams are delivered (adequate buffer size, correct recvfrom usage).","Investigate network MTU/truncation if short packets appear in production traffic."],"exampleFix":"// before\nmsg, _, err := m.ProcessPacket(nil, buf[:n]) // n may be < header size\n// after\nif n < handshake.MinPacketLen {\n    return // skip short/garbage datagram\n}\nmsg, _, err := m.ProcessPacket(nil, buf[:n])","handlingStrategy":"validation","validationCode":"if len(packet) < handshake.MinPacketLen /* header size */ {\n    // discard: not a valid handshake packet\n    return nil\n}","typeGuard":"func isPlausiblePacket(b []byte) bool {\n    return len(b) > 0 && len(b) >= handshake.MinPacketLen\n}","tryCatchPattern":"msg, packet, err := m.ProcessPacket(h, buf[:n])\nif errors.Is(err, handshake.ErrPacketTooShort) {\n    // safe to ignore; machine is still usable\n    return nil\n}","preventionTips":["Size read buffers >= max handshake packet size","Validate datagram length against the header before dispatch","Skip silently (no fatal) on short packets — the machine stays healthy","Monitor truncation rates to detect MTU or socket-config problems"],"tags":["network","handshake","malformed-packet"],"backgroundTag":"malformed-packet","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}