Back to Intelligence

GitLab AI Gateway 9.9 Critical Flaw: Command Execution on Self-Hosted Servers — Detection and Remediation Guide

SA
Security Arsenal Team
October 2, 2026
11 min read

GitLab has patched a critical severity vulnerability (CVSS 9.9) in its self-hosted AI Gateway that allows an authenticated user with access to the Duo Agent Platform to execute arbitrary commands on the gateway server under certain conditions. If your organization self-hosts the GitLab AI Gateway, this is a patch-now situation.

Introduction

On the surface, "authenticated user required" sounds like it lowers the stakes. It doesn't — and a 9.9 score from GitLab's own advisory confirms that. The AI Gateway is the connective tissue between your GitLab instance and large language models. It handles prompts, code context, and agent orchestration for GitLab Duo features. A user who can execute commands on the gateway isn't just compromising one service — they're sitting on a privileged pivot point with access to AI model credentials, API keys for upstream providers (Anthropic, OpenAI, Google Vertex, self-hosted models), internal network reachability, and potentially sensitive code context flowing through Duo workloads.

In our IR engagements, services like this — internally trusted, lightly monitored, and holding cloud credentials — are exactly where attackers set up persistence after gaining an initial foothold. This flaw collapses the distance between "low-privilege GitLab user with Duo access" and "code execution on infrastructure." Defenders running self-hosted gateways need to patch immediately and hunt for signs of prior exploitation.

Who needs to act: Only organizations that self-host the GitLab AI Gateway. GitLab.com SaaS customers and customers using GitLab-managed AI infrastructure are not affected by this exposure.

Technical Analysis

Affected Products and Versions

  • Product: GitLab AI Gateway (self-hosted deployments only)
  • Component: Duo Agent Platform request handling
  • Fixed versions: AI Gateway 19.2.4, 19.3.2, and 19.4.1
  • Severity: CVSS 9.9 (Critical)
  • Attack vector: Network, authenticated (low-privilege GitLab user with Duo Agent Platform access)

The AI Gateway is most commonly deployed as a Docker container (registry.gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/model-gateway) or as a cloud-native workload in Kubernetes/ECS, but it can also run as a standalone Python service. The gateway is built on a Python/FastAPI stack typically served via uvicorn/gunicorn workers.

How the Vulnerability Works

Per GitLab's advisory, a logged-in user with access to the Duo Agent Platform can, under certain conditions, cause the gateway to execute commands. From a defender's perspective, the attack chain looks like this:

  1. Prerequisite access: The attacker holds a valid GitLab account with Duo Agent Platform access. This could be a malicious insider, a compromised developer account (stolen PAT, session token, or phished credentials), or an account created via weak invite controls.
  2. Malicious request: The attacker crafts requests through the Duo Agent Platform interaction surface that reach the vulnerable code path in the AI Gateway.
  3. Command execution: The gateway process executes attacker-controlled commands with the privileges of the gateway service account (commonly a container user, but containers are frequently run with excessive privileges, mounted host paths, or reachable cloud metadata endpoints).
  4. Post-exploitation potential: From the gateway, an attacker can harvest AI provider API keys from environment variables, access internal services the gateway can reach, intercept or manipulate Duo traffic, and pivot deeper into the environment.

The critical 9.9 score reflects the combination of network reachability, low privilege requirement, and full impact on confidentiality, integrity, and availability — with the scope change inherent in breaking out of the intended application sandbox.

Exploitation Status

At the time of this writing, there is no confirmed public proof-of-concept exploit and no confirmed in-the-wild exploitation reported. The vulnerability has not been added to CISA's Known Exploited Vulnerabilities catalog. However, GitLab self-hosted instances are a historically attractive target — threat actors routinely weaponize GitLab flaws within days of disclosure, and the gap between advisory publication and mass scanning is typically short. Treat this as urgent regardless of current exploitation status.

Detection & Response

Because exploitation requires authentication, your detection strategy has two pillars: (1) behavioral detection on the gateway host for anomalous command execution, and (2) audit-log review for suspicious Duo Agent Platform usage by accounts that shouldn't be touching it.

The single highest-fidelity signal: the AI Gateway service process (Python/uvicorn/gunicorn) spawning shell interpreters or system utilities. Legitimate gateway operation does not require spawning sh, bash, curl, wget, python -c, or reconnaissance tooling as child processes.

Sigma Rules

YAML
---
title: GitLab AI Gateway Process Spawning Shell or System Utility
id: 3f8a1b42-7c9d-4e51-a6b2-9d4e5f6a7b8c
status: experimental
description: Detects the GitLab AI Gateway (Python/uvicorn/gunicorn) spawning shell interpreters or common post-exploitation utilities, consistent with command execution via the Duo Agent Platform flaw.
references:
  - https://thehackernews.com/2026/10/gitlab-patches-critical-self-hosted-ai.html
  - https://attack.mitre.org/techniques/T1059/
author: Security Arsenal
date: 2026/10/15
tags:
  - attack.execution
  - attack.t1059
  - attack.t1059.004
logsource:
  category: process_creation
  product: linux
detection:
  selection_parent:
    ParentImage|contains:
      - '/python'
      - '/uvicorn'
      - '/gunicorn'
  selection_child:
    Image|endswith:
      - '/sh'
      - '/bash'
      - '/dash'
      - '/zsh'
      - '/curl'
      - '/wget'
      - '/nc'
      - '/ncat'
      - '/python'
      - '/python3'
      - '/perl'
      - '/base64'
      - '/id'
      - '/whoami'
  filter_framework:
    ParentCommandLine|contains:
      - 'celery'
      - 'sidekiq'
  condition: selection_parent and selection_child and not filter_framework
falsepositives:
  - Legitimate gateway worker frameworks spawning subprocesses during upgrades or plugin execution
  - Container health checks invoking shells (tune with container runtime context)
level: high
---
title: Network Connection from GitLab AI Gateway to Unusual External Destination
id: 8b2c4d61-1e3f-4a57-b8c9-0d1e2f3a4b5c
status: experimental
description: Detects outbound network connections from the AI Gateway process to destinations that are not approved AI model providers or GitLab infrastructure, indicating potential post-exploitation C2 or data exfiltration.
references:
  - https://thehackernews.com/2026/10/gitlab-patches-critical-self-hosted-ai.html
  - https://attack.mitre.org/techniques/T1071/
author: Security Arsenal
date: 2026/10/15
tags:
  - attack.command_and_control
  - attack.t1071
  - attack.exfiltration
logsource:
  category: network_connection
  product: linux
detection:
  selection:
    Image|contains:
      - '/python'
      - '/uvicorn'
      - '/gunicorn'
    DestinationHostname|contains:
      - '.ngrok.io'
      - '.ngrok-free.app'
      - '.trycloudflare.com'
      - '.burpcollaborator.net'
      - '.oastify.com'
      - '.interact.sh'
      - 'pastebin.com'
      - 'webhook.site'
  condition: selection
falsepositives:
  - Security testing and authorized red team activity using collaborator-style tooling
level: high

KQL (Microsoft Sentinel)

This query assumes you're ingesting Syslog/auditd process events from the gateway host or container node into Sentinel. It hunts for the gateway service spawning suspicious child processes and correlates with GitLab audit events where available.

KQL — Microsoft Sentinel / Defender
// Hunt for AI Gateway processes spawning shells or utilities (process execution anomaly)
let suspiciousChildren = dynamic(["/bin/sh","/bin/bash","/bin/dash","/usr/bin/curl","/usr/bin/wget","/usr/bin/nc","/usr/bin/base64","/usr/bin/id","/usr/bin/whoami","/usr/bin/perl","/usr/bin/python3"]);
Syslog
| where TimeGenerated > ago(30d)
| where ProcessName in~ ("python","python3","uvicorn","gunicorn") or SyslogMessage has_any ("ai-gateway","model-gateway")
| where SyslogMessage has_any (suspiciousChildren)
| extend ChildProcess = extract(@"(sh|bash|dash|curl|wget|nc|base64|whoami|perl)(\s|$)", 1, SyslogMessage)
| project TimeGenerated, Computer, ProcessName, SyslogMessage, ChildProcess
| order by TimeGenerated desc;
// Correlate with recent GitLab audit events for Duo access on the same timeframe
union (
    CommonSecurityLog
    | where TimeGenerated > ago(30d)
    | where DeviceVendor =~ "GitLab"
    | where Message has_any ("duo","agent_platform","ai_gateway")
    | where Message has_any ("create","update","token","project_access")
    | project TimeGenerated, SourceIP, SourceUserID, Message, Activity
)
| order by TimeGenerated desc

Velociraptor VQL

Use this hunt artifact on gateway hosts (or container nodes) to enumerate processes spawned by the gateway service and identify suspicious command lines.

VQL — Velociraptor
-- Hunt for suspicious child processes of the GitLab AI Gateway service
SELECT Pid, Ppid, Name, CommandLine, Exe, Username, CreateTime,
       get_field(member='CommandLine', dict=dict(
         parent=parent.CommandLine)) AS ParentCommandLine
FROM pslist()
WHERE Name =~ 'python|uvicorn|gunicorn'
   OR CommandLine =~ 'ai.gateway|model.gateway|ai_gateway'
LET parent = SELECT Pid, CommandLine FROM pslist()

-- Secondary: enumerate recent shells spawned by service accounts (non-interactive users)
SELECT Pid, Ppid, Name, CommandLine, Username, CreateTime
FROM pslist()
WHERE (Name =~ '^(sh|bash|dash|zsh)$' OR CommandLine =~ '(curl|wget|nc |ncat|base64|whoami)')
  AND Username =~ 'git|gitlab|gateway|nobody|www'
ORDER BY CreateTime DESC

Additional Hunting Guidance

  • Review GitLab audit events for Duo Agent Platform activity from accounts with no legitimate need, newly created accounts, or service accounts used interactively.
  • Check egress from the gateway network segment. The gateway should only need to talk to your GitLab instance and your configured AI providers. Any other egress — especially to cloud metadata endpoints (169.254.169.254) if the gateway shouldn't be calling instance metadata — is a strong signal.
  • Inspect container runtime logs (docker logs, Kubernetes audit logs) for exec events into the gateway container around the exposure window.

Remediation

Immediate Actions (Next 24 Hours)

  1. Identify your exposure. Determine whether you self-host the AI Gateway. If you use GitLab-managed AI infrastructure, you are not affected by this specific issue. Verify by checking for running gateway containers/services:
Bash / Shell
#!/bin/bash
# GitLab AI Gateway exposure check and version verification
# Run on the gateway host or container node

echo "=== Checking for running AI Gateway containers ==="
docker ps --format '{{.Image}} {{.Names}}' 2>/dev/null | grep -iE 'ai-gateway|model-gateway' || echo "No gateway containers found via docker"

echo ""
echo "=== Checking Kubernetes deployments (if applicable) ==="
kubectl get pods -A 2>/dev/null | grep -iE 'ai-gateway|model-gateway' || echo "kubectl not configured or no gateway pods found"

echo ""
echo "=== Checking running gateway processes and version ==="
ps aux | grep -iE 'ai[-_]gateway|model[-_]gateway' | grep -v grep

echo ""
echo "=== Checking installed gateway version (container tag) ==="
docker images 2>/dev/null | grep -iE 'ai-gateway|model-gateway'

echo ""
echo "=== VULNERABILITY CHECK ==="
echo "Fixed versions: 19.2.4, 19.3.2, 19.4.1"
echo "If your deployed tag is older than these for your release track, you are VULNERABLE."
  1. Upgrade the gateway immediately to the fixed release for your track:
    • 19.2.x track → 19.2.4
    • 19.3.x track → 19.3.2
    • 19.4.x track → 19.4.1
Bash / Shell
#!/bin/bash
# Upgrade self-hosted AI Gateway container to a patched version
# Adjust the tag to your release track: 19.2.4 / 19.3.2 / 19.4.1

GATEWAY_TAG="19.4.1"
IMAGE="registry.gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/model-gateway"

echo "=== Pulling patched AI Gateway image: ${IMAGE}:${GATEWAY_TAG} ==="
docker pull "${IMAGE}:${GATEWAY_TAG}"

echo "=== Stopping current gateway container ==="
docker stop ai-gateway 2>/dev/null && docker rm ai-gateway 2>/dev/null

echo "=== Starting patched gateway (re-apply your original env/ports) ==="
# NOTE: replicate your existing deployment's env vars, volumes, and network config
docker run -d --name ai-gateway \
  -p 5052:5052 \
  --restart unless-stopped \
  "${IMAGE}:${GATEWAY_TAG}"

echo "=== Verifying new version is running ==="
docker ps --filter name=ai-gateway --format '{{.Image}} {{.Status}}'

# For Kubernetes/Helm deployments, update the image tag and roll out:
# kubectl set image deployment/ai-gateway gateway=${IMAGE}:${GATEWAY_TAG} -n <namespace>
# kubectl rollout status deployment/ai-gateway -n <namespace>
  1. Restrict Duo Agent Platform access to only those users and groups with a documented business need. Review current access grants and revoke stale entitlements.

Hardening (This Week)

  • Network segmentation: Place the gateway in a dedicated segment with egress filtering limited to your GitLab instance and approved AI provider endpoints (e.g., api.anthropic.com, api.openai.com, Vertex AI endpoints). Block all other outbound traffic by default.
  • Block cloud metadata access from the gateway pod/container unless explicitly required, to prevent credential theft via SSRF-style pivots after command execution.
  • Run the gateway as non-root with a read-only root filesystem, dropped capabilities, and no host path mounts. Command execution inside a locked-down container is a dramatically smaller blast radius.
  • Rotate AI provider API keys if the gateway was exposed to untrusted users or if you find any suspicious process activity during hunting — assume keys in gateway environment variables may have been readable post-exploitation.
  • Forward gateway host and container logs to your SIEM, and deploy the Sigma/KQL detections above before attackers catch up to this advisory.

Verification

After patching, confirm the running image tag matches a fixed version and re-run the exposure-check script. Validate that the Duo Agent Platform functions normally for authorized users — the patch should not break legitimate agent workflows. Document the remediation in your vulnerability management system and track it against your internal SLA for critical findings (for a 9.9 with an authenticated path to RCE, that SLA should be measured in hours, not weeks).

Final Assessment

This flaw is a textbook example of why AI infrastructure deserves the same defensive rigor as your CI/CD pipeline — because increasingly, it is part of your CI/CD pipeline. The gateway holds model credentials, sees proprietary code context, and enjoys trusted network positioning. A 9.9 authenticated RCE on that service is a direct path from a single compromised GitLab account to infrastructure-level compromise. Patch to 19.2.4, 19.3.2, or 19.4.1 today, hunt for anomalous gateway process execution, and tighten who can touch the Duo Agent Platform in the first place.

Related Resources

Security Arsenal Managed SOC Services AlertMonitor Platform Book a SOC Assessment soc-mdr Intel Hub

Is your security operations ready?

Get a free SOC assessment or see how AlertMonitor cuts through alert noise with automated triage.