Forumer 0.2.3 — follow-up security audit

A second, adversarial pass on top of the main 0.2.3 review — not re-verifying the 18 numbered findings again, but hunting for issues neither that review nor the original two asked about: the new wire-message types the 0.2.3 features add, the new image-decode path, and a handful of standard audit checks (injection, SQL, bounds-on-receive) applied fresh to the new code · repo bristinWild/forumer tag v0.2.3 (5bb22a9e), same commit as the companion review

One real, concrete gap found: the two new "find who has this image" messages (mask / MediaAsk) have no flood protection, while everything else in the protocol does. Every other message type that costs a receiver real work — posts, replies, digest re-sends — has a rate limit the project built and tested for specifically (the two prior findings, F6 and F7, were exactly this class of bug for posts). The two new message types 0.2.3 introduces for image discovery got the sealing right but didn't get a limit at all. This review reproduces the reachable half of that directly: a receiver's own decoder accepts an unlimited stream of distinct, fabricated requests with no rejection, at a cost to the sender of about one microsecond each.

Everything else checked here came back clean: the new encryption code (three independently-derived subkeys across the forum, storage, and preview paths) is correct wherever it was re-read line by line; the one other new system call this review could reach — the OS file picker — uses the safe, non-shell form of process invocation; the new per-forum SQL is fully parameterised; and the per-post image-count limit is enforced on received posts, not just ones the app itself authors, so it can't be bypassed by a peer sending a hand-crafted envelope.

1new finding (medium)
20,000 / 20,000fabricated requests accepted by the real decoder, reproduced
5other adversarial checks run clean

Jump to: The finding · What else was checked · How this was done · What this could not check

The finding

medium

MediaAsk ("mask") messages have no rate limit, unlike every other message type that costs a receiver work

0.2.3 adds image sharing, and with it two new wire-message types for finding who holds a given picture: mask ("does anyone have this CID?") and mhere ("I do, here's my address"). mask is the one that matters here — receiving one makes the client do real work: check a local cooldown, then, if that passes, ask the storage module whether it holds the content.

The project's own design document for flood control — the top-of-file comment in flood.h, quoted here in full because it's the clearest evidence of what was and wasn't in scope — describes five layers of protection, every one of them about posts, replies, or re-sends:

1. Proof-of-work on every post: 16 bits signed, 20 bits anonymous.
2. Per persona: at most kMaxTopics topics and kMaxReplies replies per hour of
   AUTHOR time (2a: + an arrival-time cap, 2b: + a daily cap for bulk history).
3. Brand-new keys: draw from a shared budget (kNewKeyPerMinute/kNewKeyBurst),
   with a priority lane for posts carrying extra proof-of-work.
4. Per account, on the sender: the same hourly limits across all personas.
5. Re-sending to repair gaps is capped (kResendPerMinute), so a stream of
   digests can't turn a peer into an amplifier.

Nothing here mentions media discovery. Reading the handler that processes an incoming mask (handleMediaAsk, src/forumer_backend.cpp:2314) confirms it: the only throttle is a 30-second cooldown keyed by the content id itself, which does nothing against an attacker who simply varies the id on every message. Past that cooldown, a request for any content id the receiver holds — or, with re-hosting on (the documented default: "By default a picture you opened stays in your storage node and is offered to others"), any syntactically valid id at all — triggers a real call into the storage module to check whether it's held.

Two things make this concretely reachable rather than theoretical:

The content-id format check (cidShape: 20–128 alphanumeric characters) that every mask message has to pass is a shape check, not a provenance one — trivial for an attacker to satisfy for an unbounded number of distinct, entirely fabricated ids. Reproduced directly: a standalone probe built against the real sync::decode() (the same decoder every incoming message on every joined topic — public or private forum — passes through before any type-specific handling) generated 20,000 distinct fabricated mask messages and found every single one accepted as well-formed, at a generation cost of about 0.001 ms each. The part this review could not reach directly is the real cost of the resulting storage_module.exists() call on the receiving side, since the handler that makes it lives in the Qt backend, which (like the original review's own F8 finding) can't be built and run standalone in this environment — but the shape of the gap doesn't depend on exactly how expensive that call turns out to be; it depends on there being no limit on how many distinct ones a sender can trigger, which is independently confirmed.

This applies identically inside private forums, since the forum-unwrap step happens before the message is dispatched by type — anyone holding a private forum's invite link has the same ability against the other members of that forum specifically.

Suggested fix, in the same shape as the two prior findings this most resembles (F6/F7, both about posts): add a TokenBucket for MediaAsk processing, the same pattern already used for new-key posts and digest re-sends, so the number of distinct content ids a receiver will act on per minute is bounded regardless of how many different ones a sender asks about — the existing per-id cooldown is fine as a secondary guard against repeats of the same id, it just isn't one against variety.

Code: src/forumer_backend.cpp:2314 (handleMediaAsk), :3027 (dispatch, confirms no generic throttle sits upstream of the type switch); lib/forumer_core/include/forumer_core/flood.h (the five-layer design comment, quoted above, with no sixth layer for media); lib/forumer_core/src/sync.cpp:225-245 (cidShape validation in decode() — a format check only); probes/probe_mediaask_flood.cpp for the reproduction.

What else was checked, and came back clean

checked, no issue

Image-decode memory exhaustion ("decompression bomb")

Hypothesis: image_prep.cpp's pixel-count guard (if (declared.isValid() && width*height > kMaxInputPixels)) runs before the image is actually decoded, using QImageReader::size() — if that ever returns an invalid size for a file that still decodes successfully, the guard is skipped entirely and the following full decode has no size limit at all, bounded only by the 30 MB file-size cap (which doesn't bound decompressed memory for a highly-compressible crafted file).

Tested directly with a standalone Qt6Gui probe against real PNG (normal and interlaced) and JPEG (normal and progressive) files: declared.isValid() was true, with the correct dimensions, in every case. Qt's PNG and JPEG handlers both read the true dimensions from the file header without needing to decode pixel data, which is exactly why the guard works for these two formats specifically — a PNG "bomb" still has to declare its real (huge) dimensions in its header for a standard decoder to make sense of it, and that's exactly what the size check reads.

Not fully cleared: WebP is the third format Forumer's code accepts, and this sandbox's Qt6 installation has no WebP decoder plugin available at all (every WebP input returned an outright decode failure, not a successful one with a bad size), so the guard's behavior for a crafted WebP file specifically is genuinely untested, not confirmed safe.

checked, no issue

The new private-forum and image-sharing crypto

Read sealed.cpp, forums.cpp, and media.cpp line by line (the full implementation, not just the header documentation already cited in the companion review). Three independently-derived subkeys (forum wire, forum storage, media) are each used for exactly one purpose, bound with correct associated data (forum id, purpose string, account id, or mime type, depending on context) that prevents a ciphertext sealed for one purpose being accepted for another. Every AEAD nonce is either freshly random (sealed.cpp, forums.cpp) or deterministically derived from a key that is itself unique per distinct plaintext (the media path's convergent-encryption nonce) — the second case is safe specifically because nonce reuse only matters when the same key encrypts different plaintexts, which can't happen there by construction. media::open() and openPreview() both re-verify the decrypted content's hash, size, and type against the signed reference after decryption succeeds, not before — a swapped or truncated blob is refused even if it happened to decrypt without an AEAD-tag failure.

checked, no issue

The other two new message handlers (MediaHere, Preview)

handleMediaHere only acts on a content id the receiver is itself actively fetching (m_mediaFetches.find(hint.cid) must already exist) — an attacker sending unsolicited mhere messages for ids nobody asked about is a no-op. handlePreviewPart and acceptPreview are both explicitly bounded: at most 32 previews being assembled at once, a 2-minute assembly timeout, at most 32 previews held pending their post for up to 10 minutes, and a preview is verified against the author's own signature before it's ever written to storage — a forged preview is rejected cheaply, before any of the bounded queues are touched.

checked, no issue

Image picker: external process invocation

The file picker (osascript on macOS, zenity or kdialog on Linux) is launched via QProcess::start(program, QStringList args) throughout — the argument-array form, which does not go through a shell, so there is no injection vector through a crafted filename or path. The macOS AppleScript text itself is a fixed literal with nothing untrusted interpolated into it.

checked, no issue

Per-post image-count limit, enforced on receive, not just on send

The four-images-per-post cap is checked in two places: the composer (attachImage, before the author even signs a post) and, independently, inside post::verify() itself via validateDraft(p.content), which runs for every post received from the network. A peer cannot bypass the limit by hand-constructing a signed envelope with more than four media references and sending it directly — verify() rejects it the same way an honest client's own composer would have refused to build it.

checked, no issue

The new per-forum SQL

PostStore::removeForum and the forum-scoped query paths added for private forums (lib/forumer_core/src/post_store.cpp) are fully parameterised (?1/?2/?3 placeholders) with no string concatenation into SQL text anywhere in the new code — consistent with the rest of the codebase, which the original review already noted as fully parameterised throughout.

How this was done

Read every line of the four files new in 0.2.3 that the companion review hadn't fully read line-by-line (sealed.cpp, media.cpp implementation — the header was already read for the companion report, but not the .cpp), plus a fresh, adversarial re-read of the message-dispatch path in forumer_backend.cpp specifically looking for gaps between what the new message types need and what the existing flood-control design actually covers. Built two standalone probes: one against the real lib/forumer_core sources (no Qt) to reproduce the reachable half of the MediaAsk finding with real numbers, and one against a bare Qt6Gui to test the image-decode size-guard hypothesis against real image files. Grep-verified the absence of a generic throttle upstream of the message-type dispatch, and the presence (or absence) of a TokenBucket for each message type, directly against the header that documents what exists. Checked the picker's process-invocation code, the per-post media-count enforcement on both the send and verify paths, and the new forum-scoped SQL by direct reading, each against the specific vulnerability class it would need to avoid (shell injection, bypass-via-crafted-envelope, string-built SQL respectively).

No GUI testing in this pass — this was a code-and-probe audit only, not a live app session.

What this could not check

Environment: Linux 6.17, x86_64, g++ 12.2 with system libsodium/sqlite3/nlohmann-json 3 and Qt6Gui 6.4.2. Repo cloned fresh, v0.2.3 tag checked out, never modified. Re-run the probes with probes/README.md. No network activity of any kind in this pass — everything here is static code reading and standalone, offline probes.