Auditing Elasticsearch
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.
Responsibility model
Section titled “Responsibility model”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
Security on by default since 8.0
Section titled “Security on by default since 8.0”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
elasticsuperuser; - 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 onlocalhost. 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: truexpack.security.enrollment.enabled: truexpack.security.http.ssl: enabled: true keystore.path: certs/http.p12xpack.security.transport.ssl: enabled: true verification_mode: certificate keystore.path: certs/transport.p12 truststore.path: certs/transport.p12Real 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 credentialsfor 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 1logs-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.
Users, roles and API keys
Section titled “Users, roles and API keys”superuser. Administration only, never for applications or Kibana. Theelasticuser is kept for emergencies.- Custom roles. Specific indices (
logs-*), not*, and minimal privileges:readto query;create_docto ingest;- no
allormanagewithout a justification.
- API keys. With an expiration date and
role_descriptorsthat 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).
Lab: audit script
Section titled “Lab: audit script”The lab creates (the object names are in Spanish):
- a
lectura_logsrole (onlyreadonlogs-*); - an
analystuser with that role; - a
devuser withsuperuser, the typical mistake; - an API key without expiration;
- another API key that expires in 30 days and can only
create_doconlogs-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 securityversion: 9.5.6security: true | TLS http: true | anonymous: false== Users with broad roleselastic: superuserdev: superuser== Custom roles with dangerous cluster privileges or '*' indices== Active API keys without expirationingesta-sin-caducidad (creator: elastic, id: 2zqv_6EBj0b-adYRNXhT)== Indicesclientes 1logs-app 1Two findings: the dev user with superuser and the API key without expiration. The 30-day key with limited permissions does not show up.
From outside
Section titled “From outside”- Ports 9200 and 5601 reachable from where they should not be (see ports).
GET /without credentials:- a
401withWWW-Authenticatemeans security is on; - a
200with the cluster name and version is a critical finding.
- a
- Clear-text HTTP: if it answers on
http://, HTTP TLS is off. - Version: the
X-elastic-productheader and the JSON from/reveal the product and, without security, the version.
Real-world cases
Section titled “Real-world cases”- 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.
Checklist
Section titled “Checklist”-
xpack.security.enabled: true; TLS on for HTTP and transport - Ports 9200 and 5601 not exposed to the internet;
network.hostlimited -
elastickept 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
allormanage - 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
References
Section titled “References”- Elastic: Set up security in self-managed deployments
- Elastic: Start the Elastic Stack with security enabled automatically (8.19)
- Elastic: Securing your Elastic Stack is now simpler than ever
- Elastic: Minimal security setup
- Cybernews: European cloud provider Nextcloud leaks 367K records
- Security Affairs: 24 Billion Stolen Credentials Exposed in Massive Data Leak