Pentest R89: Provider-Adressfelder härten
R89.1 MEDIUM + R89.2 LOW: sanitizeNotes(…, 500) macht silent slice(0, 500) statt 400, und stripHtml lief vor dem Length- Check – `<script>…</script>` reduzierte auf "" → null in DB → vorheriger Wert silent überschrieben (R87.1-Pattern auf Adress-Feldern). Fix: validateProviderAddress() in sanitize.ts – Raw-Input, max 500 mit ApiError(400), Blacklist <, >, Tab + alle Control-Chars außer \n. CRLF → LF VOR dem Length-Check, damit Editoren mit \r\n-Line-Endings nicht doppelt zählen. Eingehängt in stripProviderStrings für contactAddress/cancellationAddress. R89.3/R89.4 (Quotes/\n) bewusst akzeptiert – Pentester selbst sagt "kein Risiko", sind in Adressen legitim. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import prisma from '../lib/prisma.js';
|
||||
import { stripHtml, isValidEmail, sanitizePhoneField, sanitizeNotes } from '../utils/sanitize.js';
|
||||
import { stripHtml, isValidEmail, sanitizePhoneField, validateProviderAddress } from '../utils/sanitize.js';
|
||||
import { validateHttpUrl } from '../utils/url.js';
|
||||
|
||||
// Pentest 46.1 (HIGH, 2026-06-01): Stored XSS via provider.portalUrl.
|
||||
@@ -84,10 +84,16 @@ function stripProviderStrings<T extends object>(data: T): T {
|
||||
const v = sanitizePhoneField(out[k], phoneLabels[k]);
|
||||
out[k] = v === undefined ? null : v;
|
||||
}
|
||||
const addressLabels: Record<string, string> = {
|
||||
contactAddress: 'Kontakt-Postadresse',
|
||||
cancellationAddress: 'Kündigungs-Postadresse',
|
||||
};
|
||||
for (const k of ['contactAddress', 'cancellationAddress'] as const) {
|
||||
if (out[k] === undefined) continue;
|
||||
if (out[k] === '' || out[k] === null) { out[k] = null; continue; }
|
||||
out[k] = sanitizeNotes(out[k], 500);
|
||||
// R89.1/R89.2: validateProviderAddress wirft 400 bei Längen-
|
||||
// Verstoß, HTML, Tabs oder Steuerzeichen. Kein silent truncate,
|
||||
// kein silent null-overwrite mehr.
|
||||
out[k] = validateProviderAddress(out[k], addressLabels[k]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user