Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-231035

2-byte-characters in MOTD can break query responses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.17, 1.17.1 Release Candidate 1, 1.17.1
    • None
    • OS: Manjaro Linux
      Java: OpenJDK Runtime Environment (build 15.0.2+7)
    • Plausible
    • Networking
    • Low
    • Platform

      This bug is probably related to MC-221987.

      Although the server.properties file only supports ASCII characters, it is possible to add larger characters to a server's MOTD by using the sequence \uXXXX (where XXXX are two hexadecimal bytes). This allows using characters with a length of up to two bytes.

      Expected behavior

      I could not find any official information on what encoding strings in query responses should use. Dinnerbone's mcstatus python program refers to the encoding as ASCII (https://github.com/Dinnerbone/mcstatus/blob/master/mcstatus/querier.py#L136 ) but actually uses ISO-8859-1 (https://github.com/Dinnerbone/mcstatus/blob/master/mcstatus/protocol/connection.py#L77).

      The expected behavior depends on what the actual character encoding is supposed to be, but generally, characters in query responses should be converted to the correct encoding or filtered if they can't be represented in the correct encoding.

      Bug

      Only the last byte of 2-byte-characters is sent in query responses (e.g. \uABCD => CD). This generally results in characters longer than 8 bits being unreadable/corrupted in query responses. Additionally, this results in 2-byte-characters that end on 00 (like ᴀ = \u1D00) being sent as 00, which, due to query responses using null-terminated string, results in the whole query response being unreadable.

      Reproduce

      1. Create a server
      2. Change the MOTD to
        This character will break the query protocol\:\u1D00
      3. Try using the mcstatus CLI
        mcstatus 0.0.0.0:25565 query
      4. Since the query response is unreadable, a python error is displayed

       

      A hex dump of the query response data shows the additional null-byte:

       

      00000000  00 00 00 00 01 54 68 69  73 20 63 68 61 72 61 63  |.....This charac|
      00000010  74 65 72 20 77 69 6c 6c  20 62 72 65 61 6b 20 74  |ter will break t|
      00000020  68 65 20 71 75 65 72 79  20 70 72 6f 74 6f 63 6f  |he query protoco|
      00000030  6c 3a 00 00 53 4d 50 00  77 6f 72 6c 64 00 30 00  |l:..SMP.world.0.|
      00000040  32 30 00 dd 63 31 32 37  2e 30 2e 31 2e 31 00     |20..c127.0.1.1.|
      0000004f

       

            Unassigned Unassigned
            KurtThiemann Kurt Thiemann
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: