Back to Intelligence

Cavern (Cav3rn) C2: Detecting DNS Tunneling and Google Apps Script Abuse by Iranian APT Operators

SA
Security Arsenal Team
August 17, 2026
9 min read

Kaspersky's ongoing tracking of the Cavern (aka Cav3rn) command-and-control framework — attributed to Iranian nation-state operators conducting campaigns against entities in Israel — has surfaced previously unreported components that mark a meaningful evolution in the framework's stealth posture. Since December 2025, researchers have observed Cavern shifting its C2 communications into two channels that most organizations explicitly trust: DNS traffic and Google Apps Script (script.google.com / script.googleusercontent.com).

This matters well beyond the immediate targeting scope. The tradecraft on display — tunneling C2 over DNS and riding legitimate Google infrastructure — is directly portable to any enterprise, any vertical, any geography. If your egress controls treat DNS as plumbing and Google domains as inherently safe, an operator using these techniques can maintain long-term, low-and-slow access inside your network without tripping a single signature-based control.

This post breaks down the technique from a defender's perspective and delivers hunt content you can operationalize today.

Technical Analysis

What Cavern Is Doing Differently

Cavern is not a new family — it is a maturing C2 framework, and the newly documented components show the operators investing specifically in traffic camouflage rather than raw capability:

  1. DNS-based C2 channel. Commands and exfiltrated data are encoded into DNS query and response payloads — typically as long, high-entropy subdomains in TXT, CNAME, or NULL record queries directed at attacker-controlled authoritative name servers. Because port 53 is almost universally permitted outbound and rarely inspected at the content level, this channel survives most egress architectures. DNS C2 also tolerates heavy latency, making it ideal for patient, low-volume tasking — the hallmark of espionage-oriented operators rather than smash-and-grab crimeware.

  2. Google Apps Script as dead-drop / relay infrastructure. Apps Script lets anyone deploy serverless web apps under Google's own domains (script.google.com, script.googleusercontent.com). By proxying C2 through attacker-deployed Apps Script endpoints, the operators inherit Google's TLS certificates, IP reputation, and domain trust. URL categorization engines classify these destinations as legitimate productivity infrastructure. Blocking Google outright is a non-starter for most enterprises — and the operators know it.

Attack Chain (Defender's View)

  • Initial access / staging: Implant is delivered and executed on the endpoint (the summary does not detail the loader; treat delivery as opportunistic — spearphishing and loader droppers are consistent with this actor's historical TTPs, MITRE ATT&CK T1566).
  • C2 establishment: Implant initiates outbound connections either to (a) attacker-controlled domains via DNS TXT/CNAME queries (T1071.004 — Application Layer Protocol: DNS), or (b) HTTPS sessions to Google Apps Script web app URLs (T1102 — Web Service; T1090 — Proxy via legitimate cloud).
  • Tasking & exfiltration: Commands arrive encoded in DNS responses or HTTP(S) responses from the Apps Script relay; results are chunked into subsequent queries/requests. Volumes stay deliberately small to evade bandwidth-based alerting.

Exploitation Status

This is confirmed active, in-the-wild nation-state tradecraft documented by Kaspersky in campaigns observed since December 2025, currently targeting Israeli entities. There is no CVE involved — this is not a patchable vulnerability; it is an architectural detection problem. No CISA KEV entry applies. The defensive burden falls entirely on network monitoring, egress policy, and behavioral endpoint detection.

Why Standard Controls Miss It

  • DNS inspection gap: Most organizations forward all client DNS to internal resolvers and never log query content at the endpoint. Long TXT queries blend into noise.
  • Domain reputation blindness: script.google.com carries Google's reputation. No blocklist will flag it.
  • Process-context blindness: A browser hitting Google is normal. A signed-but-unusual binary — or a LOLBin like rundll32.exe, mshta.exe, or powershell.exe — establishing TLS sessions to Google Apps Script infrastructure is not. That process-to-destination correlation is where detection lives.

Detection & Response

The durable detection logic for this campaign rests on three pivots: (1) non-browser processes connecting to Google Apps Script infrastructure, (2) DNS queries with abnormal length/entropy to rare domains, and (3) periodic low-volume beaconing patterns. The rules below are tuned to fire on the anomaly, not the baseline — validate against your environment's development/automation tooling before broad deployment.

YAML
---
title: Non-Browser Process Network Connection to Google Apps Script
id: 3f8a1c42-7b9d-4e5a-a1c6-9d2e4f7b8a01
status: experimental
description: Detects non-browser processes establishing network connections to Google Apps Script infrastructure (script.google.com / script.googleusercontent.com), consistent with Cavern C2 abusing Apps Script as a C2 relay. Legitimate Apps Script traffic originates from browsers; connections from scripting hosts, LOLBins, or unsigned binaries are highly suspicious.
references:
  - https://thehackernews.com/2026/08/cavern-c2-uses-dns-and-google-apps.html
  - https://attack.mitre.org/techniques/T1102/
  - https://attack.mitre.org/techniques/T1090/
author: Security Arsenal
date: 2026/08/15
tags:
  - attack.command_and_control
  - attack.t1102
  - attack.t1090
logsource:
  category: network_connection
  product: windows
detection:
  selection_domain:
    DestinationHostname|contains:
      - 'script.google.com'
      - 'script.googleusercontent.com'
  filter_browsers:
    Image|endswith:
      - '\chrome.exe'
      - '\msedge.exe'
      - '\firefox.exe'
      - '\brave.exe'
      - '\opera.exe'
      - '\iexplore.exe'
  filter_google_update:
    Image|endswith:
      - '\GoogleUpdate.exe'
  condition: selection_domain and not 1 of filter_*
falsepositives:
  - Legitimate Google Workspace automation tools or CLI utilities interacting with Apps Script deployments
  - Enterprise RMM or IT automation platforms calling internal Apps Script web apps
level: high
---
title: Suspicious DNS Query Characteristics Indicative of DNS Tunneling
id: 8c2e5d91-4a6f-4b38-9c1d-2e7f5a8b3c04
status: experimental
description: Detects DNS TXT or NULL record queries with abnormally long query names, consistent with DNS tunneling C2 channels such as those used by the Cavern framework. Tunneling implants encode command output into subdomain labels, producing query names far longer than typical legitimate traffic.
references:
  - https://thehackernews.com/2026/08/cavern-c2-uses-dns-and-google-apps.html
  - https://attack.mitre.org/techniques/T1071/004/
author: Security Arsenal
date: 2026/08/15
tags:
  - attack.command_and_control
  - attack.t1071.004
  - attack.exfiltration
  - attack.t1048
logsource:
  category: dns
  product: windows
detection:
  selection_type:
    record_type:
      - 'TXT'
      - 'NULL'
      - 'CNAME'
  selection_length:
    query|re: '.{100,}'
  filter_common:
    query|contains:
      - 'google.com'
      - 'microsoft.com'
      - 'apple.com'
      - 'amazondns.com'
  condition: selection_type and selection_length and not filter_common
falsepositives:
  - DKIM/SPF TXT lookups against unusually deep domain structures
  - Some email security gateways performing long verification queries
level: medium
KQL — Microsoft Sentinel / Defender
// Hunt: Non-browser / LOLBin processes communicating with Google Apps Script infrastructure
// Correlates process lineage with network destination — the key pivot for Cavern-style C2
let GoogleAppsScript = dynamic(["script.google.com", "script.googleusercontent.com"]);
let Browsers = dynamic(["chrome.exe", "msedge.exe", "firefox.exe", "brave.exe", "opera.exe", "iexplore.exe", "GoogleUpdate.exe"]);
DeviceNetworkEvents
| where TimeGenerated > ago(7d)
| where RemoteUrl in (GoogleAppsScript)
| where not(InitiatingProcessFileName in~ (Browsers))
| extend SuspiciousLineage = iff(InitiatingProcessFileName in~ (
    dynamic(["powershell.exe","pwsh.exe","wscript.exe","cscript.exe","mshta.exe",
             "rundll32.exe","regsvr32.exe","wmic.exe","cmd.exe","curl.exe","bitsadmin.exe"])),
    "LOLBin", "OtherNonBrowser")
| project TimeGenerated, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine,
          InitiatingProcessParentFileName, SuspiciousLineage, RemoteUrl, RemoteIP, RemotePort,
          InitiatingProcessSHA256, ReportId
| sort by TimeGenerated desc;

// Hunt: DNS tunneling indicators — long TXT/CNAME queries and high query volume per host-domain pair
// Requires DNS events ingested (ASimDnsActivityLogs, or DNS Events via connector)
DeviceEvents
| where TimeGenerated > ago(7d)
| where ActionType == "DnsQueryResponse"
| extend QueryName = tostring(AdditionalFields.QueryName)
| extend QueryType = tostring(AdditionalFields.QueryType)
| where QueryType in~ ("TXT", "NULL", "CNAME")
| extend QueryLength = strlen(QueryName)
| where QueryLength > 100
| summarize QueryCount = count(), MaxLength = max(QueryLength), ExampleQuery = any(QueryName)
    by DeviceName, QueryType, bin(TimeGenerated, 1h)
| where QueryCount > 20 or MaxLength > 180
| sort by QueryCount desc;
VQL — Velociraptor
-- Hunt: Identify processes holding active connections to Google Apps Script infrastructure
-- and suspicious DNS resolver behavior. Run across the fleet as a Velociraptor hunt.
SELECT Pid, Name, Path, CommandLine, Username,
       netstat().RemoteIP AS RemoteIP,
       netstat().RemotePort AS RemotePort,
       netstat().Status AS ConnStatus
FROM pslist()
WHERE netstat().RemotePort = 443
  AND NOT Name =~ '(?i)(chrome|msedge|firefox|brave|opera|iexplore|GoogleUpdate)'
  AND CommandLine =~ '(?i)(apps.?script|google)'

-- Companion: enumerate DNS client cache for script.google entries resolved by non-browser tooling
SELECT Name, Data, Type
FROM glob(glob='C:/Windows/System32/drivers/etc/hosts')

Remediation

There is no patch — this is architectural hardening. Execute in this order:

1. Constrain DNS egress (highest ROI). Force all endpoint DNS through internal resolvers; block outbound UDP/TCP 53 and DoT (853) from everything except approved resolvers at the perimeter. Block or sinkhole outbound DoH to non-approved providers. This collapses direct DNS tunneling to attacker name servers.

2. Instrument DNS logging. Enable DNS analytical/debug logging on resolvers (or deploy Zeek/Suricata with DNS protocol analysis). Alert on query length, TXT/NULL volume per host, and NXDOMAIN ratio per source — tunneling channels generate distinctive failure patterns.

3. Deploy the hunt content above. Onboard the Sigma rules to your SIEM pipeline, schedule the KQL queries as Sentinel analytics rules (7-day lookback, hourly scheduling), and run the VQL hunt across your fleet.

4. Tighten Google Workspace egress. You cannot block google.com wholesale, but you can: restrict which Google services are reachable from server VLANs (servers have no business reaching Apps Script), enforce TLS inspection with process-context correlation at the proxy, and alert on non-browser user-agents to script.google.com.

5. Application control. Enforce WDAC/AppLocker so unsigned or non-standard binaries cannot execute — Cavern-style implants depend on arbitrary code execution persisting on the endpoint. Constrain LOLBins (mshta, rundll32, regsvr32) for users who don't need them.

6. Run the audit script below to baseline outbound DNS policy and surface existing Apps Script connections:

PowerShell
# Cavern C2 Exposure Audit - Run elevated on endpoints or via GPO/SCCM

# 1. Check for active/historical connections to Google Apps Script from non-browser processes
Write-Host "=== Active TCP 443 connections from non-browser processes ===" -ForegroundColor Cyan
Get-NetTCPConnection -State Established -RemotePort 443 -ErrorAction SilentlyContinue |
    ForEach-Object {
        $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
        if ($proc -and $proc.ProcessName -notmatch '^(chrome|msedge|firefox|brave|opera|iexplore)$') {
            [PSCustomObject]@{
                Process     = $proc.ProcessName
                Path        = $proc.Path
                RemoteIP    = $_.RemoteAddress
                PID         = $_.OwningProcess
            }
        }
    } | Format-Table -AutoSize

# 2. Verify outbound DNS is restricted to approved resolvers (check local firewall policy)
Write-Host "=== Outbound DNS (53) firewall rules ===" -ForegroundColor Cyan
Get-NetFirewallRule -Direction Outbound -ErrorAction SilentlyContinue |
    Where-Object { $_.Enabled -eq 'True' } |
    Get-NetFirewallPortFilter -ErrorAction SilentlyContinue |
    Where-Object { $_.RemotePort -in 53, 853 -or $_.LocalPort -in 53, 853 } |
    Select-Object DisplayName, Action, Profile

# 3. Enable DNS Client operational logging for hunt telemetry
$log = Get-WinEvent -ListLog "Microsoft-Windows-DNS-Client/Operational"
if (-not $log.IsEnabled) {
    $log.IsEnabled = $true
    $log.SaveChanges()
    Write-Host "[+] DNS Client Operational log enabled" -ForegroundColor Green
} else {
    Write-Host "[i] DNS Client Operational log already enabled" -ForegroundColor Yellow
}

# 4. Flag hosts resolving script.google.com recently (last 24h)
Write-Host "=== Recent DNS resolutions of Apps Script domains ===" -ForegroundColor Cyan
Get-WinEvent -LogName "Microsoft-Windows-DNS-Client/Operational" -MaxEvents 5000 -ErrorAction SilentlyContinue |
    Where-Object { $_.Message -match 'script\.google|googleusercontent' -and $_.TimeCreated -gt (Get-Date).AddDays(-1) } |
    Select-Object TimeCreated, Message -First 20 | Format-List

7. Threat-informed validation. Run a purple-team exercise emulating T1071.004 (DNS tunneling) and T1102 (web service C2) using tools like dnscat2 or a controlled Apps Script relay to verify your controls actually fire. Assumed detection is failed detection.

Organizations in Israel and those in adjacent targeting profiles (defense, government, critical infrastructure, technology) should treat this as an active-threat priority and run the hunts immediately. Everyone else should treat it as the template for where nation-state C2 is heading: living inside the traffic you trust most.

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.