docs(quick-261106-d20): fonoteka.go uploads named after the sniffed type, attach.UploadWriterOptions exported, 2 todos closed

This commit is contained in:
Jakub Zych
2026-11-06 09:38:19 +01:00
parent 903859a131
commit 8a600ca704
4 changed files with 361 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
---
title: fonoteka.go uploads still name files after the client extension (stored XSS)
date: 2026-10-28
created: 2026-10-28T18:47:20.000Z
area: fonoteka.go uploads
severity: major
priority: high
g15office: cf81chjk
files:
- ../fonoteka.go/plugins/golem15/fonoteka/controllers/api/collection_media_controller.go:251 (storeUpload)
- ../fonoteka.go/plugins/golem15/fonoteka/classes/album_files.go:35 (StorePublicFile)
---
## Problem
Split from `2026-10-11-uploads-keep-client-extension-stored-xss.md` (closed by quick 261028-r16, framework side). `attach.Store` and `attach.DiskExtension` in the framework name files from the sniffed type, but fonoteka.go's own upload paths still append `filepath.Ext(<client name>)` to the disk name. A PNG with `<script>` in a tEXt chunk uploaded as `x.html` is stored as `<hex>.html` and rendered by the web server as HTML.
## Solution
- In both call sites, sniff first, then name with `attach.DiskExtension(contentType, filepath.Ext(name))`. Keep the client name only in `file_name`.
- Uploads without an extension then get `.bin` / `.txt` instead of none.
- Regression test: the x.html PNG is stored and served as `.png`.
- Optional cleanup, already safe: `sm-feedback-plugin` `screenshotExtension` and `sm-user-plugin` `avatarExt` could reuse the helper.

View File

@@ -0,0 +1,27 @@
---
created: 2026-11-06T08:17:49.419Z
title: Blob writers that bypass attach.Store set Content-Disposition for non-inline types
area: framework
severity: minor
g15office: ifdz5o0m
files:
- modules/lagoon/attach/inline.go:31 (IsInlineContentType), :38 (uploadWriterOptions, unexported)
- ../fonoteka.go/plugins/golem15/fonoteka/controllers/api/collection_media_controller.go:258 (storeUpload)
- ../fonoteka.go/plugins/golem15/fonoteka/classes/album_files.go:42 (StorePublicFile)
- ../sm-user-plugin/controllers/api_controller.go:1559 (avatar upload)
- ../sm-feedback-plugin/classes/submission_store.go:131 (screenshot)
---
## Problem
Follow-up of g15office knuu7fil (closed by summercms.go 27c98bf). `attach.Store` stores every non-inline type (anything but JPEG/PNG/GIF/WebP/AVIF) with `Content-Disposition: attachment`, and `attach.StaticHandler` / `StaticHandlerPublic` now send the stored disposition plus `nosniff`. Writers that call `bucket.NewWriter` / `WriteAll` themselves pass only `ContentType`, so their blobs carry no disposition and an HTML or SVG blob is served inline by the static handlers (or by a web server reading the bucket directly).
Writers that bypass `attach.Store`:
- fonoteka.go `storeUpload` and `StorePublicFile`: accept arbitrary media, so this is the real gap. The disk-extension issue at the same call sites is the separate major todo `2026-10-28-fonoteka-uploads-use-disk-extension.md` (cf81chjk); do both together.
- sm-user-plugin avatar upload and sm-feedback-plugin screenshots: inputs are already limited to images, so this is defence in depth.
## Solution
- Framework (additive): export the writer-options helper, e.g. `attach.UploadWriterOptions(contentType) *blob.WriterOptions`, with README and docs updated in the same commit. Writers can also check `attach.IsInlineContentType` themselves, or switch to `attach.Store`.
- Each writer uses it. Shared plugins: additive change only, plugin commit and patch tag first, then pointer bumps in the apps as separate commits. A plugin using a new framework export needs the framework tag that has it, so raise the plugin's required version only if consumers are already on that version; otherwise inline the `IsInlineContentType` check.
- Regression test per writer: an upload whose sniffed type isn't an inline image is stored with `attachment` disposition.