フロア図アップロードのファイル種別を検証する - #17
Merged
Merged
Conversation
- アップロードされたバイナリの内容をimage-sizeで判定し、PNG/JPEG/WebPのみ許可する。 従来は無検証で保存・/uploadsから配信していたため、HTML/SVG等を置くことで APIオリジン上のStored XSSが可能だった - 保存拡張子はクライアントのファイル名ではなく検出形式から決定する - /uploads配信に X-Content-Type-Options: nosniff を付与 - APP_ENV未設定時の既定をコメント通りprod(フェイルセーフ)に修正 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 画像差し替え時に旧ファイルをストレージから削除する - 画像検証ロジックを切り出しユニットテストを追加 - accept にサーバー側で許可済みの WebP を追加 - 保存・公開失敗時にスナックバーでエラー表示(413・形式エラーはi18nメッセージ) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
概要
OSS公開前のセキュリティレビューで見つかった問題の修正。
フロア図アップロードの検証(Stored XSS対策)
従来はアップロードされたファイルを無検証のまま、クライアント指定の拡張子でディスク保存し
/uploadsから無認証配信していたため、HTML や SVG を置くことで APIオリジン(認証Cookieが載るオリジン)上での Stored XSS が可能だった。image-sizeによるバイナリ内容の判定で PNG / JPEG / WebP のみ許可(クライアント申告のファイル名・MIMEは信用しない)400 Unsupported image formatで拒否(従来は判定失敗を握り潰して保存を続行していた)planImageNameは従来どおり元ファイル名を保持image-sizeで検出されるがスクリプトを含められるため意図的に除外多層防御・フェイルセーフ
/uploads配信にX-Content-Type-Options: nosniffを付与APP_ENV未設定時の既定をlocal→prodに修正(コメントの「未設定は安全側でprod扱い」と実装が矛盾していた。.env.exampleにAPP_ENV=localがあるためローカル開発には影響なし)テスト
pnpm typecheck/ APIテスト72件パスtype: "svg"検出されるがホワイトリスト外で拒否🤖 Generated with Claude Code