[PID1 REVIEW] Environment sanitization insufficient -- PID1 env leaks to all children #35
Loading…
Add table
Add a link
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?
Context
From a deep architectural review of my_init as PID1 (May 2026).
Problem
The process spawn code in both
spawn_shimmedandspawn_processonly unsets 6 environment variables:Everything else is inherited. A proper PID1 should use
env_clear()and whitelist only essential variables (PATH,HOME,LANG,TERM, and explicitly configured serviceenv).Why This Matters for PID1
PID1's environment is inherited by every child process. If PID1 was started with:
SSH_AUTH_SOCK-- SSH agent socket leaked to all servicesDBUS_SESSION_BUS_ADDRESS-- D-Bus session leakedAWS_SECRET_ACCESS_KEYor other secrets -- leaked to services running as different usersXDG_*variables -- desktop session context leaked into servicesFor services running with
user/groupset for privilege separation, this directly undermines the isolation boundary. A service running asappuser would inherit the root session environment.Additional Missing Variables
The following are commonly recommended to clear for privilege-separated processes:
LD_AUDIT,LD_DYNAMIC_WEAK,LD_PROFILE,LD_BIND_NOW-- linker behaviorGCONV_PATH-- character set conversion pathsHOSTALIASES-- hostname resolution overrideRES_OPTIONS,LOCALDOMAIN-- resolver configurationTMPDIR-- symlink attack vectorIFS-- shell injection in shim modeBASH_ENV,ENV-- shell startup file injectionPERLIO_DEBUG,PYTHONINSPECT-- interpreter debug modesFiles
crates/my_init_server/src/process.rs--sensitive_varsarray (appears twice:spawn_shimmedandspawn_process)Suggested Fix
Replace the blocklist approach with a whitelist:
This is a breaking change for services that rely on inherited env vars, but for a PID1 running privilege-separated services, correctness matters more than convenience.
This is a separate review of the same code path as #19 but with a PID1-specific perspective. The same sensitive_vars blocklist approach is used; PID1's environment leaks to every child process. SSH_AUTH_SOCK, DBUS_SESSION_BUS_ADDRESS, AWS secrets would all be inherited by services.