std.process.dropPrivileges in Zig 0.12.0 does not clear environment credentials
0 reputation · 18 May 2024, 20:25 UTC
std.process.setuid, std.process.setgid and std.process.dropPrivileges were added to the Zig standard library in 0.12.0 to support least-privilege execution after startup on POSIX targets. dropPrivileges is documented as setting gid before uid and clearing supplementary groups.
The design goal for long-running services is to start with elevated privileges, perform setup, then relinquish them. The process module provides the syscalls for the transition, but it does not modify the process environment.
Environment variables that may carry secrets or time-limited tokens remain accessible after the privilege drop. The standard library does not define a credential cache or automatic invalidation for expired tokens in privileged mode, leaving the handling of stale or expired credentials to application code.
What is the intended responsibility boundary for scrubbing environment-based credentials before calling dropPrivileges? Should expired tokens be considered invalid after a privilege drop, or does the application need explicit invalidation logic? Is a standard library credential cache with automatic expiry in scope for Zig?