Mintplex-Labs/anything-llm · error · Error
Access denied - parent directory outside allowed directories
Error message
Access denied - parent directory outside allowed directories.
What it means
Thrown by validatePath() in the ENOENT branch: the requested file does not yet exist, so realpath cannot resolve it. The code instead resolves the parent directory with realpath; if that real parent path is outside the allowed directories, this error fires. It prevents creating new files in locations that escape the sandbox via a symlinked parent.
Source
Thrown at server/utils/agents/aibitat/plugins/filesystem/lib.js:464
);
}
return realPath;
} catch (error) {
if (error.code === "ENOENT") {
const parentDir = path.dirname(absolute);
try {
const realParentPath = await fs.realpath(parentDir);
const normalizedParent = this.#normalizePath(realParentPath);
if (
!this.#isPathWithinAllowedDirectories(
normalizedParent,
this.#allowedDirectories
)
) {
console.log(
`[validatePath] Access denied - parent directory outside allowed directories: ${realParentPath} not in ${this.#allowedDirectories.join(", ")}`
);
throw new Error(
`Access denied - parent directory outside allowed directories.`
);
}
return absolute;
} catch {
throw new Error(`Parent directory does not exist: ${parentDir}`);
}
}
throw error;
}
}
/**
* Gets detailed file statistics.
* @param {string} filePath - Path to the file
* @returns {Promise<Object>} File statistics
*/
async getFileStats(filePath) {View on GitHub (pinned to 526360e320)
Solutions
- Ensure the target parent directory genuinely exists inside an allowed directory (not via an escaping symlink).
- Create the file in a direct subdirectory of the workspace.
- Remove or fix symlinked parent directories before writing into them.
Defensive patterns
Strategy: try-catch
Validate before calling
const fs = require("fs/promises");
async function assertParentInside(p, allowedDirs) {
const parent = path.dirname(path.resolve(p));
try {
const real = await fs.realpath(parent);
if (!allowedDirs.some((d) => real.startsWith(path.resolve(d))))
throw new Error(`Parent ${parent} resolves outside workspace`);
} catch { throw new Error(`Parent ${parent} does not exist`); }
} Try / catch
try { await filesystem.validatePath(p); }
catch (e) {
if (e.message.includes("parent directory outside")) { /* write inside a real workspace dir */ }
else throw e;
} Prevention
- Write new files into directories that genuinely exist inside the workspace.
- Avoid creating files under symlinked directories whose targets escape the sandbox.
- Validate the parent directory's realpath before writing.
When it happens
Trigger: Writing/creating a file whose path does not exist yet, and whose parent directory (resolved to its real target via realpath) lies outside the allowed directories. Typical when the parent is a symlink pointing outside the workspace.
Common situations: Creating a file inside a symlinked directory that points outside the workspace; a nested path where an intermediate directory is an escaping symlink.
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 - path outside allowed directories.
- Cannot copy symbolic link: ${source}. Symlinks are not allow
- Invalid path.
- Invalid path name
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/8a10f10d430b2512.
Report an issue: GitHub.