ocgo stop can kill wrong process (PID file TOCTOU) #2
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: Critical
stopCmdreads a PID from~/.config/ocgo/ocgo.pid(world-readable 0644) then callsos.FindProcess(pid)followed byp.Kill(). On Unix,os.FindProcessalways succeeds, so a malicious local user can write a fake PID to that file and causeocgo stopto kill an arbitrary process. Even without malice, recycled PIDs can cause the wrong process to be killed.File:
cmd/ocgo/main.go:314-321Fix: Verify the PID belongs to an actual ocgo process (e.g. check
/proc/<pid>/exeorcmdline) before killing. Also restrict PID file permissions to 0600.