Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

State/liveness keyed on PID alone is vulnerable to PID reuse

Abierto
#1,755 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
csharp
Área
cli, devtools

Línea de trabajo

Empieza leyendo DevProxy/State/StateManager.cs, especialmente IsProcessRunning, LoadStateFromFileAsync y GetOrphanedSystemProxyStatesAsync; después inspecciona DevProxy/State/ProxyInstanceState.cs para entender los datos del archivo de estado. Sigue cómo los comandos de instancias desconectadas utilizan la vigencia del PID. Se considera terminado cuando se rechaza el estado obsoleto si se ha reutilizado un PID, mientras las instancias legítimas siguen reconociéndose.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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) returns true for 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 the stop --force fix) 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 in IsProcessRunning compare 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 --force cannot restore the system proxy after a crashed instance). That fix relies on asSystemProxy state 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.
Lenguaje dominante
C#
Estrellas
832
Forks
90
Merge medio
14 h 14 min
PR fusionados (30 d)
45

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotnet/dev-proxy

Todos los issues de dotnet/dev-proxy

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.