Miggo Logo

GHSA-xh92-rqrq-227v: Mastra Docs MCP Server `@mastra/mcp-docs-server` Leads to Information Exposure

6.5

CVSS Score
3.1

Basic Information

CVE ID
-
EPSS Score
-
Published
9/24/2025
Updated
9/24/2025
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
@mastra/mcp-docs-servernpm<= 0.13.80.17.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability is a classic directory traversal caused by a logical flaw in the docsTool.execute function. The readMdxContent function correctly identifies and flags path traversal attempts. However, the vulnerable version of the docsTool.execute function fails to check the return signal from readMdxContent properly. It treats a security violation the same as a regular 'file not found' error.

Consequently, even after a traversal attempt is detected, the execution flow continues, and the malicious path is passed to the findNearestDirectory function. This function, lacking its own validation, proceeds to list the contents of the directory specified in the malicious path, leading to the disclosure of the file system structure.

The fixing commit (7f2b528ba82db512d68832d2f8ad6cbc8bb46cd4) addresses this by modifying readMdxContent to return an explicit isSecurityViolation flag. The docsTool.execute function is then updated to check for this flag and halt execution immediately, preventing the malicious path from ever reaching findNearestDirectory. An engineer seeing this CVE should be aware that any version before the patch is susceptible to an attacker reading arbitrary directory listings on the machine running the @mastra/mcp-docs-server.

Vulnerable functions

docsTool.execute
packages/mcp-docs-server/src/tools/docs.ts
This function contains the core logical flaw. It calls `readMdxContent` to check for a file, but even when `readMdxContent` detects a path traversal attempt and returns `{ found: false }`, this `execute` function proceeds to call `findNearestDirectory` with the un-sanitized, malicious path. This bypasses the security check and leads to directory content disclosure.
findNearestDirectory
packages/mcp-docs-server/src/tools/docs.ts
This function is called by `docsTool.execute` with a user-controlled path that may contain traversal sequences. According to the vulnerability description, this function does not perform its own path validation, and proceeds to list directory contents, leading to information disclosure when a malicious path is provided.
readMdxContent
packages/mcp-docs-server/src/tools/docs.ts
This function contains the security check to detect path traversal. In the vulnerable version, it correctly identifies a traversal attempt but only returns `{ found: false }`. The calling function, `docsTool.execute`, failed to act on this signal, rendering the check ineffective. The patch changes the return value to `{ found: false, isSecurityViolation: true }` to allow the caller to distinguish between a simple 'not found' and a security violation.

WAF Protection Rules

WAF Rule

T** M*str* *o*s M*P S*rv*r p**k*** `@m*str*/m*p-*o*s-s*rv*r` is * s*rv*r **si*n** to provi** *o*um*nt*tion *ont*xt to *I ***nti* work*lows, su** *s t*os* us** in *I-pow*r** I**s. **R*sour**s:** * P**k*** URL: [*ttps://www.npmjs.*om/p**k***/@m*str

Reasoning

T** vuln*r**ility is * *l*ssi* *ir**tory tr*v*rs*l **us** *y * lo*i**l *l*w in t** `*o*sTool.*x**ut*` *un*tion. T** `r***M*x*ont*nt` *un*tion *orr**tly i**nti*i*s *n* *l**s p*t* tr*v*rs*l *tt*mpts. *ow*v*r, t** vuln*r**l* v*rsion o* t** `*o*sTool.*x*