{"record":{"id":"e9855789c7527468","repo":"slackhq/nebula","slug":"errheadertooshort","errorCode":"ErrHeaderTooShort","errorMessage":"header is too short","messagePattern":"header is too short","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"header/header.go","lineNumber":67,"sourceCode":"\tControl:     \"control\",\n}\n\nconst (\n\tMessageNone  MessageSubType = 0\n\tMessageRelay MessageSubType = 1\n)\n\nconst (\n\tTestRequest MessageSubType = 0\n\tTestReply   MessageSubType = 1\n)\n\nconst (\n\tHandshakeIXPSK0 MessageSubType = 0\n\tHandshakeXXPSK0 MessageSubType = 1\n)\n\nvar ErrHeaderTooShort = errors.New(\"header is too short\")\n\nvar subTypeTestMap = map[MessageSubType]string{\n\tTestRequest: \"testRequest\",\n\tTestReply:   \"testReply\",\n}\n\nvar subTypeNoneMap = map[MessageSubType]string{0: \"none\"}\n\nvar subTypeMap = map[MessageType]*map[MessageSubType]string{\n\tMessage: {\n\t\tMessageNone:  \"none\",\n\t\tMessageRelay: \"relay\",\n\t},\n\tRecvError:   &subTypeNoneMap,\n\tLightHouse:  &subTypeNoneMap,\n\tTest:        &subTypeTestMap,\n\tCloseTunnel: &subTypeNoneMap,\n\tHandshake: {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/header/header.go#L49-L85","documentation":"ErrHeaderTooShort is returned by H.Parse (and Parse) when the input byte slice is shorter than the fixed header Len. Nebula packet headers are fixed-size, so any shorter buffer cannot possibly contain a valid header.","triggerScenarios":"Calling h.Parse(b) at header/header.go:145 with len(b) < Len — e.g. a truncated UDP datagram, garbage datagram, or a slice handed to the wrong parse layer.","commonSituations":"Random internet noise arriving on the open UDP port; truncated packets from an undersized read buffer or MTU issue; feeding payload bytes (instead of the full packet) into Parse.","solutions":["Verify the read buffer is at least header.Len bytes and you pass the entire datagram to Parse","Treat the packet as garbage and drop it — the manager ignores undecodable datagrams","If truncation is systematic, check for MTU/fragmentation problems on the network path"],"exampleFix":"// before\nb := buf[:20] // truncated copy\nerr := h.Parse(b)\n// after\nif len(buf) < header.Len {\n    return // drop undecodable packet\n}\nerr := h.Parse(buf)","handlingStrategy":"validation","validationCode":"func canParseHeader(b []byte) bool {\n    return len(b) >= header.Len\n}","typeGuard":null,"tryCatchPattern":"var h header.H\nif err := h.Parse(b); err != nil {\n    if errors.Is(err, header.ErrHeaderTooShort) {\n        // drop garbage/truncated datagram\n        return\n    }\n    return err\n}","preventionTips":["Read at least header.Len bytes before parsing","Parse the full datagram, never a sub-slice of the payload","Drop undecodable datagrams silently; they're usually network noise"],"tags":["packet-parsing","header","udp"],"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"}