Harden gh CLI tool sandbox boundary against host file access - #1514
Open
daiv-agent[bot] wants to merge 1 commit into
Open
Harden gh CLI tool sandbox boundary against host file access#1514daiv-agent[bot] wants to merge 1 commit into
daiv-agent[bot] wants to merge 1 commit into
Conversation
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.
The
ghCLI tool runs in the DAIV worker process, not the sandbox, so file-operand actions and host-path arguments were a sandbox-boundary escape:gh release upload <tag> /run/secrets/xcould exfiltrate host files andgh run download -D /home/daiv/...could write attacker-influenced artifacts to arbitrary host paths. This change closes those holes at the allowlist, argument-validation, and subprocess-execution layers.Key Changes:
downloadfrom therunallowlist and restrictedreleasetolist/viewonly (droppingdownload,edit,upload), blocking all file-operand actions that read or write host files.--body-file(both--body-file <path>and--body-file=<path>forms) to_gh_has_disallowed_cli_flags, preventing issue/PR bodies from being populated from host files._gh_has_path_traversal_args, which rejects any argument that is an absolute path or contains a..path segment, while leaving non-path values like a bare..(jq recursive descent) or tags such asv1..2untouched.ghsubprocesscwdto a freshtempfile.mkdtemp(prefix="gh-cli-")directory, cleaned up viashutil.rmtree(..., ignore_errors=True)in afinallyblock — defense in depth so any residual file operand resolves only inside the throwaway dir.GITHUB_TOOL_DESCRIPTIONschema to document the--body-file, absolute-path, and..restrictions.TestGitHubToolSandboxBoundarycovering rejection ofrelease upload/download/edit,run download,--body-fileexfiltration, absolute-path and..arguments, tempdir pinning/cleanup, and that allowed read-only commands still execute.💡 Instructions for the reviewer: