[Bug]: Book resources and video font attachments are served as active content (stored XSS)
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 52/100
調査の方向性
Start at the two named sinks, src/books/mod.rs:144 and src/api/media.rs:188, and read whatever helper guesses the MIME type from the zip or MKV attachment name. Then read the middleware stack in src/api/mod.rs to see where COOP/COEP is added, since that is where a global X-Content-Type-Options: nosniff belongs. Done means SVG/HTML/XHTML from books or fonts come back as application/octet-stream with Content-Disposition: attachment and a sandboxing CSP on those routes, verified by a test asserting the response headers on a crafted EPUB entry.
索引モデルが issue の本文から書いたものです。
説明
[!NOTE]
This issue was written by Claude (Claude Opus 5.5) from a code review session with @PhrolovaMoe. It was found by reading the code and hasn't been reproduced on a running server.
Version
0.40.0 (feat/desktop, 017a837b)
Area
Other
What happened?
/api/books/{id}/files/{*name} serves files from inside an EPUB with a MIME type guessed from the name in the zip (src/books/mod.rs:144). /api/media/{id}/fonts/{index} does the same with MKV attachment file names (src/api/media.rs:188). An .svg, .xhtml or .html inside a downloaded book or torrented MKV is served as image/svg+xml / text/html on the app's own origin, where scripts can use the signed-in user's session. No response sets X-Content-Type-Options: nosniff or a CSP; the global middleware only adds COOP/COEP (src/api/mod.rs).
Steps to reproduce
- Put an EPUB with
OEBPS/x.svgcontaining<svg xmlns="http://www.w3.org/2000/svg" onload="alert(document.domain)"/>in a books library. - Open
/api/books/<id>/files/OEBPS/x.svgwhile signed in.
Expected behavior
Files from books and media attachments never run script on the app's origin.
Suggested fix
- Serve fonts with a font MIME type or
application/octet-stream, never one guessed from an arbitrary name. - For book resources, allow only image/font/CSS types the reader needs, and send everything else as
application/octet-streamwithContent-Disposition: attachment. - Add
X-Content-Type-Options: nosniffglobally andContent-Security-Policy: sandbox(ordefault-src 'none') on these file routes.
- 主要言語
- TypeScript
- スター
- 4
- フォーク
- 1
- 平均マージ
- 4時間 49分
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tinystream-dev/tinystream のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
tinystream-dev/tinystream#132 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
tinystream-dev/tinystream#131 ·
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
tinystream-dev/tinystream#129 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
tinystream-dev/tinystream#128 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tinystream-dev/tinystream#124 ·
tinystream-dev/tinystream の issue をすべて見る
似ている issue
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskオープン
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
sandbox-quantum/switch#2163 ·
メンテナーはふだん 1 日以内に返信
-
automated issue report
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
area/dashboard kind/bug QA/dev-automation
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bug pydanty:is-working
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pydantic/pydantic-ai#13939 ·
メンテナーはふだん 1 日以内に返信
-
self-host
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
funmusicplace/mirlo#2625 ·
メンテナーはふだん 1 日以内に返信