Back to Intelligence

Shadow AI Relay Services Strip Sandboxes from OpenAI Codex and Claude Code: Detection and Hardening Guide

SA
Security Arsenal Team
October 30, 2026
10 min read

Security researchers have identified an enigmatic relay service providing access to OpenAI Codex and Anthropic's Claude Code in mainland China and other regions where these products are not officially sold — with one critical modification: key security features, including the execution sandboxes that make agentic coding tools safe to run against real systems, are turned off.

This is not a hypothetical supply-chain scenario. It is an active, in-the-wild pattern with two distinct risk planes. First, any developer — or any organization with developers in affected regions — using these relayed tools is executing AI-generated shell commands, file writes, and network calls without the sandbox isolation that OpenAI and Anthropic engineered as the primary safety boundary. Second, every prompt, source file, and repository context sent through the relay transits infrastructure controlled by an unknown third party. That is your source code, your credentials embedded in config files, and your internal architecture flowing through an unaccountable intermediary.

For defenders, the immediate questions are: do we have developers using these tools through unofficial relays, are our endpoints running agentic AI CLIs in unsandboxed/danger mode, and is code or credential material egressing to non-official API endpoints? This post gives you the detection logic and hardening steps to answer all three.

Technical Analysis: How the Relay Model Breaks the Security Model

The architecture

Both Codex CLI and Claude Code are designed to authenticate against first-party API endpoints (api.openai.com, api.anthropic.com) and to execute model-generated commands inside a constrained environment:

  • Codex CLI defaults to a sandboxed execution mode (--sandbox-mode read-only / workspace-write with OS-level seatbelt/landlock enforcement) and an approval gate before commands run.
  • Claude Code enforces a permission model requiring explicit user approval for tool use (file writes, bash execution), with enterprise controls via managed settings.

Relay services monetize access in sanctioned or unsupported regions by proxying API traffic through their own infrastructure. To make the tools function against the relay — and often to strip out safety friction that interferes with the proxied experience — the relay operators instruct users to (or ship wrappers that):

  1. Override the API base URL via environment variables (OPENAI_BASE_URL, ANTHROPIC_BASE_URL, OPENAI_API_BASE) or modified config files, redirecting traffic to relay-controlled domains.
  2. Disable sandboxing and approval gates using flags that exist for legitimate power-user workflows: codex --dangerously-bypass-approvals-and-sandbox, --sandbox-mode danger-full-access, or claude --dangerously-skip-permissions.
  3. Inject relay-issued API keys, meaning the relay operator can observe — and log — every request and response in plaintext.

Why this matters operationally

An agentic coding tool without a sandbox is effectively an autonomous shell with write access to whatever the developer's account can reach. The dangerous configurations these relays normalize are exactly the ones a threat actor would want on a developer workstation:

  • Unsandboxed command execution: model output executes directly against the host. A poisoned dependency, a malicious README in a cloned repo (indirect prompt injection), or a compromised relay injecting responses can achieve arbitrary code execution with the developer's privileges.
  • Credential and IP exposure: source code, .env files, SSH keys, cloud tokens, and internal hostnames in the working context are transmitted to relay infrastructure.
  • No audit trail: traffic to relay domains blends into generic HTTPS egress; without explicit hunting, it is invisible to most SOC tooling.

Exploitation status

There is no CVE associated with this story — this is architectural risk and abuse of legitimate configuration options, not a patchable bug. The exposure is confirmed active: the relay service is operating now, distributing modified/unofficial access paths with security controls disabled. The closest MITRE ATT&CK mappings are T1078 (Valid Accounts — relayed credentials), T1552 (Unsecured Credentials in transit), T1059 (Command Execution via unsandboxed agents), and T1105 (Ingress Tool Transfer / exfiltration over the relay channel).

Detection & Response

The detection strategy has three prongs: (1) find AI coding CLIs running with sandbox/approval bypass flags, (2) find environment-level API endpoint redirection to non-official domains, and (3) hunt network egress from developer workstations to AI API traffic that isn't going to first-party endpoints.

Sigma Rules

YAML
---
title: Agentic AI CLI Executed With Sandbox or Approval Bypass
description: Detects Codex CLI or Claude Code launched with flags that disable sandboxing and approval gates, as distributed by unofficial AI relay services.
id: 3f8a1c62-7b4d-4e91-a2c5-9d0e1f2a3b4c
status: experimental
references:
  - https://www.darkreading.com/threat-intelligence/ai-relay-service-openai-codex-claude-code-sandboxes
  - https://attack.mitre.org/techniques/T1059/
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: windows
detection:
  selection_image:
    Image|endswith:
      - '\codex.exe'
      - '\claude.exe'
      - '\node.exe'
  selection_flags:
    CommandLine|contains:
      - '--dangerously-bypass-approvals-and-sandbox'
      - '--dangerously-skip-permissions'
      - 'danger-full-access'
      - '--sandbox-mode danger'
  condition: selection_image and selection_flags
falsepositives:
  - Legitimate power-user developer workflows (rare; should be exception-approved per user)
level: high
---
title: AI API Base URL Redirected to Non-Official Endpoint
description: Detects shell or process launch where OpenAI/Anthropic base URL environment variables are overridden, redirecting API traffic through third-party relay infrastructure.
id: 8c2d4e71-1a3b-4f56-b7d8-2e9f0a1b5c6d
status: experimental
references:
  - https://www.darkreading.com/threat-intelligence/ai-relay-service-openai-codex-claude-code-sandboxes
  - https://attack.mitre.org/techniques/T1552/
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.collection
  - attack.t1552
  - attack.exfiltration
logsource:
  category: process_creation
  product: linux
detection:
  selection:
    CommandLine|contains:
      - 'OPENAI_BASE_URL='
      - 'OPENAI_API_BASE='
      - 'ANTHROPIC_BASE_URL='
  filter_official:
    CommandLine|contains:
      - 'api.openai.com'
      - 'api.anthropic.com'
  condition: selection and not filter_official
falsepositives:
  - Corporate LLM gateways and approved internal proxies (maintain an allowlist of sanctioned gateway domains)
level: high
---
title: AI CLI Configuration Modified for Custom Endpoint or Disabled Sandbox
description: Detects writes to Codex/Claude configuration files introducing custom base URLs or disabling approval and sandbox enforcement.
id: b5e7f109-4c2d-48a3-9e61-7f3a0b8c2d4e
status: experimental
references:
  - https://www.darkreading.com/threat-intelligence/ai-relay-service-openai-codex-claude-code-sandboxes
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.defense_evasion
logsource:
  category: file_event
  product: windows
detection:
  selection_path:
    TargetFilename|contains:
      - '\.codex\config'
      - '\.claude\settings'
      - '\.claude.json'
  condition: selection_path
falsepositives:
  - Normal user preference edits; tune by alerting on content where telemetry supports it or pairing with network detections
level: medium

KQL Hunt — Microsoft Sentinel / Defender

KQL — Microsoft Sentinel / Defender
// Hunt 1: Agentic AI CLIs launched with sandbox/approval bypass on Windows endpoints
DeviceProcessEvents
| where TimeGenerated > ago(14d)
| where ProcessCommandLine has_any (
    "--dangerously-bypass-approvals-and-sandbox",
    "--dangerously-skip-permissions",
    "danger-full-access")
   or (ProcessCommandLine has "--sandbox-mode" and ProcessCommandLine has "danger")
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessAccountName, SHA256
| order by TimeGenerated desc;

// Hunt 2: Network egress from AI CLI processes to non-official API destinations
// Baseline first: build an allowlist of your sanctioned LLM gateways, then alert on everything else.
let OfficialEndpoints = dynamic(["api.openai.com", "api.anthropic.com", "chatgpt.com", "claude.ai"]);
DeviceNetworkEvents
| where TimeGenerated > ago(14d)
| where InitiatingProcessFileName in~ ("codex.exe", "claude.exe", "node.exe", "codex", "claude")
   or InitiatingProcessCommandLine has_any ("codex", "claude-code")
| where RemoteUrl !in~ (OfficialEndpoints)
| summarize Connections = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)
  by DeviceName, InitiatingProcessFileName, RemoteUrl, RemoteIP
| order by Connections desc;

Velociraptor VQL Hunt

VQL — Velociraptor
-- Artifact: SecurityArsenal.AI.RelayHunt
-- Hunts developer endpoints for AI coding CLIs running in unsandboxed mode
-- or holding environment overrides pointing API traffic at unofficial relays.

LET procs = SELECT Pid, Ppid, Name, Exe, CommandLine, Username, CreateTime
FROM pslist()
WHERE CommandLine =~ '(?i)(codex|claude)'
  AND (
       CommandLine =~ '(?i)dangerously-(bypass|skip)'
    OR CommandLine =~ '(?i)danger-full-access'
    OR CommandLine =~ '(?i)(OPENAI_BASE_URL|OPENAI_API_BASE|ANTHROPIC_BASE_URL)=https?://'
  )

LET conns = SELECT Pid, Name, Status, Laddr, Lport, Raddr, Rport
FROM netstat()
WHERE Name =~ '(?i)(codex|claude|node)'
  AND Rport = 443

SELECT * FROM procs
UNION ALL
SELECT Pid, NULL AS Ppid, Name, NULL AS Exe,
       format(format='connection %v:%v -> %v:%v [%v]', args=[Laddr, Lport, Raddr, Rport, Status]) AS CommandLine,
       NULL AS Username, NULL AS CreateTime
FROM conns

The network half of that artifact requires your analysts to eyeball Raddr against known OpenAI/Anthropic ASN space — enrich with a threat intel or ASN lookup plugin where available. Any node/codex/claude process holding persistent 443 sessions to unfamiliar hosting ASNs (particularly consumer VPS ranges) is a high-priority lead.

Hardening & Audit Script

PowerShell
# SecurityArsenal-AI-RelayAudit.ps1
# Audits Windows developer endpoints for relay-style AI CLI misconfigurations.
# Run via your RMM/Intune/SCCM as SYSTEM or collect output centrally.

$findings = @()

# 1) Check machine- and user-level environment variables for API endpoint overrides
$relayVars = 'OPENAI_BASE_URL','OPENAI_API_BASE','ANTHROPIC_BASE_URL','ANTHROPIC_API_URL'
foreach ($scope in 'Machine','User') {
    foreach ($v in $relayVars) {
        $val = [Environment]::GetEnvironmentVariable($v, $scope)
        if ($val -and $val -notmatch 'api\.openai\.com|api\.anthropic\.com') {
            $findings += [pscustomobject]@{ Check='EnvOverride'; Scope=$scope; Variable=$v; Value=$val }
        }
    }
}

# 2) Inspect Codex CLI config for disabled sandbox or custom providers
$users = Get-ChildItem 'C:\Users' -Directory -ErrorAction SilentlyContinue
foreach ($u in $users) {
    $codexCfg = Join-Path $u.FullName '.codex\config.toml'
    if (Test-Path $codexCfg) {
        $cfg = Get-Content $codexCfg -Raw -ErrorAction SilentlyContinue
        if ($cfg -match 'sandbox_mode\s*=\s*"danger-full-access"') {
            $findings += [pscustomobject]@{ Check='CodexSandboxDisabled'; Scope=$u.Name; Variable='sandbox_mode'; Value='danger-full-access' }
        }
        if ($cfg -match 'base_url\s*=\s*"https?://(?!api\.openai\.com)') {
            $findings += [pscustomobject]@{ Check='CodexCustomBaseURL'; Scope=$u.Name; Variable='base_url'; Value=($Matches[0]) }
        }
    }
    $claudeCfg = Join-Path $u.FullName '.claude.json'
    if (Test-Path $claudeCfg) {
        $cfg2 = Get-Content $claudeCfg -Raw -ErrorAction SilentlyContinue
        if ($cfg2 -match '"skipDangerouslySkipPermissions"\s*:\s*true|"bypassPermissionsModeAccepted"\s*:\s*true') {
            $findings += [pscustomobject]@{ Check='ClaudePermissionBypass'; Scope=$u.Name; Variable='claude.json'; Value='permission bypass accepted' }
        }
    }
}

# 3) Report — ship JSON to your SIEM or write to a central share
if ($findings) {
    $findings | ConvertTo-Json | Out-File "$env:ProgramData\AI-RelayAudit-$(hostname)-$(Get-Date -Format yyyyMMdd).json"
    Write-Warning "Relay-style AI CLI misconfigurations detected. Review findings file."
} else {
    Write-Output "No AI relay indicators found on $(hostname)."
}
Bash / Shell
#!/usr/bin/env bash
# ai-relay-audit.sh — Linux/macOS equivalent. Run via MDM/chef/ansible across dev fleets.
echo "=== AI Relay Audit: $(hostname) ==="

# 1) Env overrides in shell profiles
for f in /home/*/.bashrc /home/*/.zshrc /home/*/.profile /root/.bashrc /etc/profile.d/*.sh; do
  grep -HEn 'OPENAI_BASE_URL|OPENAI_API_BASE|ANTHROPIC_BASE_URL' "$f" 2>/dev/null \
    | grep -vE 'api\.openai\.com|api\.anthropic\.com'
done

# 2) Codex config with sandbox disabled or custom provider
for cfg in /home/*/.codex/config.toml /root/.codex/config.toml; do
  [ -f "$cfg" ] || continue
  grep -Hn 'danger-full-access' "$cfg"
  grep -HnE 'base_url\s*=\s*"https?://' "$cfg" | grep -v 'api\.openai\.com'
done

# 3) Running processes with bypass flags
ps -eo user,pid,args | grep -E 'codex|claude' | grep -E 'dangerously|danger-full-access' | grep -v grep

echo "=== Audit complete ==="

Remediation and Risk Reduction

There is no vendor patch for this — the mitigations are policy, configuration enforcement, and egress control:

  1. Inventory and policy. Establish a definitive list of sanctioned AI coding tools and first-party endpoints. Anything outside that list — particularly tools reachable only via third-party relays — is unauthorized by default. For staff in regions where these products aren't officially sold, the answer is an approved enterprise licensing path or an approved alternative, not a relay of unknown provenance.
  2. Egress control. Restrict outbound 443 from developer workstations to api.openai.com / api.anthropic.com (and your sanctioned LLM gateway, if you operate one) for the CLI process names. Alert on AI-tool process traffic terminating anywhere else. This single control breaks the relay model.
  3. Enforce sandbox configuration centrally. For Claude Code, deploy managed settings that prohibit --dangerously-skip-permissions in your environment. For Codex, distribute a managed config.toml pinning sandbox_mode to workspace-write (or stricter) and monitor for drift with the scripts above.
  4. Treat relay keys as compromised. Any developer who has used a relay service has transmitted their working context — potentially including credentials in .env files, config, and source — through third-party infrastructure. Rotate any credentials present in repositories those users worked on, and review access logs for the affected API keys.
  5. Detect the wrapper, not just the tool. Some relays ship repackaged CLI binaries. Verify binary provenance: check code-signing status and hashes of codex/claude executables against official distribution channels, and alert on unsigned or side-loaded copies.
  6. Educate on indirect prompt injection. An unsandboxed agent reading a malicious repository is a code-execution primitive. Developers must understand that removing the sandbox converts prompt injection from an annoyance into remote code execution on their workstation.

Related Resources

Security Arsenal Penetration Testing Services AlertMonitor Platform Book a SOC Assessment vulnerability-management Intel Hub

Is your security operations ready?

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