Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(security): prevent path traversal bypass via startswith check
andienguyen-ecoligo5c9cb3a208a0
diff --git a/nanobot/agent/tools/filesystem.py b/nanobot/agent/tools/filesystem.pyindex 9c169e4c4..b87da116d 100644--- a/nanobot/agent/tools/filesystem.py+++ b/nanobot/agent/tools/filesystem.py@@ -13,8 +13,11 @@ def _resolve_path(path: str, workspace: Path | None = None, allowed_dir: Path |if not p.is_absolute() and workspace:p = workspace / presolved = p.resolve()- if allowed_dir and not str(resolved).startswith(str(allowed_dir.resolve())):- raise PermissionError(f"Path {path} is outside allowed directory {allowed_dir}")+ if allowed_dir:+ try:+ resolved.relative_to(allowed_dir.resolve())+ except ValueError:+ raise PermissionError(f"Path {path} is outside allowed directory {allowed_dir}")return resolved