Sandbox auf ausgelieferte Dateien, die Skript tragen koennen (d4rk-rp-planung#254)

Ein SVG mit <script> lief direkt geoeffnet auf der Herkunft des Dashboards
(FILES_HOST leer) - mit dessen Sitzung. Jeder Upload-Token konnte es ablegen,
die Arten-Fessel "Bild" laesst SVG durch.

Jetzt: Content-Security-Policy "sandbox; default-src 'none'; ..." auf allem
ausser Rasterbild, Video und Ton (Positivliste, dateiKopf in storage.ts), auf
allen Wegen: /f/, /t/, Dateiwirt, /api/privat. Nicht auf Video und Bild,
weil die Sandbox ein direkt geoeffnetes Video anhaelt (readyState 0 statt 4).

Gemessen mit tools/csp-pruefen.mjs gegen einen Wegwerf-Container aus diesem
Stand, Edge kopflos: vorher lief das Skript (Gegenprobe --erwarte-lauf),
jetzt 8/8 - Skript laeuft nicht, SVG wird gezeichnet, PNG und MP4 wie vorher,
Teilantwort 206.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
D4rkst3randClaude Opus 5.5 committed 2026-10-19 20:57:08 +02:00
1 parent 6630def7b2
commit a4e918be8a
4 files changed
+162 -7

No files matched your search

+4 -5
View File
@@ -30,7 +30,7 @@ import { config } from './config.js'
import { ensureAdmin } from './auth.js'
import { pruneEvents, pruneSessions, pruneVerwaltung, schreibeAbrufe, zaehleAbruf } from './db.js'
import { pruefePlatte, pruefeSicherung } from './meldung.js'
import { absolutePath, checkPath, lohntWebp, mimeFor, thumbPath, webpPfad } from './storage.js'
import { dateiKopf, absolutePath, checkPath, lohntWebp, mimeFor, thumbPath, webpPfad } from './storage.js'
import { uploadRoutes } from './routes/upload.js'
import { fivemanageRoutes } from './routes/fivemanage.js'
import { freigabeRoutes } from './routes/freigabe.js'
@@ -152,9 +152,8 @@ async function serveFile(c: any, rawPath: string) {
ETag: etag,
'Last-Modified': info.mtime.toUTCString(),
'Accept-Ranges': 'bytes',
// Kein Verlassen auf den Dateinamen: der Browser soll nicht raten,
// was er da vor sich hat.
'X-Content-Type-Options': 'nosniff',
// nosniff und die Sandbox gegen Skript-SVGs (#254) - storage.ts, dateiKopf.
...dateiKopf(typ),
}
// GEZAEHLT WIRD HIER, nach der Pruefung und vor der Auslieferung.
@@ -282,7 +281,7 @@ app.get('/t/*', async (c) => {
// Kurz: eine Vorschau aendert sich, wenn das Bild neu hochgeladen
// wird, und dann soll das Dashboard es sehen.
'Cache-Control': 'public, max-age=60',
'X-Content-Type-Options': 'nosniff',
...dateiKopf('image/webp'),
})
})