Every web framework tutorial shows you how to accept a file upload.
Almost none show you what to do next.
You validate the Content-Type header. You check the extension. You think you're done.
You're not.
The default file upload stack leaves you exposed on four fronts: parsing security, file type spoofing, size abuse, and malware. These 7 tools close each gap without requiring a dedicated security team.
TL;DR: File upload security requires a stack, not a single library. These 7 tools cover parsing, validation, and scanning end-to-end.
Table of Contents
pompelmi — antivirus scanning before the file touches permanent storage
multer — secure multipart parsing with built-in size and field limits
busboy — low-level streaming parser for fine-grained upload control
file-type — detect the real file type from magic bytes, not the filename
mime-types — map MIME types reliably without trusting user input
sharp — re-encode images to eliminate embedded payloads
archiver — control archive creation to prevent zip bomb and path traversal risks
1) pompelmi — scan files before they land
What it is: A minimal Node.js wrapper around ClamAV that scans any uploaded file and returns a typed verdict — Clean, Malicious, or ScanError. Zero runtime dependencies, no cloud, no daemon required.
Why it matters: The file upload attack surface doesn't start with storage — it starts with what you accept. A PDF that passes as application/pdf can still carry a macro payload. An image can embed executable content. pompelmi adds a scanning layer before any file touches your database or object storage, running ClamAV locally so no user data ever leaves your server.
Best for: Express, Fastify, NestJS, Next.js, SvelteKit, any Node.js app that accepts user file uploads
Links:
Minimal Node.js wrapper around ClamAV — scan any file and get Clean, Malicious, or ScanError. Handles installation and database updates automatically.
that scans any file and returns a typed Verdict Symbol: Verdict.Clean, Verdict.Malicious, or Verdict.ScanError. No daemons. No cloud. No native bindings. Zero runtime dependencies.
Table of contents
2) multer — multipart parsing with limits built in
What it is: Express middleware for handling multipart/form-data with configurable file size limits, field count caps, and pluggable storage engines.
Why it matters: Unbounded multipart parsing is a DoS vector. A malicious client can send a multi-gigabyte upload or thousands of fields and exhaust server memory before any route handler runs. Multer's limits configuration rejects requests that exceed your thresholds before the full payload is consumed.
Best for: Express apps, REST APIs with file upload endpoints, any multipart form processing
Links: /
Multer is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files. It is written
on top of
3) busboy — streaming multipart parsing for full control
What it is: A low-level streaming multipart parser for Node.js that processes uploads without buffering the entire payload in memory.
Why it matters: Multer is the right default. Busboy is the right tool when you need to act on files before they're fully received — streaming to S3, scanning chunks in flight, or enforcing byte-level limits mid-stream. It trades abstraction for control, which is what high-volume or security-critical pipelines need.
Best for: High-volume uploads, streaming directly to cloud storage, custom upload pipelines, apps where memory pressure matters
Links: / .
Note: If you are using node v18.0.0 or newer, please be aware of the node.js
HTTP(S) server's -- v10.16.0 or newer
Install
npm install busboy
Examples
- Parsing (multipart) with default options:
const http = require('http');
const busboy = require('busboy');
http.createServer((req, res) => {
if (req.method === 'POST') {
console.log('POST request');
const bb = busboy({ headers: req.headers });
bb.on('file', (name, file, info) => {
const { filename…
Detect the file type of a file, stream, or data
of the buffer.
This package is for detecting binary-based file formats, not text-based formats like .txt, .csv, .svg, etc.
We accept contributions for commonly used modern file formats, not historical or obscure ones. Open an issue first for discussion.
Install
npm install file-typeThis package is an ESM package. Your project needs to be ESM too. . If you use it with Webpack, you need the latest Webpack version and ensure you configure it correctly for ESM.
Important
File type detection is based on binary signatures (magic numbers) and is a best-effort hint. It does not guarantee the file is actually of that type or that the file is valid/not malformed.
Robustness against malformed input is best-effort. When…
Checking file extensions vs checking magic bytes. Source:
The ultimate javascript content-type utility.
mime-types
, except:
No fallbacks. Instead of naively returning the first available type
mime-typessimply returnsfalse, so do
var type = mime.lookup('unrecognized') || 'application/octet-stream'.- No
new Mime()business, so you could dovar lookup = require('mime-types').lookup. - No
.define()functionality - Bug fixes for
.lookup(path)
Otherwise, the API is compatible with mime 1.x.
Install
This is a . Installation is done using the
6) sharp — re-encode images to strip dangerous payloads
What it is: A high-performance Node.js image processing library that converts, resizes, and re-encodes images using libvips.
Why it matters: An image that passes file-type validation can still contain EXIF metadata with XSS payloads, embedded scripts, or polyglot content that triggers vulnerabilities in downstream image parsers. Re-encoding through sharp strips all of this — the output is a clean, verified image. For any app serving user-uploaded images to other users, this step is non-negotiable.
Best for: Profile photos, user-generated image content, any pipeline that stores and serves uploaded images
Links:
High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
sharp
.
Colour spaces, embedded ICC profiles and alpha transparency channels are all handled correctly
Lanczos resampling ensures quality is not sacrificed for speed.
As well as image resizing, operations such as
rotation, extraction, compositing and gamma correction are available.
Most modern macOS, Windows and Linux systems
do not require any additional install or runtime dependencies.
Documentation
Visit ,
and
7) archiver — create archives without exposing attack surfaces
What it is: A streaming archive creation library for Node.js supporting zip, tar, and other formats with programmatic entry control.
Why it matters: When you generate archives for users programmatically, archiver gives you explicit control over what's included — preventing path traversal, setting compression ratios, and limiting which files can enter the archive. When you own archive creation, you define the attack surface rather than inheriting it from user input.
Best for: Download bundles, backup generation, export features, any server-side archive creation workflow
Links: / for a list of all methods available.
Install
npm install archiver --saveQuick Start
import fs from "fs";
import { ZipArchive } from "archiver";
// create a file to stream archive data to.
const output = fs.createWriteStream(__dirname + "/example.zip");
const archive = new ZipArchive({
zlib: { level: 9 }, // Sets the compression level.
});
// listen for all archive data to be written
// 'close' event is fired only when a file descriptor is involved
output.on("close", function () {
console.log(archive.pointer() + " total bytes");
console.log(
"archiver has been finalized and the output file descriptor has closed.",
);
});
// This…
Final thoughts
File upload security is a pipeline, not a single check. Parse with size limits, detect real types from magic bytes, map to allowed MIME types, sanitize image content, scan for malware, and control any archive generation.
Skip any step and you have a gap. Use all seven and you have a defensible upload stack that doesn't trust user input at any layer.
What's your current file upload pipeline missing?
Community-Analysen & Experten-Meinungen 0
Verwandte Story-Cluster & Quellen (Vektor-KI)
Ähnliche Beiträge
Auch interessante Nachrichten 7 Open-Source Tools That Make File Upload Security Actually Manageable
Thematisch verwandte Begriffe: OpenSource, Tools, That, Make · 6 Treffer
Amazon bietet Soundcore-In-Ears zum ersten Mal günstiger an: Mit ANC, Dolby Atmos & mehr Highlights
Axeos erhält ISO 9001:2015-Zertifizierung
Axeos erhält ISO 9001:2015-Zertifizierung
Q&D: Flutter App and Android-SDK
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
tsecurity.de App
Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformentsecurity.de Live Threat Radar
Community Radar & Live Chat
Aktivitäten deiner Analysten
Neues Thema oder Eilmeldung einreichen
Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.
SOCIAL SHARE CARD GENERATOR