{"record":{"id":"99a50e27022e22ea","repo":"unslothai/unsloth","slug":"device-and-virtual-filesystem-paths-are-not-suppor","errorCode":null,"errorMessage":"Device and virtual filesystem paths are not supported.","messagePattern":"Device and virtual filesystem paths are not supported\\.","errorType":"exception","errorClass":"NativePathLeaseError","httpStatus":400,"severity":"error","filePath":"studio/backend/utils/native_path_leases.py","lineNumber":413,"sourceCode":"        _NATIVE_PATH_REDACTIONS.append(path)\n        del _NATIVE_PATH_REDACTIONS[:-_MAX_NATIVE_PATH_REDACTIONS]\n\n\ndef _reject_network_or_device_path(path: Path) -> None:\n    text = str(path)\n    if os.name == \"nt\":\n        normalized = text.replace(\"/\", \"\\\\\").lower()\n        if normalized.startswith(\"\\\\\\\\?\\\\\"):\n            rest = normalized[4:]\n            is_local_drive = len(rest) >= 3 and rest[0].isalpha() and rest[1:3] == \":\\\\\"\n            if not is_local_drive:\n                raise NativePathLeaseError(\"Network paths are not supported for native grants.\")\n        elif normalized.startswith(\"\\\\\\\\\"):\n            raise NativePathLeaseError(\"Network paths are not supported for native grants.\")\n    if os.name != \"nt\":\n        for root in (\"/dev\", \"/proc\", \"/sys\"):\n            if path.is_relative_to(root):\n                raise NativePathLeaseError(\"Device and virtual filesystem paths are not supported.\")\n    if \"\\x00\" in text:\n        raise NativePathLeaseError(\"Native path contains invalid characters.\")\n\n\ndef _b64decode(value: str) -> bytes:\n    try:\n        padding = \"=\" * (-len(value) % 4)\n        return base64.urlsafe_b64decode((value + padding).encode(\"ascii\"))\n    except (UnicodeEncodeError, binascii.Error, ValueError) as exc:\n        raise NativePathLeaseError(\"Native path grant has an invalid format.\") from exc\n\n\ndef _same_native_path(resolved: Path, signed: Path) -> bool:\n    try:\n        return resolved.samefile(signed)\n    except OSError:\n        return os.path.normcase(str(resolved)) == os.path.normcase(str(signed))\n","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/native_path_leases.py#L395-L431","documentation":"On non-Windows platforms, the granted path lives under /dev, /proc, or /sys, which _reject_network_or_device_path() rejects. These are device nodes and virtual (kernel synthesized) filesystems whose stat results, sizes, and identities do not behave like real files, so leasing them is unsafe and meaningless. The check uses Path.is_relative_to against the three roots.","triggerScenarios":"verify_native_path_lease() on Linux/macOS with canonical_path under the three roots: selecting /dev/zero or a serial device as a 'file'; /proc/self/fd/... descriptors; /sys/... config pseudo-files; a fuzz test or path input box that accepted /dev entries.","commonSituations":"Manual path entry instead of the picker allowing /dev paths; scripts pointing at device nodes; symlinks resolved into /proc (e.g. /proc/self/fd/N) after resolve(strict=True); users trying to read GPU/disk device nodes directly.","solutions":["Select a regular file on a real filesystem (ext4/apfs/tmpfs-backed home dir) instead of /dev, /proc, or /sys.","If you need device content (e.g. disk image), create a file copy first (dd to a file) and select that.","If the picker allowed choosing these, file a bug to filter those roots in the file dialog.","Check whether a symlink resolved into /proc (fd targets) and re-select the underlying real file."],"exampleFix":"# before\nselected: /proc/self/fd/42 -> resolves under /proc -> rejected\n\n# after\n$ cp /target/of/fd42 ~/model.gguf   # materialize real file\nselect ~/model.gguf","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\nREJECTED_ROOTS = ('/dev', '/proc', '/sys')\n\ndef is_supported_native_path(path: str) -> bool:\n    p = Path(path)\n    return not any(p.is_relative_to(root) for root in REJECTED_ROOTS)","typeGuard":"from pathlib import Path\n\ndef is_real_filesystem_path(path: str) -> bool:\n    p = Path(path)\n    return p.is_absolute() and not any(\n        p.is_relative_to(root) for root in ('/dev', '/proc', '/sys')\n    )","tryCatchPattern":"try:\n    grant = verify_native_path_lease(lease, operation='read')\nexcept NativePathLeaseError as exc:\n    if 'Device and virtual filesystem' in str(exc):\n        return respond(400, 'Select a real file on disk; /dev, /proc and /sys are unsupported.')\n    raise","preventionTips":["Constrain file dialogs to user directories, excluding /dev, /proc, /sys.","Materialize device/pipe content into a regular file before selection.","Resolve symlinks client-side and warn when a target lands under a virtual root."],"tags":["native-path-lease","linux","device-file","procfs","security"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}