Repository navigation
fix(sandbox): fall back to gateway UID:GID when no user is configured (#20979) - #20991
Closed
cluster2600 wants to merge 3 commits into
Closed
cluster2600 wants to merge 3 commits into
cluster2600 wants to merge 3 commits into
Conversation
When `agents.defaults.sandbox.docker.user` is not set, the container runs as root (UID 0) with `--cap-drop ALL` which strips DAC_OVERRIDE. Without DAC_OVERRIDE, root inside the container cannot write to workspace directories owned by the non-root gateway user — the recommended git-based install pattern. This silently breaks Read, Write, Edit and apply_patch file tools for all sandboxed sessions. Fix: in `buildSandboxCreateArgs()`, when `cfg.user` is not explicitly set, fall back to `process.getuid():process.getgid()` on POSIX platforms so the container's effective user always matches the gateway's file ownership. On non-POSIX platforms (Windows, where `process.getuid` is undefined), the behavior is unchanged. Existing behavior is fully preserved when `user` is explicitly configured — the explicit value always takes precedence. Fixes openclaw#20979
cluster2600
force-pushed
the
fix/sandbox-default-user-non-root-gateway-20979
branch
from
February 19, 2026 14:55
bfd500d to
edc7f52
Compare
Contributor
Author
|
Checking failing job. I will investigate. |
This was referenced Feb 21, 2026
6 tasks done
Contributor
|
Closing as AI-assisted stale-fix triage. Linked issue #20979 ("[Bug] Default sandbox config breaks file tools for non-root gateway users (post-#4026)") is currently CLOSED and was closed on 2026-02-22T22:34:02Z with state reason COMPLETED. If the underlying bug is still reproducible on current main, please reopen this PR (or open a new focused fix PR) and reference both #20979 and #20991 for fast re-triage. |
Contributor
|
Closed after AI-assisted stale-fix triage (closed issue duplicate/stale fix). |
cluster2600
deleted the
fix/sandbox-default-user-non-root-gateway-20979
branch
October 19, 2026 13:26
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
Fixes #20979
When
agents.defaults.sandbox.docker.useris not set, the container runs as root (UID 0) with--cap-drop ALLwhich stripsDAC_OVERRIDE. WithoutDAC_OVERRIDE, root inside the container cannot write to workspace directories owned by the non-root gateway user — the recommended git-based install pattern. This silently breaks the Read, Write, Edit, andapply_patchfile tools for all sandboxed sessions.Root Cause
Three default values combine to create a UID mismatch (as detailed in #20979):
user—resolveSandboxDockerConfig()resolvesuserfrom agent or global config with no fallback, so container runs as root (UID 0) when unset.capDrop: ["ALL"]— stripsDAC_OVERRIDEfrom root.--userconditionally omitted —buildSandboxCreateArgs()only passes--userwhencfg.useris truthy.Fix
In
buildSandboxCreateArgs()insrc/agents/sandbox/docker.ts, whencfg.useris not explicitly set, fall back toprocess.getuid():process.getgid()on POSIX platforms so the container's effective user matches the gateway's file ownership:Behavior:
userconfig: unchanged (always takes precedence)--user 1003:1003--user 0:0(same as before — no regression)process.getuid): no--userflag passed (same as before)Tests
Added
src/agents/sandbox/docker.sandbox-create-args.test.tscovering:Workaround (no longer needed)
Users on affected setups can still manually configure:
Greptile Summary
Fixes file tool access issues for non-root gateway users by falling back to the gateway process UID:GID when
agents.defaults.sandbox.docker.useris not configured. The root cause was that containers ran as root with--cap-drop ALL, which strippedDAC_OVERRIDEcapability, preventing write access to workspace directories owned by non-root gateway users.process.getuid():process.getgid()on POSIX platforms inbuildSandboxCreateArgs()Confidence Score: 4/5
Last reviewed commit: 2451865
(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!