KamoCRM

Chat attachment uploads authenticate before the body is spooled

FixMediaService
Shipped
September 23, 2026 at 10:50 AM UTC
Author
Kamo
Commit
2ba2ce2

POST /sessions/{guid}/attachments bound its parts as a @RequestParam MultipartFile[] method parameter. Spring resolves method parameters before a controller method's body runs, so the container started spooling toward the 3.1 GB request ceiling before requireMember ever got a chance to reject an unauthenticated caller - an unauthenticated POST could make a pod spool gigabytes to disk for nothing. (kamo-internal's own multipart piping is handled separately.) upload() now takes only HttpServletRequest, calls requireMember and the session-membership check first, and only then reads the parts by hand off the MultipartHttpServletRequest Spring already wrapped the request in. **************** (application.yml and k8s/configmap.yaml) keeps that wrapper from parsing anything until this method actually asks it to - binding MultipartFile[] directly would still have forced a parse during argument resolution, ahead of every line in the method body, lazily or not. Covered by **************** mutation-checked by moving the file-read back ahead of the auth check (same signature, same class): two of the four assertions turn red under that ordering.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing