> ## Documentation Index
> Fetch the complete documentation index at: https://axe-engine.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Path confinement

> How axed resolves every client path inside the root directory, how it treats symlinks and absolute paths, and which paths it refuses with which error.

The rules on this page apply to every file operation, to watches, and to process working directories, in every API axed serves.

## The root

Every path is confined to one directory, set with `axed --root-dir` (default `/workspace`). axed creates it if it is missing. `axectl info` and `System.Info` report it as `root_dir`.

Confinement protects the rest of the sandbox from requests, which matters when axed is more privileged than the code in the sandbox. It does not stop processes you start from reading or writing outside the root; that is the job of the sandbox around axed. See [Security](https://axe-engine.mintlify.site/deploy/security.md).

## How a path resolves

**1. Clean the path**

axed cleans the request path lexically first, like Go's `filepath.Clean`: it drops `.` and empty components and folds `a/../b` into `b`. axed refuses a path that still climbs above the start, such as `../etc`. Because axed cleans the path before it expands symlinks, `link/..` always means the directory that holds `link`.

**2. Strip the root from absolute paths**

axed takes an absolute path under the root, such as `/workspace/src/main.rs`, relative to the root. See [absolute paths](#absolute-paths) for other absolute paths.

**3. Walk one component at a time**

axed opens each component with `openat(O_PATH | O_NOFOLLOW)` against a directory descriptor it already holds, starting from a descriptor of the root. It never reopens the path by name after checking it, so sandboxed code that swaps a directory for a symlink mid-request cannot redirect the operation.

**4. Expand symlinks itself**

When a component is a symlink, axed reads the link and continues resolving its target with the same rules, as described below.

## Symlinks

axed follows a symlink only while its target stays inside the root.

| Link | Example (root `/workspace`) | Result |
| - | - | - |
| Relative, inside the root | `src/lib -> ../lib` | Followed. |
| Absolute, inside the root | `abs -> /workspace/real` | Followed. Trees made by ordinary tools work. |
| Absolute, outside the root | `out -> /etc` | Refused. |
| Relative, climbing out | `up -> ../../etc` | Refused when the walk would go above the root. |
| A chain longer than 40 links, or a loop | `loop1 -> loop2 -> loop1` | Refused. |
| Dangling, inside the root | `new -> /workspace/missing` | Treated as a missing path. |

An absolute link target must start with the root's real path, after resolving any symlinks in `--root-dir` itself.

Operations treat the last component differently:

* **Stat, read, list, write and watch** follow a final symlink. A write through a dangling link that stays inside the root creates its target.
* **Remove, move and copy** act on the link itself, never its target.
* **List** reports a symlink with its target's metadata, never descends into it, and leaves out broken and escaping links.

[Tar extraction](https://axe-engine.mintlify.site/files/transfer.md#extract-a-tar-archive) is stricter: no entry may pass through any symlink, including one the archive created.

## Absolute paths

| Path | Native `Files`, Substrate and MCP files | Agent Sandbox REST | Native, Substrate and MCP process `cwd` | Agent Sandbox process `cwd` |
| - | - | - | - | - |
| `/workspace/src` (under the root) | Taken as `src` | Taken as `src` | Taken as `src` | Taken as `src` |
| `/etc` (outside the root) | Refused with `PERMISSION_DENIED` | Taken as `etc` under the root | Refused with `PERMISSION_DENIED` | Taken as `etc` under the root |

REST paths come from the URL, so `/v1/files/etc/passwd` names `etc/passwd` under the root. An absolute `destination` for `:move` or `:copy`, such as `/etc/moved.txt`, lands at `/workspace/etc/moved.txt`. This follows sandboxd's convention.

Watches follow the file rules of their API. The native `Files.Watch` refuses an absolute path outside the root, and the Agent Sandbox `WatchDir` takes it relative to the root, like the REST API.

## Depth limit

Resolution holds a descriptor for each directory level, so a very deep path could use up the descriptors other operations need. axed refuses paths more than 256 directories deep. Writes that create parents stop at the same depth.

Directory walks, such as recursive list, copy, remove and watch, keep only the current directory open and are not bound by this limit.

## What is refused, and with which error

| Request | Native gRPC | REST |
| - | - | - |
| `..` above the root, or a symlink leading outside it | `PERMISSION_DENIED`: path traversal outside sandbox root is forbidden | 403 `PERMISSION_DENIED` |
| Absolute path outside the root | `PERMISSION_DENIED` | Taken relative to the root |
| More than 40 symlinks, or a loop | `INVALID_ARGUMENT`: too many levels of symbolic links | 400 `INVALID_ARGUMENT` |
| More than 256 levels deep | `INVALID_ARGUMENT`: path is nested more than 256 levels deep | 400 `INVALID_ARGUMENT` |
| A component that is missing, or an intermediate component that is a file | `NOT_FOUND` | 404 `NOT_FOUND` |
| Permission denied by the filesystem while resolving | `PERMISSION_DENIED` | 403 `PERMISSION_DENIED` |

For process working directories, the same cases fail the start: `PERMISSION_DENIED` for an escape, `NOT_FOUND` for a missing directory, and `INVALID_ARGUMENT` for a path that is not a directory.

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
grpcurl -plaintext -d '{"path": "out/passwd"}' localhost:9090 axe.v1.Files/Stat
# Code: PermissionDenied
# Message: path traversal outside sandbox root is forbidden
```

[Errors](https://axe-engine.mintlify.site/reference/errors.md) lists the full mapping, and [Compatibility with sandboxd](https://axe-engine.mintlify.site/reference/sandboxd-compatibility.md) lists where these rules differ from sandboxd.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.