Skip to content

themes: fix asset 404 fallback and overly broad server #40

Open

Description

@wayback09

themes: fix asset 404 fallback and server overly broad

Context

pkg/theme/manager.go:87-126 GetAssetURLs double-checks AllowedAssetKeys/LockedAssetKeys, but L120-123 only checks fs.ContainedPath, not os.Stat. List() at manager.go:48 does os.Stat.

Problem

  • If overwrite.json maps sidebar-logo but the PNG was deleted/corrupted, GetAssetURLs returns a URL that 404s. <img src> shows broken image instead of falling back to || '/logo.png' (Sidebar.svelte:110, TitleBar.svelte:23).
  • pkg/theme/server.go:33-34 serves http.Dir(getThemesDir()) with CORS * — any extra file smuggled via zip (e.g. evil.html) is serveable, even though only PNGs should be.

Fix

  • In manager.go:120-123 add os.Stat like List() does; if missing, skip entry so frontend fallback triggers.

  • In server.go:33-34 restrict to whitelisted extensions or at least set Content-Type correctly; consider serving only themes/<id>/*.png + *.css allowlist.

  • Files: pkg/theme/manager.go:87-126, pkg/theme/server.go:33-34, frontend/src/stores/theme.ts:41-44

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions