Repository navigation
fix(sandbox): keep the GitHub token and registry password out of VM scripts - #410
Open
earakely-scale wants to merge 2 commits into
Open
earakely-scale wants to merge 2 commits into
earakely-scale wants to merge 2 commits into
Conversation
…cripts put_from_github wrote the token into a fixed /tmp askpass helper through script text, and every docker login echoed the registry password in its script. Script text is a process argument on the VM host, the operator's machine on the local provider, and `agent-env -v` logs it there. A secret now goes into a file in a mktemp -d folder that is removed on the way out, written over the exec's stdin where the sandbox takes it and through write_host_file otherwise; commands name only the file. The clone reads the token through git's credential store with the operator's own helpers off, and pull_published and the build's push share VmSandbox.docker_login. LocalSandbox gains the stdin exec it lacked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
git runs a credential helper through the shell, so a credentials path with a space (a TMPDIR that has one, on the local provider) split into separate arguments and the clone could not read the token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
@greptileai review |
This branch has not been deployed
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.
Summary
Building an image from GitHub with a token, and logging a VM's Docker in to a registry, put the secret in the text of a
bash -cscript. That text is a process argument on the VM host, and on thelocalprovider that host is the operator's machine:psor/proc/<pid>/cmdline;agent-env -vlogs every local command in full, so it lands in the debug log too.The GitHub token also sat in
/tmp/git-askpass.sh: a fixed name, created with the default mode, and left behind when the build stopped before its cleanup. Another local account could create that file first and keep what was written into it.Now a secret goes into a file in a folder made for it, and only the file's path appears in any command:
VmSandbox.secret_dir(): amktemp -dfolder (mode 0700, a name nobody can guess), removed on the way out, whether the step worked or not.VmSandbox.write_secret_file(data, path): writes over the exec's stdin when the sandbox takes stdin, and throughwrite_host_fileotherwise.VmSandbox.docker_login(auth):docker login --password-stdin < <file>. Used bypull_publishedand byput_from_github's push.put_from_github's clone:git -c credential.helper= -c 'credential.helper=store --file=<file>' clone .... The first-cturns off the operator's own credential helpers, which otherwise keep a copy of a token git used, in the macOS keychain for example. The askpass helper had that side effect too.GIT_TERMINAL_PROMPT=0now also applies to a tokenised clone, so a bad token fails instead of prompting.LocalSandbox._exec_with_stdin: the one provider change. The local sandbox had no way to take stdin, so a file write on it went through the command line.execand the new method share_spawn, so both rewrite/appand log the same way.How each provider writes the secret file:
write_host_file's base64 over exec, as beforeOn the last row the secret still travels inside an exec command. That happens only on a VM made for the run, which holds the credential anyway, and the provider receives the secret however it's sent. Covering those three would need per-provider code and is left out on purpose.
Testing
test_docker_image_github_clone.pyruns the realgit credential fillandapproveagainst the clone's options. The token comes back from the file, and a credential helper in the user's git config is never handed it. Without-c credential.helper=, that helper gets the token.test_docker_image_github_push.py: the token and the registry password reach the build VM only over stdin, into files under the secret folder. No script holds either. The folder is removed after the clone and after the login, and also when the clone fails.vm_sandbox_test.py:pull_publishedlogs in from a password file inside a removed folder, and a sandbox with a file API and no stdin writes the secret through that API.local_sandbox_test.py: on a realLocalSandboxwith real subprocesses, a secret written intosecret_dir()reaches its file. The folder is mode 0700 and gone afterwards. The secret appears in no spawned process's arguments and nowhere in the DEBUG log.put_from_githubwith a real GitHub token againstdocker-library/hello-world, then a realdocker loginand push to a localregistry:2.ps -axwwtaken every 50 ms through the build./tmp/git-askpass.shnever existed, and both secret folders were gone afterwards.apt-get install gitline: macOS has noapt-get, soput_from_githubon a Mac's local provider can't run as it is.test_hermes_bridge.py::test_the_event_pipe_is_not_left_open_in_the_server, which reads/proc/self/fd(Linux only).ruff checkis clean.Not in this PR
docker run -e KEY=valuescript text (_container_args,A2AAgent._run_container). On the local provider that's the same process-table and-vlog exposure. It's a separate change.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; the previously reported quoting issue is fixed.Summary
Moves GitHub tokens and registry passwords out of VM script text into temporary files.
No new actionable issues were found in the changes since the previous review.
Reviews (2) · Last reviewed commit: "fix(sandbox): quote the credentials path..." · Reviewed by Greptile