Repository navigation
fix(tool): apply external_directory: deny to every literal path a bash command names #1646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RaghwendraSingh
wants to merge
4
commits into
main
Choose a base branch
from
fix/bash-external-directory
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f9c19c7
fix(tool): apply `external_directory: deny` to every path a bash comm…
RaghwendraSingh e0bb5d2
Merge remote-tracking branch 'origin/main' into fix/bash-external-dir…
RaghwendraSingh 1dd20cd
fix(tool): bash `external_directory: deny` guard v2 — per-command cwd…
RaghwendraSingh 1cd6c84
docs: describe the bash `external_directory: deny` guard and its limits
RaghwendraSingh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -305,6 +305,7 @@ Altimate Code includes several layers of protection to keep the agent within you | |||||
| - **Path traversal blocking.** Paths containing `../` sequences that would escape the project are rejected with an "Access denied" error. | ||||||
| - **Sensitive file protection.** Writing to credential files (`.env`, `.ssh/`, `.aws/`, private keys) triggers a confirmation prompt, even inside the project. See [below](#why-am-i-being-prompted-to-edit-env-files) for details. | ||||||
| - **Bash command analysis.** The bash tool parses commands with tree-sitter to detect file operations (`rm`, `cp`, `mv`, etc.) targeting paths outside your project, and prompts for permission. | ||||||
| - **Bash path guard under `external_directory: "deny"`.** With the default (`"ask"`) or `"allow"`, the bash tool checks only the file operations above. When `external_directory` is `"deny"` for `*`, it also refuses any command whose text names a path outside the project: arguments (including `--opt=/x`, `-o/x` and `key=/x` values), a program run by path, redirection targets, assignment values (`PY=/x`, `export PATH=/x:$PATH`), `for`/`[[ ]]`/`case` words, `cd`/`pushd` targets, and literal `sh -c '…'`/`eval "…"` strings. Each path is resolved in the directory its command runs in and through symlinks, so a symlink inside the project that points outside is caught. Directories allowed in `external_directory` (and the tool-output directory) stay usable. Under a `"*": "deny"` rule, skill and reference directories and the CLI temp directory lose their default allow unless you allow them again, so bundled skill scripts that live there are refused too. This is a guard rail over literal command text, not a sandbox: paths built at run time (`$HOME/x`, `$(pwd)/..`, globs, variables set outside the command), paths a program opens itself (`python -c "open('/etc/hosts')"`, a script that writes to `/tmp`), heredoc bodies and shells nested more than three levels deep are not seen. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The docs say deeply nested shells are "not seen", but the guard refuses them. A command with Prompt for AI agents
Suggested change
|
||||||
| - **Non-git project safety.** For projects outside a git repository, the boundary is strictly the working directory (not the entire filesystem). | ||||||
|
|
||||||
| These protections operate at the application level. For additional isolation, you can run Altimate Code inside a Docker container or VM. | ||||||
|
|
||||||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The new paragraph lists only skill directories and the CLI temp directory as losing their default allow under
"*": "deny". Reference directories are in the same default allow list and are also affected, so name them here too.Prompt for AI agents
+With
external_directory: "deny", the bash tool refuses any command whose literal text names a path outside the project (arguments and option values, programs run by path, redirections, assignment values,cd/pushdtargets and literalsh -c/evalstrings), resolved through symlinks and in the directory each command runs in. Directories you allow underexternal_directorykeep working. A"*": "deny"also removes the default allow for skill directories and the CLI temp directory, so bundled skill scripts stored there are refused unless you allow those directories again.+
+This is a guard rail, not a sandbox. It sees only literal command text: paths built at run time (
$HOME/x,$(pwd)/.., globs) and files a program opens on its own (python -c "open('/etc/hosts')", a script that writes to/tmp) are not checked. Use a container or VM when you need isolation.</file context>