harden(modules): Payload-Grenze + Modul-ID-Prüfung nach Sicherheits-Review (v1.5.7)
Unabhängige Security-Review bestätigte: keine Autorisierungs-/Mandanten-Lücken (Tenant-Isolation via getProjectWithTenantCheck, VIEWER-Schreibsperre, keine Injection). Zwei Härtungspunkte umgesetzt: - module_items data-Payload auf 20 KB pro Zeile begrenzt (POST+PUT) → kein DB-Bloat/DoS durch beliebig grosse JSON-Objekte - moduleId-Länge auf 64 Zeichen begrenzt (verhindert pathologische Keys) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lageplan",
|
"name": "lageplan",
|
||||||
"version": "1.5.6",
|
"version": "1.5.7",
|
||||||
"description": "Feuerwehr Lageplan - Krokier-App für Einsatzdokumentation",
|
"description": "Feuerwehr Lageplan - Krokier-App für Einsatzdokumentation",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -25,9 +25,15 @@ export async function PUT(
|
|||||||
const body = await request.json()
|
const body = await request.json()
|
||||||
const patch = body && typeof body.data === 'object' && body.data !== null ? body.data : {}
|
const patch = body && typeof body.data === 'object' && body.data !== null ? body.data : {}
|
||||||
|
|
||||||
|
const merged = { ...(existing.data || {}), ...patch }
|
||||||
|
// Payload-Härtung: Zeilengrösse begrenzen (DB-Bloat/DoS vermeiden)
|
||||||
|
if (JSON.stringify(merged).length > 20000) {
|
||||||
|
return NextResponse.json({ error: 'Eintrag zu gross' }, { status: 413 })
|
||||||
|
}
|
||||||
|
|
||||||
const item = await (prisma as any).moduleItem.update({
|
const item = await (prisma as any).moduleItem.update({
|
||||||
where: { id: itemId },
|
where: { id: itemId },
|
||||||
data: { data: { ...(existing.data || {}), ...patch } },
|
data: { data: merged },
|
||||||
})
|
})
|
||||||
return NextResponse.json(item)
|
return NextResponse.json(item)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -38,11 +38,17 @@ export async function POST(
|
|||||||
if (!user) return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 401 })
|
if (!user) return NextResponse.json({ error: 'Nicht autorisiert' }, { status: 401 })
|
||||||
if (user.role === 'VIEWER') return NextResponse.json({ error: 'Keine Berechtigung' }, { status: 403 })
|
if (user.role === 'VIEWER') return NextResponse.json({ error: 'Keine Berechtigung' }, { status: 403 })
|
||||||
|
|
||||||
|
if (moduleId.length > 64) return NextResponse.json({ error: 'Ungültige Modul-ID' }, { status: 400 })
|
||||||
|
|
||||||
const project = await getProjectWithTenantCheck(id, user)
|
const project = await getProjectWithTenantCheck(id, user)
|
||||||
if (!project) return NextResponse.json({ error: 'Projekt nicht gefunden' }, { status: 404 })
|
if (!project) return NextResponse.json({ error: 'Projekt nicht gefunden' }, { status: 404 })
|
||||||
|
|
||||||
const body = await request.json()
|
const body = await request.json()
|
||||||
const data = body && typeof body.data === 'object' && body.data !== null ? body.data : {}
|
const data = body && typeof body.data === 'object' && body.data !== null ? body.data : {}
|
||||||
|
// Payload-Härtung: eine Tabellenzeile bleibt klein — verhindert DB-Bloat/DoS
|
||||||
|
if (JSON.stringify(data).length > 20000) {
|
||||||
|
return NextResponse.json({ error: 'Eintrag zu gross' }, { status: 413 })
|
||||||
|
}
|
||||||
|
|
||||||
const count = await (prisma as any).moduleItem.count({ where: { projectId: id, moduleId } })
|
const count = await (prisma as any).moduleItem.count({ where: { projectId: id, moduleId } })
|
||||||
const item = await (prisma as any).moduleItem.create({
|
const item = await (prisma as any).moduleItem.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user