{"record":{"id":"bed691bfe7bf5714","repo":"elsa-workflows/elsa-core","slug":"invalid-protobuf-varint","errorCode":null,"errorMessage":"Invalid protobuf varint.","messagePattern":"Invalid protobuf varint\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion/HttpProtobuf/OtlpHttpProtobufParser.cs","lineNumber":692,"sourceCode":"            ulong value = 0;\n            var shift = 0;\n\n            for (var i = 0; i < 10; i++)\n            {\n                if (_remaining.IsEmpty)\n                    throw new InvalidDataException(\"Unexpected end of protobuf payload.\");\n\n                var b = _remaining[0];\n                _remaining = _remaining[1..];\n                value |= (ulong)(b & 0x7f) << shift;\n\n                if ((b & 0x80) == 0)\n                    return value;\n\n                shift += 7;\n            }\n\n            throw new InvalidDataException(\"Invalid protobuf varint.\");\n        }\n\n        private readonly void EnsureAvailable(int byteCount)\n        {\n            if (_remaining.Length < byteCount)\n                throw new InvalidDataException(\"Unexpected end of protobuf payload.\");\n        }\n    }\n}\n","sourceCodeStart":674,"sourceCodeEnd":702,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion/HttpProtobuf/OtlpHttpProtobufParser.cs#L674-L702","documentation":"After 10 varint bytes without a terminating byte (high bit 0), the value would exceed the 64-bit protobuf varint maximum, which is invalid per the protobuf spec. The parser throws InvalidDataException \"Invalid protobuf varint.\" to signal a malformed or maliciously crafted payload.","triggerScenarios":"Decoding an OTLP buffer where a varint field has 10+ continuation bytes (each with the high bit set) — e.g. corrupted bytes, random data posted to the endpoint, or a buggy custom encoder emitting oversized varints.","commonSituations":"Sending binary garbage or base64 text to the OTLP protobuf endpoint; intermediary mangling bytes; a hand-rolled encoder bug producing 11-byte varints.","solutions":["Confirm the sender produces standard protobuf encodings (varints max 10 bytes) — validate with a reference decoder.","Check for byte corruption in transit (TLS termination, proxies) and test the exporter directly against the endpoint.","If the body is intentionally not protobuf, send it to the correct endpoint or format."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate before export with a reference protobuf decoder:\n// otel-cli export --protocol http/protobuf --endpoint ... or Protobuf.CodedInputStream round-trip","typeGuard":null,"tryCatchPattern":"try { ParseProtobuf(body); }\ncatch (InvalidDataException ex) when (ex.Message == \"Invalid protobuf varint.\")\n{ logger.LogWarning(ex, \"Body is not valid protobuf; check sender format.\"); }","preventionTips":["Round-trip payloads through a standard protobuf library before shipping to catch encoder bugs.","Never post base64 or text representations to the binary protobuf endpoint."],"tags":["protobuf","opentelemetry","malformed-input","parsing"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}