mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-12 09:52:19 +02:00
fix(runtime): resolve Wave 3-S audit findings (P2-1, P2-2, P2-3)
- P2-1: reject non-process PID values (None, 0, negative integers) in pid_alive without invoking underlying process probe. - P2-2: truthfully represent production external bridge executions as uncontained, external, non-authoritative grants carrying sanitized endpoint metadata. - P2-3: reject writable_extra overlay bindings over protected system roots and their descendants while preserving legitimate scratch destinations.
This commit is contained in:
@@ -94,7 +94,13 @@ def pid_alive(pid: Optional[int]) -> bool:
|
||||
the process it is checking. We instead open the process and read its exit
|
||||
code via the Win32 API.
|
||||
"""
|
||||
if not pid:
|
||||
if pid is None:
|
||||
return False
|
||||
try:
|
||||
pid_int = int(pid)
|
||||
except (TypeError, ValueError):
|
||||
return False
|
||||
if pid_int <= 0:
|
||||
return False
|
||||
if IS_WINDOWS:
|
||||
import ctypes
|
||||
@@ -104,7 +110,7 @@ def pid_alive(pid: Optional[int]) -> bool:
|
||||
STILL_ACTIVE = 259
|
||||
kernel32 = ctypes.windll.kernel32
|
||||
handle = kernel32.OpenProcess(
|
||||
PROCESS_QUERY_LIMITED_INFORMATION, False, int(pid)
|
||||
PROCESS_QUERY_LIMITED_INFORMATION, False, pid_int
|
||||
)
|
||||
if not handle:
|
||||
return kernel32.GetLastError() != 87 # ERROR_INVALID_PARAMETER: PID absent
|
||||
@@ -116,7 +122,7 @@ def pid_alive(pid: Optional[int]) -> bool:
|
||||
finally:
|
||||
kernel32.CloseHandle(handle)
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
os.kill(pid_int, 0)
|
||||
return True
|
||||
except ProcessLookupError:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user