{"record":{"id":"8ee48fe4bb9afb48","repo":"unslothai/unsloth","slug":"system-directories-are-not-browseable","errorCode":null,"errorMessage":"System directories are not browseable.","messagePattern":"System directories are not browseable\\.","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"warning","filePath":"studio/backend/routes/models.py","lineNumber":1714,"sourceCode":"                    status_code = 400,\n                    detail = \"Invalid path\",\n                ) from exc\n            if not _is_path_inside_allowlist(resolved_child, resolved_roots):\n                raise HTTPException(\n                    status_code = 403,\n                    detail = (\n                        \"Path is not in the browseable allowlist. Register it via \"\n                        \"POST /api/models/scan-folders first, or pick a directory \"\n                        \"under your home folder.\"\n                    ),\n                )\n            if contains_sensitive_path_component(str(resolved_child)):\n                raise HTTPException(\n                    status_code = 403,\n                    detail = \"Credential or configuration directories are not browseable.\",\n                )\n            if is_denied_system_path(str(resolved_child)):\n                raise HTTPException(\n                    status_code = 403,\n                    detail = \"System directories are not browseable.\",\n                )\n            current = resolved_child\n\n        if contains_sensitive_path_component(str(current)):\n            raise HTTPException(\n                status_code = 403,\n                detail = \"Credential or configuration directories are not browseable.\",\n            )\n        # Zero-component case: the requested path IS an allowlist root (legacy \"/\" or a drive root).\n        if is_denied_system_path(str(current)):\n            raise HTTPException(\n                status_code = 403,\n                detail = \"System directories are not browseable.\",\n            )\n        if not current.is_dir():\n            raise HTTPException(","sourceCodeStart":1696,"sourceCodeEnd":1732,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/models.py#L1696-L1732","documentation":"Raised as a 403 by _resolve_browse_target when is_denied_system_path() rejects a resolved intermediate component during the walk. It prevents browsing into system directories (e.g. /usr, /bin, /Windows, /Program Files) even if the textual path started under an allowed root — the check runs on the resolved child, so symlinks into system trees are also caught.","triggerScenarios":"GET browse-folders whose path resolves through or into a denied system directory; a symlink under home pointing into /usr or C:\\Windows.","commonSituations":"Symlinked SDKs/toolchains installed under system paths; users trying to browse Program Files for model binaries; legacy layouts where home contains links into /opt.","solutions":["Browse a user-data directory instead; system paths are intentionally excluded from the model browser.","If the data genuinely lives under a system path, copy or move it under home or a registered scan folder.","Remove symlinks that route the walk through denied system directories."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os\n\nDENIED_PREFIXES = ('/usr', '/bin', '/sbin', '/etc', '/var', '/lib', 'C:\\\\Windows', 'C:\\\\Program Files')\n\ndef is_system_path(p: str) -> bool:\n    rp = os.path.realpath(p)\n    return any(rp == d or rp.startswith(d + os.sep) for d in DENIED_PREFIXES)\n\nif is_system_path(browse_path):\n    raise ValueError('system directories are not browseable')","typeGuard":null,"tryCatchPattern":"try:\n    entries = browse(path)\nexcept HTTPError as e:\n    if e.response.status_code == 403 and 'System directories' in e.response.json()['detail']:\n        show_user('System folders cannot be browsed. Pick a folder under your home directory.')\n    else: raise","preventionTips":["Keep models out of system trees; use home or registered scan folders.","Do not symlink from home into /usr, /opt installs, or Program Files.","Hide system roots in the folder picker to prevent dead ends."],"tags":["security","filesystem","system-paths","browse","allowlist"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}