LC-206-IMAGE-LIMITS: spike image decompression-bomb exposure, apply image::Limits if confirmed #284
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 (investigate-first)
No image decode path configures
image::Limits(noset_limits/max_allocanywhere inserver/src). The byte caps that protect the decoders bound the input file size, not the decoded pixel-buffer allocation, so a small highly-compressed image (PNG/GIF decompression bomb) can expand to a very large RGBA buffer at decode time.This is a UNIFORM gap, not asymmetric: all three untrusted-image entry points already route through the LC-206 safe helper (
process_image_safely) and share the same unguarded decoder, so it is one finding across all three, not a sibling-missed-the-guard case.Where
server/src/uploads/pipeline.rs:process_still(:137),process_gif(:160),preview_from_path(:206) callImageReader::decode()/GifDecoder::into_frames()with noLimits.spawn_blockingpanic boundary, but none pixel-capped):server/src/routes/uploads.rs:274(10 MiB byte cap)server/src/bridge_avatar.rs:150(1 MiB stream cap)server/src/email_ingress/attachments.rs:155(byte cap)Failure mode / cost
A crafted image within the byte cap could drive a large memory spike at decode. Existing mitigations bound the blast radius:
spawn_blockingkeeps it off the runtime, and a concurrency semaphore caps parallel decodes. Whether a single decode (orsemaphore-many concurrent ones) can exhaust memory past those bounds is NOT confirmed by reading; it needs a spike.Proposed scope (investigate-first)
imagedecoders a known decompression-bomb corpus at the current byte caps and measure peak allocation per decode and at full semaphore concurrency.image::Limits(amax_allocbound) on every decode site inpipeline.rs, behind the same grep-banned safe helper so the cap cannot be bypassed.Limitsimage is rejected cleanly (not OOM, not panic).Limitsfor hostile input" gotcha into CLAUDE.md (the M2 item from the sweep).Acceptance
Either a confirmed spike +
Limitsapplied at every decode site with a test, OR a documented finding that the byte cap + semaphore + spawn_blocking already bound allocation acceptably (close as not-a-bug with the measurement recorded).Anchored to LC-206 (image-decoder safe helper). Severity: correctness/security, but speculative until the spike confirms exploitability.