Pentest 62.7 LOW: deliveryDate / confirmationDate ISO-8601-Validierung
Bisher gingen XSS-Payloads in deliveryDate (saveEmailAsContractDocument, saveAttachmentAsContractDocument, uploadContractDocument) und confirmationDate (Cancellation-Confirmation-Upload) mit 200 durch. Das Datum wurde silent als null behandelt; Impact gering, aber schlechte API-Hygiene. Neuer validateOptionalIsoDate-Helper in utils/sanitize: - ISO-8601-Regex YYYY-MM-DD oder YYYY-MM-DDTHH:MM:SS(.fff)?(Z|+HH:MM)? - null / leerer String / undefined sind OK (Optional-Semantik) - Sonstige Eingaben werfen 400 mit klarer Meldung Eingesetzt in: - contract.controller uploadContractDocument (multer-Datei wird bei Reject sauber gelöscht) - cachedEmail.controller saveEmailAsContractDocument + saveAttachmentAsContractDocument: Validierung früh, BEVOR Dateien geschrieben werden – kein Datei-Müll bei Reject - upload.routes handleContractDocumentUpload (cancellationConfirmation*) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
canAccessBankCard,
|
||||
canAccessIdentityDocument,
|
||||
} from '../utils/accessControl.js';
|
||||
import { validateOptionalIsoDate } from '../utils/sanitize.js';
|
||||
|
||||
// Pentest 56.1 (HIGH, 2026-06-01): Upload-Endpoints prüften nur die
|
||||
// Permission, nicht ob die Ziel-Resource zum Caller passt. Helper-Funktion
|
||||
@@ -738,11 +739,18 @@ async function handleContractDocumentUpload(
|
||||
const dateField = fieldName === 'cancellationConfirmationPath'
|
||||
? 'cancellationConfirmationDate'
|
||||
: 'cancellationConfirmationOptionsDate';
|
||||
const provided = typeof req.body?.confirmationDate === 'string' ? req.body.confirmationDate : null;
|
||||
// Pentest 62.7: confirmationDate gegen ISO-8601 validieren.
|
||||
let provided: string | null;
|
||||
try {
|
||||
provided = validateOptionalIsoDate(req.body?.confirmationDate, 'confirmationDate');
|
||||
} catch (err) {
|
||||
cleanupFile(req.file?.path);
|
||||
res.status(400).json({ success: false, error: err instanceof Error ? err.message : 'Ungültiges Bestätigungsdatum' });
|
||||
return;
|
||||
}
|
||||
let target: Date | null = null;
|
||||
if (provided) {
|
||||
const parsed = new Date(provided);
|
||||
if (!isNaN(parsed.getTime())) target = parsed;
|
||||
target = new Date(provided);
|
||||
}
|
||||
if (target) {
|
||||
updateData[dateField] = target;
|
||||
|
||||
Reference in New Issue
Block a user