2FA setup required: review round 2 — no SVG from the icon endpoint, migrations at container start

R2-1: /api/ipal/admin-icon answers with bytes only for a bitmap recognised by its
first bytes (PNG, JPEG, GIF, WebP, ICO, AVIF). An SVG favicon keeps the redirect
to the media file: a site-wide CSP rule overrides a route's own sandbox header,
so the header alone protected nothing in a built site. buildUploadSecurityHeaders
also returns a rule for the icon path, as a second layer.
R2-2: the SQL migration runs when the new container starts (prodMigrations, or
the start command), never in Coolify's pre-deployment command; docs and the log
line say so and point to deployment.md 4.3.
R2-3: requireSetup: null is the default. R2-4: the missing-column log line only
for a column error. R2-5, R2-6: the resetAccess example keeps the code check;
with guard: false the reset endpoint does not exist.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-24 20:18:47 +01:00
co-authored by Claude Fable 5.2
parent 75a6f5209e
commit 01e3813723
20 changed files with 155 additions and 53 deletions
+2 -1
View File
@@ -232,7 +232,8 @@ describe('buildUploadSecurityHeaders', () => {
test('sandboxes files served from upload routes', async () => {
const { buildUploadSecurityHeaders } = await import('../src/modules/security/buildSecurityHeaders.js')
const rules = buildUploadSecurityHeaders({ collections: ['media', 'documents'] })
expect(rules.map((r) => r.source)).toEqual(['/api/media/file/:path*', '/api/documents/file/:path*'])
// the upload routes, and the panel icon endpoint (it answers with a file's bytes too)
expect(rules.map((r) => r.source)).toEqual(['/api/media/file/:path*', '/api/documents/file/:path*', '/api/ipal/admin-icon'])
const csp = rules[0].headers.find((h) => h.key === 'Content-Security-Policy')?.value ?? ''
expect(csp).toContain('sandbox')
expect(csp).toContain("default-src 'none'")