Bug #92789 | MySQL Net connector 8.0.12 sends illegal connect attributes. | ||
---|---|---|---|
Submitted: | 16 Oct 2018 4:54 | Modified: | 23 Nov 2021 18:57 |
Reporter: | Xiangyu Hu | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 8.0.12 | OS: | Windows (Windows 7/10) |
Assigned to: | CPU Architecture: | x86 | |
Tags: | Connector; |
[16 Oct 2018 4:54]
Xiangyu Hu
[16 Oct 2018 6:59]
Bradley Grainger
The bug is here: https://github.com/mysql/mysql-connector-net/blob/68c54371821c87ff40a773acc127ce357b46a5ae... Connector/NET computes the length of the C# string (which is in chars, i.e., UTF-16 code units) and then converts the string to UTF-8 for serialization across the wire. The OP's OS name is “Microsoft Windows 7 旗舰版 ”, which is 24 characters (0x18). But this becomes 30 bytes (0x1E) when encoded in UTF-8, so Connector/NET should have written 0x1C for the size of the length-encoded string, not 0x18. Since this version of the connector is out in the wild, Microsoft will need to update their Azure proxy to detect “_client_version” = 8.0.12.0, assume the prefix byte is wrong, and perform UTF-8 decoding on client-supplied connection attributes as they're being deserialized. Or just read the prefix byte at the beginning of this block (i.e., 0x97 in this case) and skip the whole thing.
[16 Oct 2018 18:32]
Bradley Grainger
Typo in previous comment. "But this becomes 30 bytes (0x1E) when encoded in UTF-8, so Connector/NET should have written 0x1C for the size of the length-encoded string, not 0x18." should read "should have written 0x1E"
[18 Oct 2018 4:06]
Xiangyu Hu
Thank you Bradley for your detailed root cause. Since Connector/Net (always) uses UTF-8 across the wire, can a fix be made to make sure the encoded length be set to its UTF-8 size of each attribute? MySQL's definition on Protocol::LengthEncodedString did not rule's its encoding format but the length should be consistant with its real length of bytes.
[22 Oct 2018 12:18]
MySQL Verification Team
Thank you Xiangyu, for the report and Bradley Grainger for the details. regards, Umesh
[23 Nov 2021 18:57]
Christine Cole
Posted by developer: Fixed as of the upcoming MySQL Connector/NET 8.0.28 release, and here's the proposed changelog entry from the documentation team: The calculation used to determine the length of connection attribute values could produce the wrong format in MySQL login packets. Thank you for the bug report.