gchq/CyberChef · error · OperationError

${err}

Error message

${err}

What it means

Protobuf Decode delegates to Protobuf.decode and wraps any thrown error in an OperationError, surfacing the underlying message as ${err}. Decode failures arise from malformed/truncated protobuf wire data, an invalid or unparseable .proto schema, schema/data mismatches, or invalid varint/wire-type sequences. The wrapper converts internal library errors into CyberChef's expected OperationError output channel.

Source

Thrown at src/core/operations/ProtobufDecode.mjs:59

            {
                name: "Show Types",
                type: "boolean",
                value: false
            }
        ];
    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {JSON}
     */
    run(input, args) {
        input = new Uint8Array(input);
        try {
            return Protobuf.decode(input, args);
        } catch (err) {
            throw new OperationError(err);
        }
    }

}

export default ProtobufDecode;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Confirm the input is real protobuf wire data (field tag + wire-type varints).
  2. If using a schema, validate the .proto syntax with protoc first.
  3. Strip any gRPC/framing prefix (length + compressed flag) before decoding.
  4. Read the wrapped ${err} text — it usually names the exact decode problem (truncated varint, bad wire type, unknown enum, etc.).

Example fix

// before: gRPC-framed bytes
run(grpcFrameBuf, ["", false, false]);

// after: protobuf payload only (prefix stripped)
run(pbPayloadBuf, [schema, false, false]);
Defensive patterns

Strategy: try-catch

Validate before calling

// Best-effort shape check before decoding: protobuf wire bytes are a sequence of
// (field_number << 3 | wire_type) varints with wire_type in 0..5.
function looksLikeProtobuf(buf) {
  const u = new Uint8Array(buf);
  return u.length > 0 && (u[0] & 0x07) <= 5;
}

Type guard

function isLikelyProtobuf(buf) {
  const u = new Uint8Array(buf);
  return u.length > 0 && (u[0] & 0x07) <= 5;
}

Try / catch

try {
  return protobufDecode.run(input, [schema, showUnknown, showTypes]);
} catch (e) {
  // e.message is the wrapped Protobuf.decode error; surface it to the user
  throw e;
}

Prevention

When it happens

Trigger: Decoding non-protobuf bytes; a truncated message missing field data; a .proto schema with syntax errors; a wire type the decoder cannot handle (e.g. malformed length-delimited or group fields); oversized/recursive input that hits the decoder's internal limits.

Common situations: Pointing the op at random binary; feeding a gRPC frame including the 5-byte prefix; schema that does not match the producing schema; partial reads from a stream.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/4c3c0218455fc642. Report an issue: GitHub.