langchain-ai/deepagents · error · ValueError
Permission path must not contain '..': {path!r}
Error message
Permission path must not contain '..': {path!r} What it means
FilesystemPermission patterns must not contain '..' path segments; parent-directory traversal would make permission rules ambiguous or let rules escape their intended tree. Violating patterns raise this ValueError in __post_init__.
Source
Thrown at libs/deepagents/deepagents/middleware/filesystem.py:417
Best paired with patterns that have a literal leading anchor (e.g.,
`/secrets/**`, `/projects/*/secrets/**`). Bulk tools
(`ls`/`glob`/`grep`) fire the interrupt based on whether their
search subtree could overlap the rule's anchored prefix, so a fully
unanchored pattern (`/**/secrets`) collapses to `/` and
conservatively over-fires for any bulk call.
"""
def __post_init__(self) -> None:
"""Validate permission path patterns."""
for path in self.paths:
if not path.startswith("/"):
msg = f"Permission path must start with '/': {path!r}"
raise ValueError(msg)
parts = PurePosixPath(path.replace("\\", "/")).parts
if ".." in parts:
msg = f"Permission path must not contain '..': {path!r}"
raise ValueError(msg)
if "~" in parts:
msg = f"Permission path must not contain '~': {path!r}"
raise NotImplementedError(msg)
def _check_fs_permission(
rules: list[FilesystemPermission],
operation: FilesystemOperation,
path: str,
) -> Literal["allow", "deny", "interrupt"]:
for rule in rules:
if operation not in rule.operations:
continue
if any(wcglob.globmatch(path, pattern, flags=_FS_WCMATCH_FLAGS) for pattern in rule.paths):
return rule.mode
return "allow"
View on GitHub (pinned to a1af029e6e)
Solutions
- Remove '..' by normalizing/resolving the path (os.path.normpath or posixpath.normpath) before building the pattern
- Express the intended target directly without traversal segments
- Sanitize user input to reject traversal attempts early
Example fix
// before FilesystemPermission(paths=["/project/../secrets"]) // after FilesystemPermission(paths=["/secrets"])
Defensive patterns
Strategy: validation
Validate before calling
import posixpath
def ensure_no_dotdot(p: str) -> str:
normalized = posixpath.normpath(p)
if ".." in posixpath.normpath(p).split("/"):
raise ValueError(f"permission path must not contain '..': {p!r}")
return normalized Try / catch
try:
perm = FilesystemPermission(paths=paths)
except ValueError as e:
logger.error("traversal in permission pattern: %s", e)
raise Prevention
- Normalize with posixpath.normpath before creating permissions
- Never concatenate untrusted fragments into permission patterns
- Treat '..' in config as a security signal, not just a validation failure
When it happens
Trigger: Constructing FilesystemPermission with a pattern like '/a/../etc' or '/..' — after converting backslashes, '..' appears in PurePosixPath parts.
Common situations: Concatenating user-supplied path fragments without normalization; porting Windows-style relative patterns; generated patterns from templates that inject '..'.
Related errors
- interpreter_ptc='all' exposes every host tool to PTC calls t
- temporary artifact is not a regular file
- Path traversal not allowed
- Permission path must start with '/': {path!r}
- read_file must be included in tools; it is required by Files
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/9af7c23bd4d28d4a.
Report an issue: GitHub.