LC-153-WIKI-DESC-CAP: cap room description + wiki markdown body length (share the LC-153 cap) #283
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Room description and wiki bodies are rendered through the markdown + LaTeX pipeline with no length cap, unlike every other markdown surface. Chat messages are capped at
MAX_MESSAGE_CHARS = 16_000(server/src/routes/room.rs:24, enforced at:440/:1486/:1848viacheck_message_length, the LC-153 cap); email-ingress bodies are capped at 64 KiB. The two room-doc handlers have no equivalent check, so the only bound is Axum's framework-defaultDefaultBodyLimit(~2 MiB) with no per-route override.Where
server/src/routes/room_info.rs::patch_description(:400): takesform.body, stores it, renders viarender_markdown_body. Nocheck_message_length, no per-route body limit.server/src/routes/room_info.rs::patch_wiki(:459): same shape.require_can_edit_description/require_can_edit_wiki), so the actor is a room moderator, not an anonymous user.spawn_blocking-wrapped (permain.rscommentary); confirm whether these tworoom_inforender sites are also off the async worker thread, or wrap them.Failure mode / cost
A 2 MiB body fed to the markdown + pulldown-latex pipeline is a ~128x larger render unit than the 16K-char chat cap. A privileged-but-not-trusted room moderator can spike CPU or stall a worker thread on render. Independently, the inconsistent input contract invites the next markdown-surface author to copy the unbounded handler.
Proposed scope
patch_descriptionandpatch_wiki(aMAX_DOC_CHARSconstant, or reuse/relaxcheck_message_lengthif 16K is acceptable for docs; pick a doc-appropriate bound).spawn_blocking/block_in_place); wrap if not.Acceptance
patch_descriptionandpatch_wikireject over-length bodies and render on a blocking thread; a regression test covers it; CLAUDE.md records the markdown-surface cap convention.Anchored to LC-153 (message length cap). Severity: correctness, low-privilege DoS, high confidence (the missing cap is confirmed by reading the handlers).