Pentest 70.1 (INFO): GIF/WebP-Whitelist in contract.routes Multer-Filter

contract.routes Vertragsdokumente: Multer-fileFilter blockte
image/gif + image/webp, obwohl validateUploadedFile sie zulässt.
Folge: GIF mit korrektem MIME 415, mit gespooftem MIME 201. Kein
Sicherheitsproblem (Magic-Byte ist der echte Guard), nur Konsistenz.
This commit is contained in:
2026-06-03 15:21:24 +02:00
parent 9cfd2e4a64
commit a235c43f40
2 changed files with 16 additions and 2 deletions
+6 -2
View File
@@ -23,9 +23,13 @@ const docUpload = multer({
},
}),
fileFilter: (_req, file, cb) => {
const allowed = ['application/pdf', 'image/jpeg', 'image/png', 'image/jpg'];
// Pentest 70.1: aligned mit validateUploadedFile-Whitelist
// (PDF/JPG/PNG/GIF/WebP). Multer-fileFilter ist nur "fast reject"
// anhand des client-gemeldeten MIME-Types; der echte Guard ist der
// Magic-Byte-Check in validateUploadedFile.
const allowed = ['application/pdf', 'image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp'];
if (allowed.includes(file.mimetype)) cb(null, true);
else cb(new Error('Nur PDF, JPG und PNG Dateien sind erlaubt'));
else cb(new Error('Nur PDF, JPG, PNG, GIF oder WebP erlaubt'));
},
limits: { fileSize: 10 * 1024 * 1024 },
});