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
base: main
Are you sure you want to change the base?
Changes from all commits
f9c19c7
e0bb5d2
1dd20cd
1cd6c84
4794c90
1d38b40
cbc285d
c1385e9
8cefa58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 a command whose literal text names a path outside the project: arguments (including `--opt=/x`, `-o/x` and `key=/x` values), a program run by path, redirection targets and the words after them, heredoc arguments, assignment and array values (`PY=/x`, `A=(/x)`, `export PATH=/x:$PATH`), `for`/`[[ ]]`/`case` words, `cd`/`pushd`/`popd` and `env -C` directories, and literal `sh -c '…'`, `eval "…"`, `env -S` and `find -exec` strings. Each path is resolved in the directory its command runs in and through symlinks, applying `..` after the symlink as the kernel does, so `lnk/s.txt` and `lnk/../s.txt` through an in-project symlink that points outside are caught. It refuses what it cannot follow: a loop or function body that changes directory, more than 32 possible working directories, `pushd +N`, `~-`, another user's `~name`, and `sh -c`/`eval` nested more than three levels deep. Deliberate exceptions: character devices (`/dev/null`), programs in system binary directories run by full path, the pattern or program operand of `grep`/`sed`/`awk`/`rg`, separator values (`cut -d/`, `IFS=/`, `tr` operands), and text below a missing top-level entry (`echo /api/v1`) unless it is given to a parent-creating program such as `mkdir` or `install`. 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, `cd "$dir"`, variables set outside the command), paths a program opens itself (`python -c "open('/etc/hosts')"`, an awk program that reads a file, a script that writes to `/tmp`), heredoc bodies and `CDPATH` lookups 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. P3: This bullet is too long to scan and repeats the full rule list from permissions.md, where the two copies already disagree (the device exemption and the parent-creating program examples differ). Shorten it to the summary and link to Permissions for the complete list of exceptions and limits, so the rule is maintained in one place. 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. | ||||||
|
|
||||||
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.
Minor, not a blocker (docs; safe once behaviour settles): the docs still state forms as refused or checked that are not.
This line and
security-faq.md:308say a loop or function body that changes directory is refused, and so is another user's~name. They also sayenv -Sandfind -execstrings are checked. At head,builtin cdin a function,A=(~root/x),env -S sh -c '…'andfind -exec sh -c '…' {} \;all get through (see the inline majors).bash <<< 'head <outside>/s.txt'read the outside file. That is the here-string form of the heredoc-body limit, and it is not listed. Please make both pages match what the guard refuses at merge time.