{"record":{"id":"f5dcce02e430157a","repo":"cloudflare/cloudflared","slug":"errdatagramresponsemsgtoolargemaximum","errorCode":"ErrDatagramResponseMsgTooLargeMaximum","errorMessage":"datagram response error message length exceeds the length of the datagram maximum: %d","messagePattern":"datagram response error message length exceeds the length of the datagram maximum: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quic/v3/datagram_errors.go","lineNumber":16,"sourceCode":"package v3\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n)\n\nvar (\n\tErrInvalidDatagramType                 error = errors.New(\"invalid datagram type expected\")\n\tErrDatagramHeaderTooSmall              error = fmt.Errorf(\"datagram should have at least %d byte\", datagramTypeLen)\n\tErrDatagramPayloadTooLarge             error = errors.New(\"payload length is too large to be bundled in datagram\")\n\tErrDatagramPayloadHeaderTooSmall       error = errors.New(\"payload length is too small to fit the datagram header\")\n\tErrDatagramPayloadInvalidSize          error = errors.New(\"datagram provided is an invalid size\")\n\tErrDatagramResponseMsgInvalidSize      error = errors.New(\"datagram response message is an invalid size\")\n\tErrDatagramResponseInvalidSize         error = errors.New(\"datagram response is an invalid size\")\n\tErrDatagramResponseMsgTooLargeMaximum  error = fmt.Errorf(\"datagram response error message length exceeds the length of the datagram maximum: %d\", maxResponseErrorMessageLen)\n\tErrDatagramResponseMsgTooLargeDatagram error = fmt.Errorf(\"datagram response error message length exceeds the length of the provided datagram\")\n\tErrDatagramICMPPayloadTooLarge         error = fmt.Errorf(\"datagram icmp payload exceeds %d bytes\", maxICMPPayloadLen)\n\tErrDatagramICMPPayloadMissing          error = errors.New(\"datagram icmp payload is missing\")\n)\n\nfunc wrapMarshalErr(err error) error {\n\treturn fmt.Errorf(\"datagram marshal error: %w\", err)\n}\n\nfunc wrapUnmarshalErr(err error) error {\n\treturn fmt.Errorf(\"datagram unmarshal error: %w\", err)\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/quic/v3/datagram_errors.go#L1-L29","documentation":"ErrDatagramResponseMsgTooLargeMaximum is returned when unmarshaling a UDPSessionRegistrationResponseDatagram whose embedded error-message length field (a 16-bit value at bytes 18:20) exceeds maxResponseErrorMessageLen. The protocol caps how long an error message may be; a larger declared length means a malformed or non-conformant response datagram. UnmarshalBinary wraps this sentinel via wrapUnmarshalErr, so match with errors.Is.","triggerScenarios":"UnmarshalBinary on a UDPSessionRegistrationResponseDatagram where the uint16 error-message length read from data[18:20] is greater than maxResponseErrorMessageLen — i.e. a response datagram crafted or corrupted with an oversized message-length field.","commonSituations":"Corrupted datagram in transit; an incompatible peer/protocol version writing extra data into the message field; malicious or fuzzed traffic; a test constructing a payload with a too-large length field to verify error handling.","solutions":["Validate the length field before unmarshaling: read data[18:20] and reject values > maxResponseErrorMessageLen.","Use errors.Is(err, v3.ErrDatagramResponseMsgTooLargeMaximum) to identify malformed peer responses and drop them.","Verify both endpoints run matching cloudflared/quic v3 protocol versions.","Log the remote address; repeated occurrences may indicate tampered or buggy traffic."],"exampleFix":"// before\nerr := resp.UnmarshalBinary(payload)\nif err != nil { return err }\n// after\nerr := resp.UnmarshalBinary(payload)\nif errors.Is(err, v3.ErrDatagramResponseMsgTooLargeMaximum) {\n    logger.Warn().Msg(\"rejecting response datagram with oversized error message\")\n    return nil\n}","handlingStrategy":"try-catch","validationCode":"if len(data) >= 20 && binary.BigEndian.Uint16(data[18:20]) > v3.MaxResponseErrorMessageLen {\n    return fmt.Errorf(\"response error message length exceeds protocol maximum\")\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, v3.ErrDatagramResponseMsgTooLargeMaximum) {\n    logger.Warn().Msg(\"malformed response datagram: message length exceeds maximum; dropping\")\n    return nil\n}","preventionTips":["Keep both endpoints on protocol versions that agree on maxResponseErrorMessageLen.","Sanitize length fields from untrusted peers before trusting them.","Match this error with errors.Is to survive wrapUnmarshalErr wrapping."],"tags":["quic","datagram","protocol","size-limit"],"backgroundTag":"payload-too-large","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}