Serving Customer-Sent WhatsApp Media Safely: MIME Types, Filenames and the Blob URL Trap
A WhatsApp team inbox does something most web apps avoid: it shows files from strangers inside a logged-in session. Customers send photos, voice notes, PDFs and "documents" of any kind, and an agent opens them in the same browser tab that holds their access to every conversation in the account. If one of those files is served back the wrong way, it stops being a picture and becomes code running…
WhatsApp's customer service inbox displays files from unknown sources within a logged-in browser tab. This includes photos, voice notes, PDFs, and various documents. Agents open these files in the same browser tab that grants them access to all account conversations. If served incorrectly, a file can become executable code running under that agent's control.
The focus of this article is on safely handling inbound WhatsApp media messages, determining what to trust, storage methods, and the necessary response headers for secure serving. The provided TypeScript snippets illustrate practical implementations of the discussed concepts, based on actual test cases.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.