Security: path traversal in the SPA static fallback route — arbitrary file read as the running user

オープン 初心者向け
#28 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@phatloi0010 がすでに取り組んでいます。

2026年11月2日 から。

  • #77 @phatloi0010 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend, security

調査の方向性

src/profiles/server/static.py の 27-35 行を読み、static_dir / full_path から FileResponse を構築する保護されていない catch-all を確認してください。修正は .resolve() とプレフィックス包含を追加し、その後 ..%2f パスを送信し、dist dir から逃れるのではなく index.html にフォールスルーすることを期待する回帰テストを追加する必要があります。完了とは、任意のファイル読み取りがなく、テストが通ることを意味します。

索引モデルが issue の本文から書いたものです。

説明

bug security

Summary

src/profiles/server/static.py:27-35 — the hand-rolled SPA catch-all serves any file at static_dir / full_path after only an is_file() check. There is no .resolve() + prefix containment, and uvicorn/starlette percent-decode request paths, so:

GET /..%2f..%2f..%2fetc%2fpasswd

escapes static_dir and is returned via FileResponse. The /assets mount (static.py:22-24, Starlette StaticFiles) is traversal-protected — only the hand-rolled catch-all is vulnerable. Combined with the unauthenticated CORS posture (see companion issue), any webpage (or, on --server-only, any LAN host) can read arbitrary files readable by the user.

Suggested fix

requested = (static_dir / full_path).resolve()
if requested.is_file() and requested.is_relative_to(static_dir.resolve()):
    return FileResponse(requested)

plus a regression test hitting ..%2f paths that must fall through to index.html (404/SPA), not escape the dist dir.

主要言語
Python
スター
1
フォーク
1
平均マージ
4時間 46分
マージ済み PR(30日)
55

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

falbany/ProFiles のほかの issue

falbany/ProFiles の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。