State/liveness keyed on PID alone is vulnerable to PID reuse
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
先阅读 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#
- 星标
- 835
- 派生
- 90
- 平均合并
- 12 小时 53 分钟
- 30 天内合并 PR
- 44
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 于 94 天前认领,目前没有进行中的 PR。 未关闭
dotnet/dev-proxy#1757 · 1 个 reaction · 已指派 2 人 ·
维护者通常 1 天内回复
-
needs peer review
难度 4/5 3-5 天 新手友好度 52/100
dotnet/dev-proxy#1667 · 1 条评论 ·
维护者通常 1 天内回复
-
needs spec question
难度 5/5 一周以上 新手友好度 30/100
dotnet/dev-proxy#1649 · 1 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
ready-for-agent size:S status:todo
难度 2/5 1-3 小时 新手友好度 82/100
elsa-workflows/elsa-foundation#2830 ·
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
[Bug]: Edit Bar buttons are not localized可能已有人在做 @idumlupinar 今天认领。 未关闭Status: New
难度 2/5 1-3 小时 新手友好度 70/100
dnnsoftware/Dnn.Platform#7565 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 半天 新手友好度 72/100
-
难度 2/5 半天 新手友好度 70/100