{"record":{"id":"5f2ab56492915249","repo":"thanos-io/thanos","slug":"proto-request-wiretype-end-group-for-non-group","errorCode":null,"errorMessage":"proto: Request: wiretype end group for non-group","messagePattern":"proto: Request: wiretype end group for non-group","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/storepb/prompb/io/prometheus/write/v2/custom.go","lineNumber":35,"sourceCode":"\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowTypes\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: Request: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: Request: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 4:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Symbols\", wireType)\n\t\t\t}\n\t\t\tvar stringLen uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowTypes\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/storepb/prompb/io/prometheus/write/v2/custom.go#L17-L53","documentation":"This is a hand-written proto Unmarshal validation for the Prometheus remote-write v2 Request. Wire type 4 is the 'end group' marker; since proto3 messages here are not groups, encountering it means the bytes are not a valid Request per the schema.","triggerScenarios":"Calling Unmarshal (via XXX_Unmarshal) on payload bytes where a field tag encodes an end-group marker — malformed, truncated-from-the-front, or non-remote-write-v2 data posted to the write v2 handler.","commonSituations":"A client posting remote-write v1 (or another protobuf) payload where a v2 Request is expected, corrupted request bodies in transit, or fuzzing/malicious traffic against the ingest endpoint.","solutions":["Ensure the sender uses remote-write v2 protobuf encoding (X-Prometheus-Remote-Write-Version: 2.0.0)","Verify the request body was not truncated or transformed by a proxy (Content-Length vs actual bytes)","Decode with the correct proto type matching the sender's schema","Log and reject the payload; do not attempt lenient parsing"],"exampleFix":"// before: blindly unmarshaling any body\nvar req prompb.WriteV2Request\nreq.Unmarshal(body)\n// after: check version header first\nif r.Header.Get(\"X-Prometheus-Remote-Write-Version\") != \"2.0.0\" { http.Error(w, \"unsupported rw version\", http.StatusUnsupportedMediaType); return }\nerr := req.Unmarshal(body)","handlingStrategy":"validation","validationCode":"if r.Header.Get(\"X-Prometheus-Remote-Write-Version\") != \"2.0.0\" { return status.Errorf(codes.InvalidArgument, \"unsupported RW version\") }","typeGuard":null,"tryCatchPattern":"if err := req.Unmarshal(body); err != nil { http.Error(w, \"malformed remote-write body\", http.StatusBadRequest); return }","preventionTips":["Senders must declare RW 2.0.0 header and encode v2 protobuf","Snappy-decompress bodies before Unmarshal","Reject non-v2 senders at the ingress"],"tags":["protobuf","unmarshal","wire-format","remote-write"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}