github/copilot-sdk · error · RuntimeError

Unsafe runtime package path

Error message

Unsafe runtime package path: {member_name}

What it means

_hostless_runtime_path maps tar members of the runtime package to safe destination paths. This error is raised immediately when a member name contains a backslash, since backslashes are not valid POSIX separators and could be used to smuggle unsafe paths on Windows.

Solutions

  1. Re-download the package — checksum verification should catch tampering or corruption.
  2. Verify the release's integrity/attestations if this recurs on an official version.
  3. Report the release as malformed if it comes from the official publisher.
  4. Check for a proxy or mirror injecting/replacing the tarball.
Defensive patterns

Strategy: try-catch

Validate before calling

import tarfile
with tarfile.open("pkg.tgz") as t:
    bad = [m.name for m in t.getmembers() if "\\" in m.name]
    if bad:
        raise SystemExit(f"rejecting archive with backslash paths: {bad}")

Try / catch

try:
    ensure_runtime_wrapper()
except RuntimeError as e:
    if "Unsafe runtime package path" in str(e):
        quarantine_download_and_alert()  # treat as tampered package
    else:
        raise

Prevention

When it happens

Trigger: Extracting a runtime release package whose tarball contains a member name with a '\' character (via _materialize_runtime_bundle), e.g. a maliciously crafted or incorrectly built archive.

Common situations: Man-in-the-middle or tampered release packages; a release built on Windows where paths used backslashes; corrupted downloads (mitigated elsewhere by checksum verification).

Understand the failure class

Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/7044f8828ab3c70b. Report an issue: GitHub.

Appendix: source

Thrown at python/copilot/_cli_download.py:276

    "foundry-local-sdk",
    "index.js",
    "LICENSE.md",
    "napi-oop-runtime",
    "npm-loader.js",
    "package.json",
    "preloads",
    "pvrecorder",
    "queries",
    "README.md",
    "sdk",
    "sea-loader.js",
    "webview",
}


def _hostless_runtime_path(member_name: str, runtime_platform: str) -> Path | None:
    if "\\" in member_name:
        raise RuntimeError(f"Unsafe runtime package path: {member_name}")
    parts = PurePosixPath(member_name).parts
    if not parts or parts[0] != "package" or len(parts) < 2:
        return None
    relative = parts[1:]
    top_level = relative[0]
    file_name = relative[-1]
    if (
        top_level in _HOSTLESS_EXCLUDED_TOP_LEVEL
        or (top_level.startswith("tree-sitter") and top_level.endswith(".wasm"))
        or (top_level.startswith("voice-") and top_level.endswith(".js"))
        or file_name == "cli-native.node"
        or "mediaremote-adapter" in relative
        or file_name.startswith("copilot-runtime-bin")
    ):
        return None
    if top_level == "prebuilds":
        if len(relative) < 3 or relative[1] != runtime_platform:
            return None

View on GitHub (pinned to cd8cf15dc3)