{"record":{"id":"efe2b4f1c3d04ced","repo":"HKUDS/Vibe-Trading","slug":"unc-paths-are-not-allowed-p-r","errorCode":null,"errorMessage":"UNC paths are not allowed: {p!r}","messagePattern":"UNC paths are not allowed: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/path_utils.py","lineNumber":43,"sourceCode":"_ALLOWED_FILE_ROOTS_ENV = \"VIBE_TRADING_ALLOWED_FILE_ROOTS\"\n_ALLOWED_RUN_ROOTS_ENV = \"VIBE_TRADING_ALLOWED_RUN_ROOTS\"\n\n# MCP clients spawn the server themselves, so a shell export never reaches it.\n_ENV_SCOPE_HINT = (\n    \"Under an MCP client, set it in that client's server env block — \"\n    \"exporting it in a shell does not reach the spawned server.\"\n)\n\n\ndef _describe_roots(roots: list[Path]) -> str:\n    \"\"\"Render allowed roots as an indented list for a rejection message.\"\"\"\n    return \"Allowed roots:\\n\" + \"\\n\".join(f\"  - {root}\" for root in roots)\n\n\ndef _rejects_unc(p: str) -> None:\n    \"\"\"Raise ValueError if `p` starts with a UNC share prefix.\"\"\"\n    if p.startswith(\"\\\\\\\\\") or p.startswith(\"//\"):\n        raise ValueError(f\"UNC paths are not allowed: {p!r}\")\n\n\ndef safe_path(p: str, workdir: Path) -> Path:\n    \"\"\"Resolve `p` under `workdir` and ensure it stays inside.\n\n    Args:\n        p: User-supplied path (relative or absolute).  ``~`` expansion is\n            supported so callers can pass home-relative paths.\n        workdir: Workspace root. `p` must resolve to a location inside.\n\n    Returns:\n        Absolute resolved path inside `workdir`.\n\n    Raises:\n        ValueError: If `p` uses a UNC share, or its resolved form escapes\n            `workdir`. Callers surface this back to the LLM as a tool error.\n    \"\"\"\n    _rejects_unc(p)","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/path_utils.py#L25-L61","documentation":"_rejects_unc rejects any path string starting with a UNC share prefix (backslash or forward-slash double prefix) before any resolution occurs, because UNC shares bypass workspace containment. Used by safe_path, resolve_safe_path, allowed-write-root and import-root helpers.","triggerScenarios":"Passing '\\\\\\\\server\\\\share\\\\file.csv' or '//server/share/file.csv' as file_path, run_dir, or as a configured root (file roots env var).","commonSituations":"Windows network shares, WSL/docker mounts mapped to UNC, or mis-escaped backslashes producing a leading double slash.","solutions":["Copy or symlink the data into a local allowed directory and reference that path","Normalize the path (strip the leading double separator) if it was a plain local path mangled by escaping","Configure allowed roots with local absolute paths only"],"exampleFix":"// before\nfile_path = \"\\\\\\\\fileserver\\\\data\\\\prices.csv\"\n// after\nfile_path = \"/workspace/data/prices.csv\"","handlingStrategy":"validation","validationCode":"def is_unc(p: str) -> bool:\n    return p.startswith(\"\\\\\\\\\") or p.startswith(\"//\")\n\nif is_unc(file_path):\n    raise ArgumentError(\"copy the file into a local allowed directory\")","typeGuard":"def is_local_path(p: str) -> bool:\n    return not (p.startswith(\"\\\\\\\\\") or p.startswith(\"//\"))","tryCatchPattern":"try:\n    safe = safe_path(file_path, workdir)\nexcept ValueError as e:\n    if \"UNC\" in str(e):\n        file_path = copy_to_workspace(file_path); safe = safe_path(file_path, workdir)","preventionTips":["Never reference network shares in tool arguments","Materialize remote data into the workspace first","Beware of escaping that turns '/x' into '//x'"],"tags":["path-validation","windows","unc","security"],"backgroundTag":"path-traversal-rejected","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}