gitlab-mcp
- Type
- MCP server
- Scanned
- Nov 13, 2026
- Version
- 1a1e413aad16
- Files read
- 526
This tool connects AI coding assistants to GitLab so they can view and manage your repositories, merge requests, issues, pipelines, wikis, and settings. Because it grants full edit and delete access by default, hidden instructions inside untrusted GitLab issues or merge requests could trick the AI into reading build secrets or changing and deleting project data, and optional features have bugs that can bypass project limits, hijack logins, or run unsafe commands.
What it can reach
- Network
- Connects to GitLab.com or self-hosted GitLab servers to read and change project data, checks npm for updates at startup unless turned off, and can open local or remote ports for web connections and login callbacks.
- Secrets
- Reads GitLab access tokens, OAuth credentials, cookies, and encryption keys from environment variables, command-line flags, or local files, and can view or edit GitLab build variables when enabled.
- Files
- Reads local workspace files chosen for upload, saves downloaded attachments and build artifacts to a downloads folder, reads optional certificate and masking settings, and writes local token or editor setup files.
- Browser
- Opens your default web browser to the GitLab sign-in page when browser login mode is enabled.
- Shell commands
- Runs a user-configured shell command to fetch an access token only when both OAuth login and a custom token script are explicitly enabled.
Findings
-
MediumCross-site scripting on the remote /downloads proxy can bypass OAuth consent
In remote HTTP modes (SSE or Streamable HTTP), the /downloads/:type endpoint streams upstream files from GitLab and external release-asset redirect targets on the same origin as the MCP server and its OAuth endpoints. Because it copies the upstream Content-Type header verbatim without forcing Content-Disposition: attachment, X-Content-Type-Options: nosniff, or a sandboxing Content-Security-Policy, an uploaded HTML/SVG file or an external release-asset link serving text/html will execute JavaScript on the MCP server origin when a user opens a download_url. On a server using GITLAB_MCP_OAUTH with callback proxy mode, same-origin JavaScript can read the consent_csrf form token and submit POST /authorize with the SameSite=Lax cookie to silently approve an attacker's OAuth client.
Fix: Force Content-Disposition: attachment, set X-Content-Type-Options: nosniff, and add Content-Security-Policy: sandbox (or default-src 'none') on all /downloads/:type responses.
-
MediumShell command injection in compact CLI replay commands
When GITLAB_MCP_COMPACT_RESULTS=true or GITLAB_MCP_COMPACT_TOOLS is enabled, oversized MCP tool replies are replaced with a preview and a suggested CLI command for the user or coding agent to run. buildToolReplayCommand quotes non-trivial arguments and --args-json payloads using JSON.stringify, which wraps strings in double quotes rather than POSIX single quotes. In sh, bash, and zsh, double-quoted strings still evaluate $(...) and backtick command substitutions. If a GitLab repository or merge request contains a filename with $(...) or backticks and the agent requests its diff (such as via get_merge_request_file_diff), running the generated CLI replay command executes arbitrary shell commands on the user's machine.
Fix: Format shell arguments using POSIX single quotes (escaping embedded single quotes as '\'') instead of JSON.stringify.
-
MediumGroup tools such as create_webhook bypass GITLAB_ALLOWED_PROJECT_IDS by default
When GITLAB_ALLOWED_PROJECT_IDS or X-GitLab-Allowed-Project-Ids is set to confine the agent to specific projects, several group-level mutation tools—including create_webhook, update_webhook, delete_webhook, group wiki tools, group milestone tools, and group iteration tools—only check rejectIfStrictProjectScope, which does nothing unless ENABLE_STRICT_PROJECT_SCOPE=true is also set. Because discover_tools is on by default and can activate the webhooks, wiki, milestones, and projects toolsets during a session, a prompt-injected agent restricted to a single sandbox project can activate webhooks and create a group webhook on a parent group to exfiltrate push, note, and confidential issue events across all projects in that group.
Fix: Call rejectIfProjectScopedDeployment on all group-scoped mutation and webhook tools whenever GITLAB_ALLOWED_PROJECT_IDS or a session project scope is active, and add rejectIfStrictProjectScope to remaining unscoped read tools such as get_ci_catalog_resource and namespace/user lookups.
-
LowStateless HTTP mode drops X-GitLab-Allowed-Project-Ids scope when Mcp-Session-Id is omitted or invalid
When OAUTH_STATELESS_MODE=true is used with REMOTE_AUTHORIZATION=true and ENABLE_DYNAMIC_PROJECT_SCOPE=true, project scope restrictions set via X-GitLab-Allowed-Project-Ids at session initialization are sealed into Mcp-Session-Id. However, on non-initialization requests, handleStatelessMcpRequest runs the MCP SDK transport without session enforcement and only checks bindSessionProjectScope when opened is non-null. If a client sends a live auth header on a tools/call request while omitting Mcp-Session-Id or sending a corrupted session ID, opened is null, the sealed project scope is skipped, the tool runs unscoped, and the server mints a new unscoped Mcp-Session-Id.
Fix: Require non-initialization requests in handleStatelessMcpRequest to present a valid sealed Mcp-Session-Id (returning 400 when missing or 404 when invalid/expired) even when live auth headers are present.
-
LowHeader-authenticated /downloads requests bypass server auth tokens, group allowlists, and IP rate limits
When _token is not supplied on GET /downloads/:type, the download proxy accepts any caller-provided Private-Token, JOB-TOKEN, or Authorization header without verifying SSE_AUTH_TOKEN (in SSE mode), STREAMABLE_HTTP_AUTH_TOKEN (in static-token HTTP mode), GITLAB_OAUTH_ALLOWED_GROUPS (in MCP OAuth mode), or Host/Origin headers. In addition, checkDownloadRateLimit keys buckets by the caller's token header rather than client IP and only evicts entries older than 60 seconds, so rotating random header values bypasses rate limiting, grows memory unboundedly, and lets unauthorized network callers reach internal GitLab download endpoints through the MCP server.
Fix: Accept raw GitLab credential headers on /downloads/:type only when REMOTE_AUTHORIZATION=true (or after verifying GITLAB_OAUTH_ALLOWED_GROUPS in MCP OAuth mode), apply Host/Origin checks, and rate-limit by client IP with express-rate-limit.
-
LowGITLAB_TOOL_POLICY_APPROVE can be self-confirmed by the AI agent without user approval
GITLAB_TOOL_POLICY_APPROVE is described in server.json as listing tools that require explicit approval before execution. In MCP mode, however, the server exposes _confirmed: true directly in the tool's JSON input schema and instructs the caller to re-call with _confirmed: true. Because _confirmed is an ordinary model-controlled tool argument rather than an out-of-band human confirmation or MCP elicitation prompt, a prompt-injected agent can supply _confirmed: true itself and run the protected tool without the user's permission.
Fix: Use MCP elicitation (or client-enforced human-in-the-loop approval) rather than an LLM-supplied _confirmed input argument, or clearly document that MCP clients do not block the model from setting _confirmed: true.
-
LowEnabling GITLAB_MASKING_ENABLED loads untrusted .gitlab-mcp-mask.json from the working directory
When GITLAB_MASKING_ENABLED=true is set without GITLAB_MASKING_POLICY_FILE or GITLAB_MASKING_WORKSPACE_DIR, the server automatically loads .gitlab-mcp-mask.json from process.cwd(). When the MCP server is spawned inside a cloned untrusted repository, a repository-supplied .gitlab-mcp-mask.json file can disable the built-in GitLab token and IP masking rules, rewrite tool responses with attacker-chosen replacement strings (enabling prompt injection), or hang the server with catastrophic-backtracking regular expressions.
Fix: Do not auto-load .gitlab-mcp-mask.json from process.cwd() unless an explicit config path is set by the user, and evaluate custom masking regexes with re2js instead of Node's backtracking RegExp engine.
-
LowDefault full permission mode allows prompt injection to activate destructive and secret-reading tools
By default, permission mode is set to full while asking for a Personal Access Token with the api scope, and response masking defaults to false. Although the initial tool list only shows 38 core tools, the always-enabled discover_tools meta-tool carries readOnlyHint: true and lets the AI agent dynamically activate all 23 opt-in toolsets in the session, including CI/CD variable readers (list_project_variables and get_project_variable, also marked readOnlyHint: true) and destructive tools (such as delete_branch, delete_issue, create_webhook, push_files, and merge_merge_request). If the agent reads untrusted text in a public issue, merge request, or CI log, prompt injection can unlock and invoke these tools.
Fix: Default gitlab_permission_mode to readonly or modify, or set GITLAB_PERMISSION_MODE=readonly (with a read_api token) and GITLAB_ALLOWED_PROJECT_IDS when working with untrusted repositories.
-
LowOne-click IDE install links run unpinned @latest code from npm on startup
The one-click Install in Cursor deeplink in README.md and docs/clients/cursor.md (as well as the Install in VS Code badge in docs/clients/vscode.md) decodes to npx -y @zereight/mcp-gitlab@latest with GITLAB_PERSONAL_ACCESS_TOKEN passed in the environment. Because -y skips confirmation and @latest is unpinned, the IDE automatically downloads and runs whatever version is newest on npm at startup, exposing local machines and GitLab tokens if the npm package is ever compromised.
Fix: Pin a release version in generated IDE install links (for example @zereight/mcp-gitlab@2.3.26) or configure the locally installed zereight-mcp-gitlab binary instead.
-
LowLocal Docker examples publish plain HTTP MCP server on all network interfaces
The local Docker commands in README.md (and docker/README.md) pair HOST=0.0.0.0 with -p 3333:3002 while showing client configs for http://localhost:3333. Without a 127.0.0.1 host prefix, Docker binds 0.0.0.0:3333 on the host machine (often bypassing host firewall INPUT rules), exposing the unencrypted HTTP transport and unauthenticated /health and /metrics endpoints to anyone on the local network.
Fix: Bind local Docker port mappings to loopback (-p 127.0.0.1:3333:3002) whenever the container is only meant for local clients on the same computer.
-
LowDocumented --token CLI flag exposes GitLab token in local process list
docs/getting-started/cli-arguments.md:31
The CLI Arguments setup guide (and README.md) instructs users whose MCP clients struggle with environment variables to pass their Personal Access Token via --token=YOUR_GITLAB_TOKEN in args. Command-line arguments of the long-running MCP server process are readable in the OS process table (ps or /proc/<pid>/cmdline) by other users and processes on the same computer, and this guide omits the warning that appears in the standalone CLI docs.
Fix: Warn against --token on shared or multi-process machines in the CLI arguments guide and offer a file-based CLI flag (matching GITLAB_PERSONAL_ACCESS_TOKEN_FILE) or local OAuth instead.
