Summary
A server-side request forgery vulnerability in @zereight/mcp-gitlab allows a caller to redirect outbound GitLab API requests to an arbitrary URL when dynamic API URLs are enabled. Because the server includes the victim's Private-Token in those requests, an attacker-controlled endpoint may receive the token.
Affected context
The issue occurs in deployments of @zereight/mcp-gitlab that enable ENABLE_DYNAMIC_API_URL=true and expose the server's HTTP transport to callers. In this configuration, the X-GitLab-API-URL request header can influence the destination used for GitLab API calls. A well-formed URL is accepted without restricting its scheme, hostname, or network location, allowing requests to reach destinations outside the intended GitLab service.
Exploit preconditions
- Attack surface: The server's reachable HTTP transport
- Required access: Ability to submit requests and set the
X-GitLab-API-URLheader - Trigger point: A subsequent GitLab API operation that performs an outbound fetch
- Why exploitation is possible: URL syntax validation does not establish that the destination is trusted, while the server attaches the configured
Private-Tokento the redirected request
Why this happens
The vulnerability results from treating a caller-controlled URL as a trusted API endpoint. Although the value is parsed to confirm that it is well-formed, the implementation does not enforce an allowlist or hostname restriction before using it for authenticated outbound requests. This maps to CWE-918, Server-Side Request Forgery, because attacker-influenced input controls a server-side request destination and can cause sensitive authentication material to be sent to an unintended host.
Potential impact
- An attacker may obtain the victim's GitLab Private-Token.
- Unauthorized parties could use the exposed token to access GitLab resources within its permissions.
- The server may be abused to send authenticated requests to attacker-controlled or otherwise unintended destinations.
- Internal services or cloud metadata endpoints could be exposed if reachable from the server's network.
General mitigation guidance
Mitigation generally focuses on removing caller control over authenticated
API destinations and reducing the trust granted to dynamic URL settings.
Common defensive patterns include:
- Disable dynamic API URL selection unless it is required.
- Permit only explicitly configured GitLab hosts and approved URL schemes.
- Resolve and validate destinations against an allowlist before each outbound request.
- Prevent redirects from escaping the approved destination or reusing credentials across hosts.
- Keep authentication tokens scoped to the minimum required permissions and avoid forwarding them to untrusted endpoints.
- Apply egress network controls that restrict access to approved services.
- Treat request headers as untrusted input and enforce authorization at the HTTP transport boundary.
How teams detect issues like this
Organizations can identify similar risks through:
- Static analysis for request headers or user input flowing into URL, HTTP client, or fetch APIs.
- Code review checks for dynamic endpoint configuration without hostname, scheme, or network-range validation.
- Tests confirming that authenticated requests reject unapproved hosts, local addresses, metadata endpoints, and unexpected redirects.
- Runtime logging and alerting for outbound requests whose destinations differ from the configured GitLab service.
- Policy enforcement requiring explicit egress allowlists for services that handle API credentials.
- Automated security review tools that flag SSRF data flows and credential forwarding across host boundaries.

