feat(web): guild logo branding with hardened upload (slice 8f)#57
Merged
Conversation
Completes Phase 1 branding (§26 'Basis-Branding: Farben, Logo'). Guilds can upload a logo shown on their public form + status pages. Security (logos are served publicly as <img>, so the upload is hardened): - raster-only allowlist via magic-byte sniff (lib/image.ts) — SVG is rejected (no inline script / stored XSS), client MIME is never trusted. - the image is decoded and re-encoded with sharp to WebP (resize <=512, metadata stripped, input-pixel cap) — only pixels survive, neutralising polyglots / hidden payloads / EXIF / decompression bombs. - 1 MB limit, manager-only. - served via /api/guilds/[guildId]/logo with a fixed image/webp Content-Type + X-Content-Type-Options: nosniff, so it can't be reinterpreted. - shared: brandingSchema gains logoKey; brandingColorSchema keeps the color endpoint from touching it (read-merge-write preserves the logo). - dashboard branding page gains a logo upload/preview/remove form. - form + status pages render the logo in the header when set. - adds sharp (already allowed in pnpm allowBuilds; serverExternalPackages). - i18n: branding logo labels (DE/EN); image magic-byte unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 finish — Task 6/6: Logo branding (hardened upload)
Completes Phase 1 branding (§26 Basis-Branding: Farben, Logo). Guilds can upload a logo shown on their public form and status pages.
Security (the logo is served publicly as
<img>, so the upload is hardened)lib/image.ts) — SVG is rejected (no inline script → no stored XSS); the client-declared MIME is never trusted.sharpto WebP (resize ≤512, metadata stripped, input-pixel cap) — only pixels survive, neutralising polyglots / hidden payloads / EXIF / decompression bombs.GET /api/guilds/[guildId]/logowith a fixedimage/webpContent-Type +X-Content-Type-Options: nosniff, so it can't be reinterpreted as anything executable.Other changes
brandingSchemagainslogoKey; a separatebrandingColorSchemakeeps the color endpoint from touching the logo (read-merge-write preserves it).img-src 'self'already covers it).sharp(already in pnpmallowBuilds; added toserverExternalPackagesso the native module isn't bundled).Verification
pnpm typecheck✅ ·pnpm lint✅ ·pnpm test✅ (10, incl. image sniff) ·pnpm build✅ (sharp ok; logo routes registered) · sharp re-encode smoke ✅This is the last Phase-1 item — Phase 1 is now 100% per the concept.