[CRITICAL] Environment sanitization incomplete for privilege-separated services #19
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?
Problem
The process spawn code only unsets 6 environment variables:
LD_PRELOAD,LD_LIBRARY_PATH,PYTHONPATH,NODE_PATH,PERL5LIB,RUBYLIBMany more variables can affect process behavior, especially when running services as different users/groups:
LD_AUDIT-- dynamic linker auditingLD_DYNAMIC_WEAK-- dynamic linker behaviorGCONV_PATH-- character set conversionHOSTALIASES-- hostname resolutionRES_OPTIONS-- resolver configurationTMPDIR-- symlink attack vectorIFS-- shell injection in shim modeBASH_ENV/ENV-- shell startup filesLD_PROFILE/LD_BIND_NOW-- linker behaviorImpact
A service config with malicious environment variables could escalate privileges, inject libraries, or bypass the intended isolation -- especially for services running with
user/groupset for privilege separation.Files
crates/my_init_server/src/process.rs--sensitive_varsarray (appears twice: inspawn_shimmedandspawn_process)Suggested Fix
Clear all environment variables with
env_clear()and only pass through a safe whitelist (PATH, HOME, LANG, TERM, and user-configuredenvfrom the service config). Or use a comprehensive blocklist.Confirmed by code inspection at crates/my_init_server/src/process.rs:194-202 and 297-305. Both spawn_shimmed and spawn_process unset only 6 env vars: LD_PRELOAD, LD_LIBRARY_PATH, PYTHONPATH, NODE_PATH, PERL5LIB, RUBYLIB. Many more dangerous vars are left unchecked: LD_AUDIT, GCONV_PATH, HOSTALIASES, RES_OPTIONS, TMPDIR, IFS, BASH_ENV, among others. A service running with user/group privilege separation inherits the parent's full root session environment, directly undermining the isolation boundary.