Pentest 69.3 (INFO): Magic-Byte-Validator auf Vertragsdokumente erweitert

contract.routes.ts Vertragsdokumente-Upload hatte bisher nur den
PDF-Inhalts-Scan aus 68.1. JPG/PNG-Uploads waren ungeprüft, ohne
canonical Rename – Pentester selbst attestiert "ohne Exploit-Pfad"
(Download-Layer fängt's), aber inkonsistent zu allen anderen
Upload-Pfaden.

- Refactor: detectType + validateUploadedFile aus upload.routes.ts
  in neue Middleware uploadFileTypeValidator.ts ausgelagert (Single
  Source of Truth, ~90 Zeilen Duplikation entfällt).
- contract.routes.ts: validateUploadedFile ersetzt
  scanUploadedPdfIfPresent → Magic-Byte + canonical Rename + PDF-Scan
  in einer Pipeline.
- pdfUploadSafety.ts: scanUploadedPdfIfPresent entfernt (tot).
This commit is contained in:
2026-06-03 14:49:06 +02:00
parent ec577e6d76
commit 9cfd2e4a64
5 changed files with 130 additions and 130 deletions
+19
View File
@@ -97,6 +97,25 @@ isolierte Instanz (keine Multi-Tenancy im Code), Provisioning + Abrechnung
## ✅ Erledigt
- [x] **🔒 Pentest 69.3 (INFO → Defense-in-Depth): Magic-Byte-Check auf Vertragsdokumente erweitert**
- `contract.routes.ts` Vertragsdokumente-Upload hatte bisher nur den
PDF-Inhalts-Scan (`scanUploadedPdfIfPresent` aus 68.1). JPG/PNG-
Uploads waren ungeprüft kompensiert durch Download-Layer
(`fileDownload.controller.ts` liefert nur bei Magic-Byte-Match
inline aus, sonst attachment). Pentester selbst: "ohne Exploit-
Pfad", aber inkonsistent zu `upload.routes.ts`.
- **Refactor:** `detectType` + `validateUploadedFile` aus
`upload.routes.ts` in neue Middleware
`middleware/uploadFileTypeValidator.ts` ausgelagert (Single Source
of Truth). Beide Routes nutzen jetzt denselben Helper.
- **contract.routes.ts:** `validateUploadedFile` ersetzt das
schlankere `scanUploadedPdfIfPresent` jetzt greift Magic-Byte +
canonical Rename + PDF-Scan für Vertragsdokumente analog zu allen
anderen Upload-Pfaden.
- **pdfUploadSafety.ts:** `scanUploadedPdfIfPresent` entfernt (tot,
da nur in contract.routes verwendet wurde). `requireSafeUploadedPdf`
bleibt für gdpr.routes Vollmacht + pdfTemplate.routes.
- [x] **🔒 Pentest 68.1 (LOW) + 68.2 (INFO): PDF-Inhalts-Validierung + Modal-Limit**
- **68.1 PDF-Active-Content-Filter:** Magic-Byte-Check prüfte bisher
nur `%PDF-`. PDFs mit `/JavaScript`, `/JS`, `/Launch` (externes