Mintplex-Labs/anything-llm · error · Error
Access denied - path outside allowed directories.
Error message
Access denied - path outside allowed directories.
What it means
Thrown by Filesystem.validatePath() when the requested path, after home-expansion and normalization, does not resolve within any allowed directory. This is the primary sandbox boundary check that confines all filesystem tool access to the configured workspace. The detailed offending path and allowed dirs are logged to the console but not exposed in the error message.
Source
Thrown at server/utils/agents/aibitat/plugins/filesystem/lib.js:429
*/
async validatePath(requestedPath) {
await this.ensureInitialized();
const expandedPath = this.#expandHome(requestedPath);
const absolute = path.isAbsolute(expandedPath)
? path.resolve(expandedPath)
: this.#resolveRelativePathAgainstAllowedDirectories(expandedPath);
const normalizedRequested = this.#normalizePath(absolute);
const isAllowed = this.#isPathWithinAllowedDirectories(
normalizedRequested,
this.#allowedDirectories
);
if (!isAllowed) {
console.log(
`[validatePath] Access denied - path outside allowed directories: ${absolute} not in ${this.#allowedDirectories.join(", ")}`
);
throw new Error(`Access denied - path outside allowed directories.`);
}
try {
const realPath = await fs.realpath(absolute);
const normalizedReal = this.#normalizePath(realPath);
if (
!this.#isPathWithinAllowedDirectories(
normalizedReal,
this.#allowedDirectories
)
) {
console.log(
`[validatePath] Access denied - symlink target outside allowed directories: ${realPath} not in ${this.#allowedDirectories.join(", ")}`
);
throw new Error(
`Access denied - symlink target outside allowed directories.`
);
}View on GitHub (pinned to 526360e320)
Solutions
- Use paths relative to the workspace root, or absolute paths confirmed to be inside an allowed directory.
- Avoid ../ sequences that escape the workspace.
- Check filesystem.getAllowedDirectories() to see what roots are permitted.
- If a legitimate directory is excluded, configure it as an allowed directory before use.
Example fix
// before - absolute path outside workspace
await filesystem.readFileContent("/etc/passwd");
// after - path inside the allowed workspace
await filesystem.readFileContent("workspace/config.txt"); Defensive patterns
Strategy: validation
Validate before calling
// resolve and check against allowed dirs before calling any filesystem tool
function isWithinAllowed(p, allowedDirs) {
const resolved = path.resolve(p);
return allowedDirs.some((d) => resolved === path.resolve(d) || resolved.startsWith(path.resolve(d) + path.sep));
}
if (!isWithinAllowed(requestedPath, filesystem.getAllowedDirectories()))
throw new Error("Path outside workspace"); Try / catch
try {
const valid = await filesystem.validatePath(p);
} catch (e) {
if (e.message.includes("outside allowed directories")) { /* use a workspace-relative path */ }
else throw e;
} Prevention
- Always use workspace-relative paths when calling filesystem tools.
- Avoid ../ sequences that escape the workspace root.
- Check getAllowedDirectories() when unsure which roots are permitted.
When it happens
Trigger: Passing an absolute path outside the workspace (e.g., /etc/passwd), a relative path that resolves outside via ../ traversal, or a path whose normalized form falls outside every allowed directory entry. Any filesystem tool call routes through validatePath first.
Common situations: An absolute path like /tmp/x when only the workspace is allowed; ../ sequences escaping the workspace root; a misconfiguration where allowedDirectories does not include the intended working area.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Access denied - symlink target outside allowed directories.
- Access denied - parent directory outside allowed directories
- Invalid path.
- Invalid path name
- Invalid folder name.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/19b2395317182214.
Report an issue: GitHub.