Skip to content

JSON-RPC: sendChatText / broadcastChatMessage / setServerName accept unbounded strings #3950

Open

Description

@ann0see

Describe the bug

jamulusclient/sendChatText, jamulusserver/broadcastChatMessage and jamulusserver/setServerName validate only that their string parameter is a string — no length bound — unlike the sibling chat methods, which reject input above MAX_LEN_CHAT_TEXT (1600):

  • jamulusserver/privateChatMessage — rejects > MAX_LEN_CHAT_TEXT (src/serverrpc.cpp:125).
  • jamulusserver/setWelcomeMessage — rejects > MAX_LEN_CHAT_TEXT (src/serverrpc.cpp:325).

Normal clients cannot produce such input: the GUI chat dialog truncates input at MAX_LEN_CHAT_TEXT (src/chatdlg.cpp:111). So these three methods deviate from both the peer RPC methods and the GUI path.

Reachable impact on current main

Since #3861 the JSON-RPC transport caps each request line at 16 KiB (MAX_JSON_RPC_REQUEST_BYTES, src/rpcserver.cpp:116), so the message is transport-bounded. It still exceeds the receive-side limits: EvaluateChatTextMes reads at most MAX_LEN_CHAT_TEXT_PLUS_HTML (1800) chars (src/protocol.cpp:1424) and split reassembly caps at 36 parts, while the sender fragments via CreateAndSendMessage with ceil(len / 550) parts and no part-count cap (src/protocol.cpp:590). Result: a ~16 KiB broadcastChatMessage produces a ~27-datagram split burst per connected client that is then silently discarded by every peer. Not memory-unsafe; low severity, but the handlers do not enforce the parameter contract their siblings and the GUI do. An oversized setServerName similarly carries into server-list registration messages to directories and clients.

To Reproduce

  1. Run a server: jamulus -s --nogui --jsonrpcport 22150 --jsonrpcsecretfile <secret> (secret >= 16 chars), connect one client.
  2. Call jamulusserver/broadcastChatMessage with chatMessage of 10,000 chars. Handler returns ok; peers receive the fragmented message and drop it (receiver bound 1800).
  3. Call it with 20,000 chars: transport rejects with Parse error: Request exceeds maximum size of 16384 bytes.

Measured against 3.12.5dev (292506eb): 15,000-char broadcast accepted with a +416 KB server RSS delta and ~27 split parts per client; 20,000-char rejected by the 16 KiB boundary.

Expected behavior

sendChatText, broadcastChatMessage (and setServerName) reject input above MAX_LEN_CHAT_TEXT with iErrInvalidParams, mirroring privateChatMessage / setWelcomeMessage.

Version of Jamulus

3.12.5dev (292506eb), JSON-RPC enabled.

Additional context

Formalizes the "String parameters are bounded inconsistently" item of #3916. #3861 bounds the transport; this issue is the remaining handler-level gap.

🤖 Used AI: big-pickle, opencode

Activity

  1. ann0see commented on Sep 13, 2026

    @ann0see
    MemberAuthor

    ... which means we need to introduce the InRange check there too.

  2. added this to the Release 4.0.0 milestone on Sep 13, 2026
  3. added theissue type on Sep 13, 2026
  4. added
    AIAI generated or potentially AI generated
    on Sep 13, 2026
  5. moved this from Triage to Backlog in Trackingon Sep 13, 2026
  6. mcfnord commented on Sep 14, 2026

    @mcfnord
    Contributor

    🤖 AI: The bound for setServerName is MAX_LEN_SERVER_NAME (20), not MAX_LEN_CHAT_TEXT (1600), and the damage starts at 21 characters rather than at 16 KiB.

    Measured on 267bf6b7 — one directory, two registered servers, one real client reading its own serverListReceived:

    directory's own name handler reply servers the client receives
    20 chars "ok" 3
    21 chars "ok" 0
    1600 chars "ok" 0

    A directory copies its own entry into slot 0 of every list it sends, and an over-length string is a parse error discarding the whole datagram, so one long directory name takes every other server's entry with it. The reduced list holds the name length in one byte: 300 chars ship a length field of 44, 1600 ship 64. On a registering server instead, a rename to 15 chars reaches the directory in 8 s while a rename to 21 returns "ok" and leaves the old name standing until the 33-minute timeout.

    Every other path already clamps to 20 — --serverinfo, the GUI field, the server-list file — so the check belongs inside SetServerName and covers every caller at once. One decision the InRange work needs regardless: the GUI truncates a server name, the sibling RPC methods reject — which of the two for the RPC?

    big-pickle's measurements were real, but oddly fickle:
    it weighed the RSS at 15,000 and skipped the field — a pickle.
    The fence it chose runs 1600; the field gives out at 20,
    and past the gap it graded "low" the server list goes empty.
    Its repro burns 10,000 chars to reach a break at 21 —
    measure the field before the fence, and then the fence is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AIAI generated or potentially AI generated

Type

Projects

  • Status
    Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions