Fix: Fallback to workspace when exec cwd is outside allowed directories#828
Merged
Fix: Fallback to workspace when exec cwd is outside allowed directories#828
Conversation
Instead of throwing an error when the LLM passes an invalid cwd (e.g. /home/user), fall back to the workspace path. This allows installed commands like pab, npm, and agent-browser to execute even when the model picks a bad working directory. File read/write/edit path validation remains strict. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9525d6d to
bc03d64
Compare
Merged
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
cwdto the exec tool (e.g./home/user), fall back to the workspace path instead of throwing an access denied errorpab,npm,npx,agent-browserto execute regardless of whatcwdthe model choosesChanges
apps/base/src/tools/exec.ts— ExtractresolveCwd()that triesvalidatePath()and falls back toworkspacePathapps/base/src/tools/exec.test.ts— Add test for fallback behaviorTest plan
cwd: "/home/user"succeeds by falling back to workspace🤖 Generated with Claude Code