publish-renderer: bubblewrap itself starts with no environment
Astra round 2 on 95c4d475: --clearenv cleared the runner's environment, but bubblewrap's own process, pid 1 in the sandbox, kept the publisher's, readable at /proc/1/environ. bwrap now runs under env -i with a fixed PATH. The test sets a canary in the script's environment and a runner that finds it there reports a valid asset: refused now; without env -i the check passes (caught).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+13
−1
internal/release/renderer_publish_test.go+9 −0scripts/publish-renderer.sh+4 −1
CI cancelled — superseded by a newer push — run details
diff --git a/internal/release/renderer_publish_test.go b/internal/release/renderer_publish_test.go| index 0bbf6fb5..29b3321b 100644 |
| --- a/internal/release/renderer_publish_test.go |
| +++ b/internal/release/renderer_publish_test.go |
| @@ -192,6 +192,15 @@ func TestPublishRendererRefuses(t *testing.T) { |
| // The runner runs with no home, no network and no environment: one |
| // that tries to read the publisher's files or a credential in its |
| // environment finds nothing. |
| + // Nor can it find the publisher's environment through the |
| + // sandbox's first process (/proc/1/environ). |
| + "a runner reading the publisher's environment": {func(r *publishRig) []string { |
| + r.writeRunner() |
| + good, _ := os.ReadFile(filepath.Join(r.kit, "equipo-runner")) |
| + body := strings.Replace(string(good), "printf", "tr '\\0' '\\n' < /proc/1/environ | grep -q '^PUBLISHER_CANARY=leaked$' || exit 1\nprintf", 1) |
| + os.WriteFile(filepath.Join(r.kit, "equipo-runner"), []byte(body), 0o755) |
| + return []string{"PUBLISHER_CANARY=leaked"} |
| + }, nil}, |
| "a runner reading the home directory": {func(r *publishRig) []string { |
| r.writeRunner() |
| good, _ := os.ReadFile(filepath.Join(r.kit, "equipo-runner")) |
diff --git a/scripts/publish-renderer.sh b/scripts/publish-renderer.sh| index af666699..81c69847 100755 |
| --- a/scripts/publish-renderer.sh |
| +++ b/scripts/publish-renderer.sh |
| @@ -59,7 +59,10 @@ sources_sum=$(sum "$kit/SOURCES") |
| # runner. The runner is the Linux amd64 one, so this needs a Linux amd64 |
| # host (docs-t1 is one). |
| isolated() { |
| - bwrap --unshare-all --die-with-parent --new-session --clearenv --setenv PATH /usr/bin:/bin \ |
| + # env -i: bubblewrap's own process (pid 1 in the sandbox, whose |
| + # /proc/1/environ the runner can read) starts with no environment |
| + # either, not only the runner (--clearenv). |
| + env -i PATH=/usr/bin:/bin bwrap --unshare-all --die-with-parent --new-session --clearenv --setenv PATH /usr/bin:/bin \ |
| --ro-bind /usr /usr --ro-bind-try /bin /bin --ro-bind-try /lib /lib --ro-bind-try /lib64 /lib64 \ |
| --proc /proc --dev /dev --tmpfs /tmp --ro-bind "$1" /runner /runner "${@:2}" |
| } |