Skip to content
Pwnversity
AUD-ELASTICSEARCHintermediate · 11 min · upd. 2026-11

Auditing Elasticsearch

ElasticsearchKibanabases de datos

Elasticsearch keeps showing up in data leak news for the same reason: a cluster that answers over HTTP without asking for credentials, with millions of indexed documents ready to search. Since version 8.0 security is on by default, so today an open cluster is almost always the result of a decision: someone turned security off “to make it work”, or the cluster comes from an old version and was never configured. The audit checks that security is on and that users, roles and API keys only grant what is needed. It also reviews what surrounds the cluster: Kibana, snapshot copies and integrations.

On Elastic Cloud, security comes configured and the provider runs the nodes. On a self-managed cluster, everything belongs to the customer. In both cases the customer decides:

  • which networks can reach the HTTP port (9200) and Kibana (5601);
  • which users, roles and API keys exist;
  • whether anonymous access is allowed;
  • where snapshots are stored and with which credentials;
  • what gets logged.
flowchart LR
    A["Applications, Beats,<br/>Logstash"] -->|"HTTPS + API key"| ES(("Elasticsearch<br/>9200"))
    K["Kibana 5601"] -->|"kibana_system"| ES
    X["Internet"] -. "xpack.security.enabled: false<br/>or an old version" .-> ES
    ES --> I[("Indices")]
    ES --> SN["Snapshot repository<br/>S3, GCS, Azure"]
    U["Users and roles<br/>superuser, custom roles"] --> ES

When a node that is not part of a cluster starts for the first time, Elasticsearch 8.0 and later configure security on their own:

  • they generate TLS certificates for HTTP and for transport between nodes;
  • they write the configuration to elasticsearch.yml;
  • they set a password for the elastic superuser;
  • they create a token to enroll Kibana.

Two details matter in an audit:

  • The HTTP layer of the automatic configuration binds to 0.0.0.0, according to Elastic’s documentation. Transport stays on localhost. A freshly installed node answers on every interface, with TLS and a password, but it answers.
  • The password is only shown the first time. In the lab, started in the background, Elasticsearch did not generate it: it reported that it could not tell whether a terminal was attached. The password had to be set with elasticsearch-reset-password.

The block the automatic configuration added to the lab’s elasticsearch.yml (Elasticsearch 9.5.6, official package with its SHA-256 checked against the repository index):

xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12

Real responses with that configuration:

$ curl -s http://127.0.0.1:19200/ # clear-text HTTP
(no response: curl exits with code 52)
$ curl -s --cacert http_ca.crt https://127.0.0.1:19200/
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials
for REST request [/]", ...},"status":401}

And with xpack.security.enabled: false and HTTP TLS turned off, which is what someone does when they “remove security to test”:

$ curl -s 'http://127.0.0.1:19200/_cat/indices?h=index,docs.count' | grep -v '^\.'
clientes 1
logs-app 1
$ curl -s 'http://127.0.0.1:19200/clientes/_search?filter_path=hits.hits._source'
{"hits":{"hits":[{"_source":{"email":"ana@ejemplo.test"}}]}}

No credentials, no TLS and the data in plain sight. It is exactly what researchers find in every leak.

  • superuser. Administration only, never for applications or Kibana. The elastic user is kept for emergencies.
  • Custom roles. Specific indices (logs-*), not *, and minimal privileges:
    • read to query;
    • create_doc to ingest;
    • no all or manage without a justification.
  • API keys. With an expiration date and role_descriptors that limit what they can do. An API key created without descriptors inherits the permissions of whoever created it.
  • Anonymous access. Disabled unless there is a documented reason and a very limited role.
  • Kibana. Behind authentication and not exposed to the internet. An open Kibana with a highly privileged user is the same as an open Elasticsearch.
  • Snapshots. The repository (S3, GCS, Azure) has its own credentials and holds full copies of the indices; audit it like any other bucket (see S3).

The lab creates (the object names are in Spanish):

  • a lectura_logs role (only read on logs-*);
  • an analyst user with that role;
  • a dev user with superuser, the typical mistake;
  • an API key without expiration;
  • another API key that expires in 30 days and can only create_doc on logs-app.

The analyst user tries to read the customers index:

"action [indices:data/read/search] is unauthorized for user [analyst] with effective roles
[lectura_logs] on indices [clientes], this action is granted by the index privileges [read,all]"

The audit script only reads the API:

#!/usr/bin/env bash
# Usage: ES=https://host:9200 AUTH="user:password" ./audit.sh (CA in ./http_ca.crt)
q() { curl -s --cacert http_ca.crt -u "$AUTH" "$ES$1"; }
echo "== Version and security"
q / | jq -r '"version: " + .version.number'
q /_xpack/usage | jq -r '.security | "security: \(.enabled) | TLS http: \(.ssl.http.enabled) | anonymous: \(.anonymous.enabled)"'
echo "== Users with broad roles"
q /_security/user | jq -r 'to_entries[] | select(.value.enabled)
| select(.value.roles | any(. == "superuser" or . == "kibana_admin" or . == "manage_security"))
| "\(.key): \(.value.roles | join(","))"'
echo "== Custom roles with dangerous cluster privileges or '*' indices"
q /_security/role | jq -r 'to_entries[] | select(.value.metadata._reserved != true)
| select((.value.cluster // []) | any(. == "all" or . == "manage" or . == "manage_security"))
, select((.value.indices // []) | any(.names | any(. == "*")))
| .key' | sort -u
echo "== Active API keys without expiration"
q '/_security/api_key?active_only=true' | jq -r '.api_keys[] | select(.expiration == null)
| "\(.name) (creator: \(.username), id: \(.id))"'
echo "== Indices"
q '/_cat/indices?h=index,docs.count&s=index' | grep -v '^\.'

Real output:

== Version and security
version: 9.5.6
security: true | TLS http: true | anonymous: false
== Users with broad roles
elastic: superuser
dev: superuser
== Custom roles with dangerous cluster privileges or '*' indices
== Active API keys without expiration
ingesta-sin-caducidad (creator: elastic, id: 2zqv_6EBj0b-adYRNXhT)
== Indices
clientes 1
logs-app 1

Two findings: the dev user with superuser and the API key without expiration. The 30-day key with limited permissions does not show up.

  • Ports 9200 and 5601 reachable from where they should not be (see ports).
  • GET / without credentials:
    • a 401 with WWW-Authenticate means security is on;
    • a 200 with the cluster name and version is a critical finding.
  • Clear-text HTTP: if it answers on http://, HTTP TLS is off.
  • Version: the X-elastic-product header and the JSON from / reveal the product and, without security, the version.
  • Nextcloud (May 2026). Cybernews researchers found a public Elasticsearch cluster with about 367,000 records (8 GB). It held invoices, contracts, employee data and infrastructure management scripts. Nextcloud said no customer servers were affected.
  • 24 billion credentials (June 2026). On June 12, Cybernews found an open cluster with more than 8.3 TB of credentials collected from infostealers, Telegram channels and earlier breaches. Even though the data did not belong to the cluster’s owner, the exposure put it within anyone’s reach.

Neither case needed a vulnerability: a cluster with security turned off and reachable from the internet was enough.

  • xpack.security.enabled: true; TLS on for HTTP and transport
  • Ports 9200 and 5601 not exposed to the internet; network.host limited
  • elastic kept for emergencies, with a long password stored in a password manager
  • No application or Kibana user with superuser
  • Custom roles with specific indices and minimal privileges; no unjustified all or manage
  • API keys with expiration and role_descriptors; inventory of active keys
  • Anonymous access disabled
  • Kibana behind authentication and not publicly exposed
  • Private snapshot repository, with minimal credentials and encryption
  • Audit logging on if the license includes it; logs shipped to a SIEM (see SIEM)
  • Supported, up-to-date version