State/liveness keyed on PID alone is vulnerable to PID reuse
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず DevProxy/State/StateManager.cs を読み、特に IsProcessRunning、LoadStateFromFileAsync、GetOrphanedSystemProxyStatesAsync を確認してから、DevProxy/State/ProxyInstanceState.cs を調べて状態ファイルのデータを理解します。切り離されたインスタンスのコマンドが PID の生存性をどのように使用しているかを追跡します。PID が再利用された場合に古い状態が拒否され、正当なインスタンスが引き続き認識されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description
Dev Proxy tracks detached instances by PID alone (state-<pid>.json), and StateManager determines whether an instance is "alive" purely by checking whether a process with that PID currently exists (StateManager.IsProcessRunning(int pid) → Process.GetProcessById).
Operating systems recycle PIDs. After an instance exits (cleanly or via crash), its PID number can be reassigned to a completely unrelated process. When that happens:
IsProcessRunning(pid)returnstruefor the stale state record, so Dev Proxy believes its old instance is still alive.- Commands that key on liveness (
stop,status,LoadAllStatesAsync,FindSystemProxyInstanceAsync, and the crash-recovery / orphaned-system-proxy reconciliation added in thestop --forcefix) can act on — or refuse to act on — the wrong process.
This is a pre-existing, low-probability correctness issue in the whole detached-instance design; it is independent of any single command.
Suggested fix
Store additional identity beyond the PID in the state file and verify it before treating a PID as "our" live instance. Options:
- Persist the process start time (
Process.StartTime) alongside the PID, and inIsProcessRunningcompare the running process's start time to the recorded value — a mismatch means the PID was reused and the record is stale. - Optionally also persist the process name / a Dev Proxy marker as a secondary check.
Process.StartTime is available cross-platform in .NET and is the standard, low-cost way to disambiguate PID reuse.
Notes
- Found while implementing the fix for #1731 (
devproxy stop --forcecannot restore the system proxy after a crashed instance). That fix relies onasSystemProxystate records to reconcile orphaned system-proxy registrations; PID-reuse hardening would make that reconciliation (and all liveness checks) more robust but is intentionally out of scope for that change. - Affected code:
DevProxy/State/StateManager.cs(IsProcessRunning,LoadStateFromFileAsync,GetOrphanedSystemProxyStatesAsync),DevProxy/State/ProxyInstanceState.cs.
- 主要言語
- C#
- スター
- 832
- フォーク
- 90
- 平均マージ
- 14時間 14分
- マージ済み PR(30日)
- 45
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/dev-proxy のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
MockStdioResponsePlugin: @stdin.body.id placeholder fails to resolve when messages arrive back-to-back after an id-less message再び着手できるかも @garrytrinder が 90 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
dotnet/dev-proxy#1757 · リアクション 1 件 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
-
needs peer review
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
dotnet/dev-proxy#1667 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs spec question
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
dotnet/dev-proxy#1649 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
dotnet/dev-proxy の issue をすべて見る
似ている issue
-
Bug: Hidden loading rings keep the compositor running, so Files uses 7-94% of a CPU core while idleオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
files-community/Files#19026 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Physgun SFX Spamオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
SubtitleEdit/subtitleedit#15946 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
BHoM/Civil3D_Toolkit#118 ·
-
Reason-phrase table has misspelled entries (`Unathorized`, `Switching Protcols`, `Multiple Choises`)オープンbug severity:low
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100