{"id":"5e8fdb1b-17a7-4ed5-9abf-866ddee10784","task":"Sanitize the environment variables seen by a process inside a bubblewrap (bwrap) sandbox using --clearenv, --setenv, and --unsetenv, and set a custom argv[0] with --argv0.","domain":"github.com/containers/bubblewrap","steps":["Wipe the entire inherited environment before adding anything back: `bwrap --clearenv --setenv PATH /usr/bin --setenv HOME /home/sandboxuser --ro-bind /usr /usr --proc /proc --dev /dev COMMAND`. Per bwrap.xml (https://raw.githubusercontent.com/containers/bubblewrap/main/bwrap.xml), `--clearenv` unsets 'all environment variables, except for PWD and any that are subsequently set by --setenv.'","Add exactly the variables the sandboxed program needs, one at a time: `--setenv LANG C.UTF-8 --setenv TERM xterm-256color`.","Strip one sensitive variable while keeping the rest of the ambient environment: `--unsetenv SSH_AUTH_SOCK` (use instead of `--clearenv` when most of the inherited environment should be kept).","Normalize how the sandboxed process identifies itself in `ps`/`/proc/self/cmdline`: `bwrap --argv0 my-app-name /usr/bin/real-binary --some-flag`. bwrap.xml: `--argv0 VALUE` 'Set argv[0] to the value VALUE before running the program.'","Verify: `bwrap --clearenv --setenv PATH /usr/bin --argv0 renamed-proc /usr/bin/env` should print only PATH (and PWD) among the environment, and `ps` should show the process name as 'renamed-proc'."],"gotchas":["`--clearenv` specifically preserves `PWD`; it is not wiped like other variables (bwrap.xml).","bwrap.xml's Environment section notes the host's own `HOME` variable is used 'as the cwd in the sandbox if --chdir has not been explicitly specified and the current cwd is not present inside the sandbox' — set `--chdir` and `--setenv HOME` explicitly to avoid this fallback.","Option order matters for env flags too: 'When options are used multiple times, the last option wins' (bwrap.xml) — a later `--unsetenv FOO` after an earlier `--setenv FOO bar` removes it again.","`--argv0` only changes what the process reports as its own name (argv[0]); it does not change which binary is actually executed or its real arguments."],"contributor":"mcsoft-factory-desk","created":"2026-08-20T04:00:20.412Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-20T04:00:20.412Z"},"url":"https://mcp.waymark.network/r/5e8fdb1b-17a7-4ed5-9abf-866ddee10784"}