Summary
A path traversal vulnerability in the upload_markdown tool of @zereight/mcp-gitlab can allow unauthenticated attackers to read arbitrary files from the server when SSE transport is enabled without authentication. An attacker may use the exposed tool to obtain sensitive environment data, including a GitLab personal access token, potentially enabling full GitLab account takeover.
Affected context
The vulnerability can occur in deployments that enable the MCP server's SSE transport mode with SSE=true while leaving MCP tools accessible without authentication. It is especially relevant to containerized deployments where sensitive credentials are provided through environment variables and the upload_markdown tool accepts file paths without effective confinement to an approved directory.
Exploit preconditions
- Attack surface: Network-reachable MCP SSE endpoint
- Required access: No authentication may be required when the affected SSE configuration is enabled
- Trigger point: Invocation of the
upload_markdowntool with a craftedfile_pathvalue - Why exploitation is possible: The file path is insufficiently restricted, allowing access outside the intended content directory; retrieved files may then be uploaded to a GitLab project
- Additional condition: Sensitive credentials must be present in readable server files or environment-backed process data
Why this happens
The underlying bug is improper restriction of user-controlled filesystem paths. The upload_markdown tool uses an unsanitized file_path parameter, allowing path traversal beyond the intended file boundary and causing arbitrary local file disclosure.
This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal. The unauthenticated exposure of the tool increases the reachable attack surface, while storing a GitLab personal access token in process environment data can turn file disclosure into credential compromise.
Potential impact
- An attacker may read sensitive local files from the MCP server
- GitLab personal access tokens may be disclosed
- A stolen token could enable GitLab account or project compromise
- Attackers could modify repositories, pipelines, issues, or other accessible resources
- Exposed credentials could support further lateral movement or supply-chain attacks
General mitigation guidance
Mitigation generally focuses on enforcing authentication and applying strict filesystem boundaries to tool inputs.
Common defensive patterns include:
- Require authentication and authorization for every MCP tool exposed through SSE
- Resolve requested paths and verify that they remain within an explicitly allowed directory
- Prefer file identifiers or server-managed objects over raw client-supplied filesystem paths
- Reject traversal components, symbolic-link escapes, absolute paths, and unexpected path encodings
- Avoid exposing process environment files and keep access tokens outside broadly readable runtime locations where practical
- Use narrowly scoped GitLab tokens with minimum required permissions and short lifetimes
- Run the service with a dedicated low-privilege identity and a restricted, preferably read-only filesystem
- Apply network access controls so the MCP endpoint is not unnecessarily reachable
How teams detect issues like this
Organizations can look for:
- Static analysis findings involving filesystem APIs that consume unsanitized tool or request parameters
- Code review signals such as raw path concatenation, missing canonicalization, and absent containment checks
- MCP tool definitions that expose file reads or uploads without authentication and authorization requirements
- Runtime logs showing unauthenticated SSE tool calls, traversal-like path components, or unexpected file access
- Network monitoring for exposure of MCP endpoints beyond trusted administrative networks
- Secret-scanning and policy checks for overly broad GitLab token scopes or credentials exposed through environment variables
Automated application-security and dependency-review tools may help identify related patterns, but they should complement targeted review of tool authorization and filesystem boundaries.

