Skip to content
Education & Software

How to Securely Connect Cursor AI Cloud to an On-Premise GitLab Server

In this article

To securely grant Cursor AI cloud services access to an on-premise GitLab instance, establish a secure network path using Zero Trust tunnels, IP allowlisting, or reverse proxies with mutual TLS, and authenticate using fine-grained GitLab Personal Access Tokens with minimal permissions. Enforce Cursor’s Enterprise Privacy Mode to ensure repository code context remains encrypted in transit and excluded from model training.

Understanding the Architecture: Client-Side vs. Cloud-Based Cursor Workflows

Integrating an AI-assisted development tool like Cursor with a self-hosted, on-premise GitLab instance requires a clear understanding of where code parsing and intelligence operations occur. Cursor operates as a modified fork of Visual Studio Code. Its interaction with your codebase generally falls into two distinct operational patterns: local client-side indexing and cloud-assisted deep context processing.

In a standard local setup, the developer’s local workstation acts as the primary bridge. The workstation connects to your internal network via Virtual Private Network (VPN) or Zero Trust Network Access (ZTNA), pulls the repository from the on-premise GitLab server using standard Git protocols (SSH or HTTPS), and performs embeddings and indexing locally. Under this model, the cloud service does not initiate direct network connections back into your private infrastructure.

  • Developer Workstation
    • Cursor AI Editor
      • Local Indexing Engine
      • Git CLI / SSH Client
    • Network Connections:
      • Private Network (VPN / ZTNA) connects to On-Premise GitLab Server (Self-Managed Repository)
      • Public Internet (TLS 1.3) connects to Cursor AI Cloud (AI Model Processing)
  • On-Premise GitLab Server
    • Self-Managed Repository
  • Cursor AI Cloud
    • AI Model Processing

However, leveraging advanced features—such as cloud-based codebase indexing, automated background agents, centralized repository search, or server-side webhook processing—requires Cursor Cloud services to communicate directly with your GitLab API and Git endpoints. Because on-premise GitLab servers usually reside behind strict corporate firewalls, NAT gateways, or air-gapped perimeter controls, granting external cloud access without introducing security vulnerabilities demands a defense-in-depth approach.

Security and Compliance Prerequisites Before Granting Access

Before opening network ingress paths or generating API tokens for third-party cloud services, your security and engineering teams must validate compliance configurations on both the Cursor control plane and your internal GitLab infrastructure.

1. Mandate Cursor Privacy Mode and Enterprise Controls

By default, developers using AI coding assistants must ensure that proprietary code snippets are not stored persistently or used to train third-party Foundation LLMs (such as OpenAI, Anthropic, or custom models).

  • Enforce Privacy Mode across all developer machines via Cursor Enterprise admin settings.
  • Verify that your organization has signed a Data Privacy Agreement (DPA) with Cursor that explicitly prohibits remote data retention and training on your telemetry.
  • Ensure local index caching complies with corporate endpoint detection and response (EDR) and disk encryption mandates (such as BitLocker or FileVault).

2. Implement the Principle of Least Privilege in GitLab

Never use global Administrator access tokens or shared personal accounts to connect external services.

  • Create dedicated GitLab Service Accounts (available in GitLab Self-Managed) specifically designated for automated AI tools.
  • Grant these service accounts read-only privileges (Reporter or Guest roles where appropriate) scoped exclusively to the specific repositories requiring AI indexing.
  • Limit token scope parameters strictly to read_repository and read_api. Avoid broad access scopes like api, write_repository, or sudo.

3. Enable Comprehensive Audit Logging

Ensure that both your perimeter gateways and GitLab instances record all incoming API calls originating from external integration points. Configure your GitLab instance to log token usage, source IP addresses, and repository access events to a central Security Information and Event Management (SIEM) platform.

Key Architectural Approaches for Secure Ingress

Connecting cloud infrastructure to a private on-premise network requires balancing operational convenience against attack surface expansion. Three primary architecture patterns can achieve this securely.

Inbound Access Architecture Comparison:

  1. Approach 1: Zero Trust Tunnel
    • Flow: Cursor Cloud to Cloudflare / Teleport Tunnel to Encrypted Outbound Connection to On-Prem GitLab
    • Details: No open inbound ports; identity & policy validated at edge proxy
  2. Approach 2: mTLS Reverse Proxy
    • Flow: Cursor Cloud to Edge WAF / Reverse Proxy to Mutual TLS Cert Check to On-Prem GitLab
    • Details: Inbound Port 443 open; requires valid client certificate & static IP match
  3. Approach 3: Static IP Firewalling
    • Flow: Cursor Cloud to Enterprise Firewall to IP Allowlist Filtering to On-Prem GitLab
    • Details: Inbound Port 443 open only to verified CIDR blocks

Approach 1: Zero Trust Network Access Tunnels (Recommended)

Zero Trust tunnels (such as Cloudflare Tunnel, Teleport, or AWS Client VPN/Direct Connect integrations) eliminate the need to open public inbound listening ports on your firewall.

An egress-only lightweight daemon (e.g., cloudflared) runs inside your private network adjacent to the GitLab server. The daemon establishes an outbound, encrypted TLS connection to a secure edge proxy network. When Cursor Cloud attempts to contact your designated public hostname (e.g., gitlab-ai-gateway.yourcompany.com), the request passes through the edge proxy, authenticates against predefined service tokens or header policies, and routes down the existing outbound tunnel to your internal GitLab server.

Approach 2: Reverse Proxy with Mutual TLS (mTLS) and WAF

If your network strategy relies on standard ingress reverse proxies (such as Nginx, Traefik, HAProxy, or F5 BIG-IP):

  1. Place a Web Application Firewall (WAF) in your Demilitarized Zone (DMZ).
  2. Configure Mutual TLS (mTLS) on the reverse proxy. This requires the incoming client (Cursor Cloud) to present an X.509 cryptographic certificate signed by your internal or trusted Certificate Authority (CA) before TLS negotiation completes.
  3. Apply rate-limiting rules and path filtering to restrict access strictly to /api/v4/ endpoints necessary for repository synchronization.

Approach 3: Static IP Allowlisting at Perimeter Firewalls

If Cursor Cloud provides dedicated egress IP ranges for enterprise tenants, you can configure your perimeter firewalls (Palo Alto, Fortinet, AWS Security Groups) to allow traffic on port 443 strictly from those specific public IP blocks. Combine IP allowlisting with strict TLS 1.3 encryption requirements and HTTP header inspection to prevent spoofed requests from reaching your internal network.

Step-by-Step Implementation Guide

Follow this practical deployment blueprint to establish a secure link between Cursor Cloud services and your self-managed GitLab instance.

Step 1: Create a Scoped Service Account in GitLab

  1. Log into your on-premise GitLab instance as a Group or Instance Administrator.
  2. Navigate to Admin Area > Users and select New User.
  3. Set the account type to Service Account to prevent manual password logins and bypass corporate SSO enforcement rules.
  4. Assign the user to the target Project or Group with the Reporter role.
  5. Generate a Personal Access Token (PAT) or Resource Access Token for this user with the following explicit scopes:
    • read_api: Grants read access to the GitLab API to resolve repository structures.
    • read_repository: Grants read-only access to download repository archives via Git over HTTP.
  6. Record the generated token securely in your enterprise secrets manager (e.g., HashiCorp Vault or AWS Secrets Manager). Set an explicit expiration date (e.g., 90 days) to enforce credential rotation.

Step 2: Configure the Secure Tunnel Daemon (Cloudflare Tunnel Example)

To expose the internal GitLab API safely without opening raw inbound ports, deploy an outbound tunnel daemon on an internal Linux node:

  1. Install cloudflared on a host with internal network connectivity to https://gitlab.internal.yourcompany.com.
  2. Authenticate the daemon and create a dedicated tunnel:
    cloudflared tunnel create gitlab-cursor-bridge
    
  3. Configure the config.yml routing rules for the tunnel:
    tunnel: 
    credentials-file: /etc/cloudflared/.json
    
    ingress:
      - hostname: gitlab-ai.yourcompany.com
        service: https://gitlab.internal.yourcompany.com
        originRequest:
          originServerName: gitlab.internal.yourcompany.com
          caPool: /etc/ssl/certs/internal-ca.crt
      - service: http_status:404
    
  4. Define Zero Trust Access policies in your edge security console to enforce HTTP header validation or service token verification on all traffic bound for gitlab-ai.yourcompany.com.
  5. Route the public DNS entry gitlab-ai.yourcompany.com to the tunnel target.

Step 3: Configure Connection Settings in Cursor

Once the public routing and authentication boundaries are active:

  1. Open the Cursor IDE settings interface or your Cursor Enterprise Organization Dashboard.
  2. Under Integrations > Custom GitLab / Self-Hosted, enter the external bridge endpoint URL: https://gitlab-ai.yourcompany.com.
  3. Provide the fine-grained Access Token generated in Step 1.
  4. Enable Strict TLS Verification to ensure Cursor rejects any self-signed certificates that cannot be validated through standard CA trust chains.

Integration Architecture Comparison

Evaluating the available connectivity options helps align your architecture choice with corporate risk tolerance, budget, and operational capacity.

Integration Method Security Level Operational Complexity Network Performance Inbound Firewall Ports Required Ideal Enterprise Use Case
Local-First (VPN / ZTNA Client) Highest Low Fast (Local Indexing) None (Outbound User VPN) Highly regulated environments, strict air-gapped policies, zero external ingress allowed.
Zero Trust Tunnel (e.g., Cloudflare Tunnel) Very High Medium Fast to Moderate None (Outbound Egress Only) Modern enterprise teams wanting seamless cloud integration without perimeter firewall changes.
Reverse Proxy with mTLS & WAF High High Very Fast Inbound TCP 443 Organizations with dedicated SecOps teams and existing public DMZ infrastructure.
Static IP Firewall Allowlisting Moderate Low Fast Inbound TCP 443 Simple setups where Cursor Cloud offers dedicated, immutable enterprise egress IP addresses.

Common Pitfalls and Security Risks to Avoid

Deploying cloud-to-premise integrations frequently introduces subtle security misconfigurations. Ensure your implementation avoids these common failure modes:

  • Using Administrator-Level Personal Access Tokens: Using a personal account token with broad access privileges exposes your entire GitLab instance if the credential is compromised. Always restrict tokens to dedicated service accounts with minimal access scopes.
  • Exposing Raw Internal Hostnames to Public DNS: Never point public DNS records directly to internal IP addresses or unencrypted internal endpoints. Use external reverse proxies or application proxies to absorb incoming connections.
  • Disabling TLS Certificate Checks: When testing self-signed certificates on internal GitLab nodes, developers may be tempted to disable SSL verification (GIT_SSL_NO_VERIFY=true). Doing so opens the connection to Man-in-the-Middle (MitM) interception attacks. Always import your organization's internal Root CA certificate into the gateway proxy layer instead.
  • Neglecting Token Rotation: Setting non-expiring tokens violates compliance frameworks like SOC 2, ISO 27001, and PCI-DSS. Automate token rotation routines using the GitLab REST API or HashiCorp Vault.
  • Omitting Client-Side Privacy Mode Enforcement: Securing the network path is useless if developers allow public AI services to retain proprietary code snippets for model training. Enforce privacy controls centrally via enterprise policy management.

Frequently Asked Questions

Does Cursor store my on-premise GitLab source code on its cloud servers?

When Privacy Mode is activated (or when using an Enterprise plan configured for zero data retention), Cursor does not store your underlying source code on disk after processing requests. Context chunks sent to processing endpoints are encrypted in transit via TLS 1.3, processed transiently in memory to generate vectors or completions, and promptly discarded. Confirm these configurations directly within your organization’s signed Data Privacy Agreement (DPA).

Can I run Cursor completely offline or air-gapped with self-hosted LLMs?

Yes. If corporate security policies strictly forbid outbound network connections to external AI endpoints, you can run Cursor locally connected to an internal, self-hosted LLM server (such as an vLLM, Ollama, or LocalAI cluster deployed within your local network infrastructure). In this configuration, both your source code on GitLab and your AI inference pipeline remain within your private security boundary.

What specific GitLab token scopes are required for Cursor integration?

For basic read-only context indexing and code analysis, Cursor requires only the read_repository and read_api scopes. You should explicitly deny access to write_repository, api (full control), sudo, and administrative operations.

How do I verify that my on-premise GitLab server isn't leaking exposed endpoints?

Utilize external vulnerability scanners (such as OWASP ZAP or Nmap) against your public gateway domain to confirm that only authorized API paths (such as /api/v4/) are reachable. Ensure all non-API paths return 403 Forbidden or 404 Not Found status codes to unauthenticated public visitors.

What happens if our corporate policy strictly forbids any inbound cloud indexing?

If inbound cloud traffic is prohibited by regulatory standards (such as HIPAA, FedRAMP High, or ITAR), opt for Local-First Indexing. Developers connect their machines to the internal network via standard corporate VPN or ZTNA, clone code locally to their encrypted workstations, and let the local Cursor client handle indexing locally without opening public ingress paths to the server.

Strategic Blueprint for Enterprise Security Teams

To successfully roll out Cursor AI while protecting your self-hosted GitLab infrastructure, follow this prioritized execution strategy:

  1. Phase 1: Policy & Governance: Update corporate acceptable use policies regarding AI coding assistants. Formally request and execute a Zero Data Retention DPA with Cursor. Enforce Privacy Mode globally across all corporate developer profiles.
  2. Phase 2: Network Isolation: Provision an egress-only Zero Trust tunnel or secure mTLS reverse proxy. Ensure no raw internal IP addresses or administrative ports are exposed to the internet.
  3. Phase 3: Identity & Access Management: Create non-human GitLab Service Accounts with Reporter access level. Issue scoped access tokens bound to explicit 90-day rotation schedules.
  4. Phase 4: Continuous Auditing: Configure your SIEM tool to monitor API request volume, anomalous access patterns, and IP origins hitting your GitLab integration endpoints.

By combining Zero Trust network controls, strict token scoping, and enterprise data privacy rules, you can grant Cursor AI access to your on-premise repositories without compromising your corporate security boundary.