Bug #82926 X protocol: Please ensure that message Types are unique and do not overlap
Submitted: 9 Sep 2016 16:43 Modified: 22 Sep 2016 10:33
Reporter: Simon Mudd (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Document Store: X Plugin Severity:S4 (Feature request)
Version:5.7.15 OS:Any
Assigned to: CPU Architecture:Any
Tags: protobuf messages

[9 Sep 2016 16:43] Simon Mudd
Description:
The X protocol stream of data over the network comprises protobuf messages which are prefixed by a length and message type indicator.

See: https://github.com/mysql/mysql-server/blob/5.7/rapid/plugin/x/protocol/mysqlx.proto

However client and server messages currently use Type values which overlap.

For generic decoding of messages in an unencrypted tcp stream if you do not know which side is the client and which side is the server you can not safely determine the message content.
That is a single packet traced on the wire may not be able to be decoded correctly.

This is not ideal.

How to repeat:
Grab a single message (with length indicator + message type + bytes) captured randomly from a communication between a client and server and see if you can decode it in one pass safely every time.

You'll find you won't be able to do that without context.

Suggested fix:
It may be too late for existing messages but please try to ensure that new message types use a new id value which does not overlap with any other existing message irrespective of the direction of the message.

Perhaps future extensions to the protocol will allow us to switch to values where there is no overlap.
[9 Sep 2016 16:44] Simon Mudd
Adjust Synopsis.
[22 Sep 2016 10:33] MySQL Verification Team
Hello Simon,

Thank you for the feature request.

Thanks,
Umesh