Repository navigation
fix(devcontainer): spawn the devcontainer CLI outside the sandbox workspace - #227
Merged
Merged
Conversation
The CLI's node shebang resolves to Bun, which loads bunfig.toml from cwd. Spawning with the cloned workspace as cwd ran the repo's preload on the host, crashing boot and executing untrusted code.
khromov
pushed a commit
that referenced
this pull request
Sep 30, 2026
🤖 I have created a release *beep* *boop* --- ## [0.16.1](codebay-v0.16.0...codebay-v0.16.1) (2026-09-30) ### Bug Fixes * **devcontainer:** spawn the devcontainer CLI outside the sandbox workspace ([#227](#227)) ([4cedf90](4cedf90)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Creating a sandbox from any repo with a root
bunfig.tomlthat declares apreloadfails right after "Starting devcontainer…". Repro: https://github.com/khromov/gpuix-svelte (preload = ["./src/plugin.ts"]):Root cause
devcontainerUpspawned the devcontainer CLI withcwd: workspaceDir. The CLI (devcontainer.js) has a#!/usr/bin/env nodeshebang, and under Bunnoderesolves to Bun. Bun loadsbunfig.tomlfrom the process cwd (not the script's directory), so it ran the cloned repo'spreloadbefore the CLI started.Security: that's host-side code execution. Any repo URL a user sandboxes could run arbitrary code on the host, outside the container, with the manager's privileges — before devcontainer isolation ever applies. Here it just crashed because deps weren't installed; a malicious preload wouldn't.
Fix
devcontainerCwd()(config.server.ts) returnsDATA_DIR(created if missing). I picked it overos.tmpdir()because tmpdir is world-writable, so another local user could plant abunfig.tomlthere.devcontainerUpnow spawns fromdevcontainerCwd().--workspace-folder,--configand--override-configare all absolute already, so behaviour is otherwise unchanged.devcontainer --versionprobe (devcontainerCliAvailable) also spawns fromdevcontainerCwd(), so it doesn't inherit whatever the manager's cwd is.spawnCapturegained an optionalcwd.Audit of the other host spawns: every other
Bun.spawn/spawnCapturerunsgit,gh,docker context, or the browser opener. None of them runs through Bun, and none sets a workspace cwd (git -C <workspace>changes git's directory, not the process cwd).devcontainerUpwas the only spawn with a workspace cwd.Bun has no env var that disables bunfig loading.
--config/-cexists, but only when you invokebundirectly. We launch through the CLI's shebang, so we can't pass it, which is why this uses a cwd fix.Test
devcontainer.isolated.test.ts→devcontainerUp cwd: builds a workspace whosebunfig.tomlpreload throws, stubsBun.spawnto capture the cwddevcontainerUpuses, and checks that the cwd is outside the workspace. It then runs a real Bun script from that cwd and expects success. It also checks the fixture really does break a Bun process started inside the workspace. The test fails onmainand passes here.