fix(sandbox): allow mkdirp safety checks on existing directory targets#28863
fix(sandbox): allow mkdirp safety checks on existing directory targets#28863Sid-Qin wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Sandbox mkdirp validated target paths with file-open boundary checks that expect regular files. When the target directory already existed, validation returned non-file and mkdirp failed before execution, even though the path was inside writable workspace mounts. Allow non-file validation outcomes for mkdirp safety checks while keeping canonical mount-root and writable checks intact. Closes openclaw#28745
Greptile SummaryThis PR fixes a bug where Key changes:
Security preserved:
The only validation skipped is the file-open check from Confidence Score: 5/5
Last reviewed commit: 6ae9962 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ae996295b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const allowedNonFile = guarded.reason === "validation" && options.allowNonFileTarget === true; | ||
| if (!allowedMissing && !allowedNonFile) { |
There was a problem hiding this comment.
Restrict mkdirp non-file bypass to directory targets
allowNonFileTarget currently accepts all validation failures from openBoundaryFile, but validation also includes boundary/alias violations from resolveBoundaryPath (not just “target is an existing directory”); as a result, mkdirp can now proceed after symlink-escape validation failures and only rely on later container-path checks, which changes the previous host-boundary behavior for alias paths. This should be narrowed so mkdirp ignores validation only when the target is a safe pre-existing directory, rather than blanket-allowing every validation error.
Useful? React with 👍 / 👎.
|
Thanks for the PR! Multiple PRs address the same sandbox mkdirp safety check (#28863, #30521, #31478). Keeping #30521 which has the most refined approach. Closing this one to reduce noise. This is an AI-assisted triage review. If we got this wrong, feel free to reopen or start a new PR — happy to revisit. |
Summary
writefails whileeditworks on same file path).src/agents/sandbox/fs-bridge.ts, addedallowNonFileTargetpath-safety option and enabled it formkdirp.assertPathSafetynow allowsvalidationfailures for this specific mode while still enforcing canonical mount containment and writable mount checks.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
mkdir -pstyle operations inside sandbox no longer fail on already-existing valid workspace directories.Security Impact (required)
NoNoNoNoNoRepro + Verification
Environment
Steps
memory/state).mkdirpon the same path.Expected
Actual
Evidence
Automated checks passed:
pnpm -C /Users/sidqin/Desktop/openclaw-contrib exec vitest run src/agents/sandbox/fs-bridge.test.tspnpm -C /Users/sidqin/Desktop/openclaw-contrib exec tsc --noEmit --pretty falseAdded regression test:
allows mkdirp on an already-existing directory inside workspaceinsrc/agents/sandbox/fs-bridge.test.tsHuman Verification (required)
Compatibility / Migration
YesNoNoFailure Recovery (if this breaks)
src/agents/sandbox/fs-bridge.ts,src/agents/sandbox/fs-bridge.test.tsRisks and Mitigations
Low risk. Relaxation is scoped to
mkdirppath precheck only, and canonical mount + writable checks still run for every call.