Security: local HTTP API is unauthenticated with wildcard CORS — any webpage can load configs, launch or delete files and read disk

オープン
#26 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

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

調査の方向性

Begin at src/profiles/server/app.py:40-46 to replace wildcard CORS with the UI origin and add Host-header validation. Reuse the instance_token from routes/instance.py:29-39 as a bearer on all /api routes, including routes/config.py and routes/actions.py. Done means every non-instance API requires the token, CORS denies foreign origins, and server binds loopback by default.

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

説明

bug security

Summary

Everything except /api/instance/* is served with no authentication, and CORSMiddleware is configured with allow_origins=["*"] and allow_credentials=True (src/profiles/server/app.py:40-46). With that combination Starlette echoes any requesting origin back with Access-Control-Allow-Credentials: true, so any page open in any browser on the user's machine can send POSTs to http://127.0.0.1:8088/api/... and read the responses. There is no CSRF token, no same-origin check, and no Host header validation anywhere (the only header check in the codebase is the handoff token in routes/instance.py:29-39).

Drive-by chain (no user interaction beyond visiting a webpage while ProFiles runs)

  1. POST /api/config/load-content (src/profiles/server/routes/config.py:160-188) uploads raw YAML content that becomes the live config after schema validation only. Config hooks: entries are arbitrary shell commands (see the companion shell=True issue).
  2. POST /api/actions/launch (src/profiles/server/routes/actions.py:113-134) accepts any directory/filename pair and runs the matching workflow.
  3. POST /api/actions/delete (routes/actions.py:164-176 → src/profiles/core/actions.py:357-406) deletes any file on disk — "confirmation" is client-side only; a drive-by client simply lies.
  4. POST /api/actions/launch-with-args, /open-folder, /open-terminal, /reveal, /hash, /metadata accept absolute paths with no scoping; GET /api/fs/browse (routes/fs.py:33-67) lists any directory on any drive; GET /api/config and GET /api/system leak scan directories, username, hostname and IP.
  5. On --server-only the server binds 0.0.0.0 (src/profiles/app.py:262) — everything above is then reachable by any LAN device with zero auth.

Additionally there is no Host-header check, so DNS rebinding bypasses any CORS-only fix.

Suggested fix

  • Require the existing instance_token (already generated per-instance and used by /api/instance/*) as a bearer token on all /api routes; the web client is served by the same server and can receive it at bootstrap.
  • Set allow_origins to the actual UI origin instead of ["*"] + credentials.
  • Validate the Host header (accept only 127.0.0.1:<port> / localhost:<port>) — this also closes DNS rebinding.
  • Keep the default bind on loopback; if LAN sharing via --server-only stays a feature, gate it behind the token or an explicit opt-in flag.

Severity: HIGH. Compounding factor: a forced config load turns into command execution via the workflow shell=True issue.

主要言語
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 を短くまとめたダイジェスト。