Join our Newsletter — 33% off our NHI Course
Home› Guides› Elasticsearch and OpenSearch Security Guide: Locking Down Clusters…
Guide Data Security

Elasticsearch and OpenSearch Security Guide: Locking Down Clusters and Exposed Indices

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 26 October 2026 16 min read
On this page

Search clusters hold some of the most sensitive data in an organisation, yet Elasticsearch and OpenSearch nodes keep turning up on the internet with security disabled and every index readable through a single HTTP request. Both engines now ship with authentication and TLS available out of the box, but long-lived clusters built on older versions, Docker images started with the security plugin turned off, and copy-pasted demo configurations still leave REST APIs open on port 9200. This guide covers self-managed Elasticsearch (Elastic) and OpenSearch: secure bootstrap, authentication and service identities, role design with document and field level security, TLS on both layers, encryption at rest and snapshots, audit logging and detection, and the failure patterns behind exposed indices. It is for platform, observability and security engineering teams running log, search and analytics clusters, and assumes the general database controls in the Database Security Guide.

Key takeaways

  • Never run a cluster with security off. Elastic's own guidance is blunt: without security, anyone who can reach the network can read, change or delete data. In OpenSearch, disabling the security plugin also exposes its configuration index.
  • Treat demo and auto-generated settings as a starting point. Elasticsearch auto-configures TLS and an elastic password only on a clean first start, and OpenSearch's demo configuration generates demo certificates meant for testing, not production.
  • Put every client on its own identity. Ingest agents, Kibana or Dashboards, applications and automation should use scoped API keys, service accounts or certificates, never the elastic or admin superuser.
  • Restrict documents and fields, not only indices. Document and field level security let one index serve several audiences, but roles combine with OR, so a single broad role silently removes the restriction.
  • Audit logging is off by default in both engines. Turn it on, forward it off-cluster and alert on failed logins, privilege denials and security configuration changes.

How search clusters get exposed

Elasticsearch and OpenSearch expose a REST API (default TCP 9200) for clients and a transport protocol (default TCP 9300) between nodes. A reachable REST port with no authentication offers _cat/indices, _search and delete APIs to anyone. Exposed clusters have repeatedly been found holding application logs, customer records and credentials, and are targets for automated wipe-and-ransom scripts.

ExposureHow it happensATT&CK techniquePrimary control
Open REST APIPre-8.0 Elasticsearch defaults, xpack.security.enabled: false, DISABLE_SECURITY_PLUGIN=true or plugins.security.disabled: true, with network.host on a public interfaceT1046 Network Service Discovery, T1190 Exploit Public-Facing ApplicationSecurity enabled, private binding, firewall
Index scrapingBulk _search and scroll requests pull entire indicesT1213 Data from Information RepositoriesAuthentication, least-privilege roles, DLS and FLS
Wipe-and-ransomIndices deleted and replaced with a ransom note indexT1485 Data Destruction, T1657 Financial TheftAuthentication, destructive-action guards, snapshots
Superuser credential reuseelastic or admin password shared across tools, stored in agent configsT1078 Valid Accounts, T1552.001 Credentials In FilesPer-client API keys and service accounts, vaulting
Software vulnerabilityOld Elasticsearch scripting RCEs (CVE-2014-3120, CVE-2015-1427) and Kibana CVE-2019-7609, all in the CISA KEV catalogueT1190 Exploit Public-Facing ApplicationSupported versions, patch SLA
Snapshot exposureSnapshot repository bucket readable or writable by too many identitiesT1530 Data from Cloud StorageDedicated repository identity, encrypted bucket

Logs are a particular risk: application and security logs routinely contain tokens, session identifiers, API keys and personal data. A log cluster with weak access control turns into a credential store for attackers. The DeepSeek Database Exposure 2025 showed the pattern with a different engine: an internet-reachable, unauthenticated analytics store whose log table contained API keys.

Elasticsearch and OpenSearch compared

OpenSearch was forked from Elasticsearch 7.10, and the security models have diverged. Settings and feature names differ even where the concept is the same.

ControlElasticsearchOpenSearch
Security on by defaultYes from 8.0; xpack.security.enabledSecurity plugin installed by default; plugins.security.disabled: true turns it off
First-start bootstrapAuto-configures HTTP and transport TLS (http_ca.crt, http.p12, transport.p12), an elastic password and a 30-minute Kibana enrollment tokenDemo configuration script writes internal users, roles, demo certificates and opensearch.yml; from 2.12 needs OPENSEARCH_INITIAL_ADMIN_PASSWORD
Transport TLSxpack.security.transport.ssl.*Mandatory; plugins.security.ssl.transport.*
REST TLSxpack.security.http.ssl.*Optional; plugins.security.ssl.http.enabled defaults to false
Identity sourcesNative and file realms, LDAP, Active Directory, SAML, OIDC, PKI, Kerberos, JWTInternal users database, LDAP/AD, SAML, OIDC, client certificates, proxy auth
Programmatic accessAPI keys, service accounts (for example for Kibana and Fleet)Internal users, certificates, JWT; check your version for API token support
Document and field level securityRole query and field_security; subscription-dependentDLS, FLS and field masking in the security plugin
Audit loggingxpack.security.audit.enabled, writes <clustername>_audit.json; subscription-dependentplugins.security.audit.type plus audit.yml; storage to an index, external cluster, webhook or log4j
Security configuration storageSecurity index managed via APIsSecurity index loaded from YAML by securityadmin.sh or managed via REST API and Dashboards

Before 8.0, Elasticsearch shipped with security disabled unless explicitly enabled, and before 6.8 and 7.1 the basic security features were not part of the free distribution. Clusters that have been upgraded in place from those versions keep their old configuration, which is why version alone is not evidence of a secure cluster.

Secure bootstrap and network exposure

Elasticsearch auto-configuration and when it is skipped

On the first start of the first node, Elasticsearch generates certificates, writes TLS settings to elasticsearch.yml, sets the elastic password and prints a Kibana enrollment token. Elastic documents several conditions that silently skip this, including an existing non-empty data directory, any xpack.security.enabled or xpack.security.*.ssl.* value already set, discovery settings such as discovery.seed_hosts, an unwritable config directory, and redirecting output to a file (the credentials are printed only to the terminal). Configuration management templates often trigger these conditions, so verify the result rather than assuming it.

OpenSearch demo configuration

The OpenSearch demo configuration is intended to replicate a production layout for testing. From 2.12 it refuses to install without a strong OPENSEARCH_INITIAL_ADMIN_PASSWORD, but it still generates demo certificates. For production, issue node certificates from your own CA, define users and roles, and load them with securityadmin.sh using an admin certificate. OpenSearch documentation positions the YAML files for initial setup and the REST API or Dashboards for ongoing changes. Keystore and truststore passwords default to changeit when keystores are used; set real values.

SettingEngineRecommended valueWhy
network.hostBothPrivate interface addressDefaults to loopback; widening it is when exposure starts
xpack.security.enabledElasticsearchtrueExplicit, so later templates cannot drop it
plugins.security.disabled / DISABLE_SECURITY_PLUGINOpenSearchAbsent / falseDisabling exposes data and the security index
xpack.security.http.ssl.enabled / plugins.security.ssl.http.enabledBothtrueCredentials and API keys otherwise cross the network in clear
Transport TLS with hostname verificationBothFull certificate verificationStops a rogue node joining the cluster
action.destructive_requires_nameBothtrueBlocks wildcard or _all index deletion
Secure settingsElasticsearchKeystore (elasticsearch-keystore)Elastic states file permissions are not enough for passwords
Run-as userBothDedicated unprivileged account, never rootLimits host compromise
  • Firewalling: allow 9200 only from clients, proxies and Kibana or Dashboards hosts; allow 9300 only between cluster nodes. Elasticsearch also supports IP filtering on both layers.
  • Front ends: Kibana and OpenSearch Dashboards should sit behind SSO and never be published without authentication. Set session timeouts and, in Kibana, a stable saved-object encryption key (xpack.encryptedSavedObjects.encryptionKey).
  • Cloud and Kubernetes: managed offerings and operators handle bootstrap, but security groups, ingress objects and load balancers can still publish 9200. Include them in the exposure scan. See the Kubernetes Security Guide.

Identities, roles, and document and field level security

Superusers and service identities

  • Bootstrap superuser: use elastic (Elasticsearch) or admin (OpenSearch) only to create named administrators, then vault it as break-glass. Reset it with elasticsearch-reset-password or the security API if it was ever shared.
  • Built-in system users: Elasticsearch ships kibana_system, logstash_system, beats_system, apm_system and remote_monitoring_user; OpenSearch has the Dashboards server user kibanaserver with the kibana_server role, which its documentation says not to assign to people.
  • API keys: issue one key per ingest pipeline or application, with role descriptors narrowing it to the indices and privileges it needs and an expiry. Invalidate keys when a host is rebuilt. Elasticsearch service accounts give Kibana and Fleet tokens that are not tied to a human.
  • Agents are non-human identities: fleets of Beats, Logstash, Fluent Bit or Data Prepper agents often share one credential baked into images. Give each its own key and track it in the inventory. See the API Key Management Guide and the Service Account Security Guide.
  • Humans through SSO: map identity-provider groups to roles (role mapping in Elasticsearch, roles_mapping.yml backend roles in OpenSearch) so joiners and leavers flow from the directory.

Role design

Role or privilegeEngineRiskGuidance
superuser / all_accessES / OpenSearchFull cluster and data control, including security configurationBreak-glass and named admins only, alert on use
manage_security cluster privilege / security_managerES / OpenSearchCan grant itself anythingTreat as privileged access; hold in PAM
readall, wildcard * index readBothEvery index, including security and audit indicesName index patterns per team or data stream
manage_snapshots / snapshot privilegesBothRestore can overwrite or copy dataDedicated backup identity
Ingest writerBothLow if limited to create_doc or index on its data streamNo read or delete for shippers

Document and field level security

Document level security (DLS) adds a query to a role so a user only sees matching documents; field level security (FLS) grants or excludes fields. In Elasticsearch, DLS queries can be templated with {{_user.username}} and other user attributes to filter per user. Elastic documents several traps practitioners must design around:

  • Roles combine permissively: DLS queries across roles are joined with OR, and FLS grants are unioned. If any role gives unrestricted access to the index, the restriction disappears.
  • Read only: DLS does not apply to write APIs, and the update API is not supported with DLS or FLS.
  • Side channels: aggregations and index statistics can still reveal field names and term counts from documents a user cannot read; metadata fields such as _id and _index are always visible.
  • Multi-fields: excluding city does not exclude city.keyword; exclude city.* as well.
  • When in doubt, split: Elastic recommends separate indices where both documents and fields must be tightly restricted. Separate indices are also easier to audit.

For sensitive values that should never be searchable in clear, mask or tokenise them before ingestion. See the Tokenisation and Data Masking Guide.

Encryption at rest and snapshots

  • No engine-level encryption at rest by default: Elastic states self-managed clusters do not get encryption at rest by default and recommends disk-level encryption such as dm-crypt. The same applies to OpenSearch nodes. Use encrypted volumes on every data node.
  • Snapshots: snapshot repositories (object storage, shared filesystems) hold full index copies. Encrypt the bucket, restrict it to the cluster's repository identity, enable versioning or object lock for immutability, and keep a copy outside the production account. See the Backup Security and Immutable Backup Guide.
  • Repository credentials: store object storage keys in the keystore, or better, use workload identity so no static key exists.
  • FIPS: Elasticsearch supports a FIPS 140-2 mode where compliance requires it.
  • Retention: deleting old indices through lifecycle policies (ILM in Elasticsearch, ISM in OpenSearch) reduces what an attacker can take. See the Log Management and Retention Guide.

Audit logging, detection and measurement

Elasticsearch audit logging is disabled by default and is enabled with xpack.security.audit.enabled: true on every node (a rolling restart, or dynamically from Elastic Stack 9.5). Events go to <clustername>_audit.json on each node; ship them to a separate monitoring cluster or SIEM. Availability depends on subscription level, so confirm it for your licence.

OpenSearch needs two settings: a storage type in opensearch.yml (plugins.security.audit.type, for example internal_opensearch) and config.enabled: true in audit.yml. The shipped audit.yml enables auditing, so it can look on while nothing is recorded until a storage type is set. Audit to an external cluster or webhook so an attacker with admin rights cannot quietly delete the evidence.

SignalOpenSearch category / Elasticsearch eventAlert when
Failed authenticationFAILED_LOGIN / authentication_failedBursts from one source, or any from the internet
Privilege denialMISSING_PRIVILEGES / access_deniedA service identity requests indices outside its pattern
Spoofed internal headersBAD_HEADERSAny occurrence
TLS failuresSSL_EXCEPTIONUnknown clients or nodes
Security changesSecurity config index writes / role, user and API key changesOutside change windows
Destructive and bulk actionsIndex deletion, snapshot restore, very large scroll volumesUnusual identity or time

OpenSearch disables AUTHENTICATED and GRANTED_PRIVILEGES by default because of volume and excludes the kibanaserver user. Keep those defaults unless an investigation needs them, and enable compliance read and write history only for indices that hold regulated data.

Metrics that show it is working

  1. Internet-reachable 9200, 9300, 5601 (Kibana) and Dashboards endpoints: target zero, from weekly external scans.
  2. Percentage of clusters with security enabled, REST TLS on and certificates from the corporate CA.
  3. Percentage of ingest and application clients on their own expiring API key or certificate, versus shared superuser credentials.
  4. Number of identities holding superuser, all_access or security-management privileges, reviewed monthly.
  5. Audit coverage: clusters forwarding audit events off-cluster, and alert triage time.
  6. Version currency: clusters on supported releases and median days to patch security advisories.

Implementation: a phased rollout

  1. Discover: inventory every cluster (including developer and observability clusters), version, owner and data types, and scan for open 9200 and 5601. Treat any unauthenticated cluster holding production data as an incident.
  2. Enable security on legacy clusters: transport TLS is the prerequisite and normally needs a full cluster restart (OpenSearch documents a full restart to enable or disable its plugin). Rehearse on a staging copy, schedule the window, and keep the previous configuration and certificates for rollback.
  3. Move clients to identities: create roles and API keys or certificates per shipper and application, update agents in rings (one environment, then a canary group, then all), and watch MISSING_PRIVILEGES or access_denied events to tune roles before tightening.
  4. Enable REST TLS: distribute the CA to clients, switch clients to HTTPS, then enforce. Rollback is reverting the HTTP TLS setting while clients still trust the CA.
  5. Restrict data: add DLS, FLS or index separation for sensitive data, and mask secrets and personal data at ingest.
  6. Audit and alert: enable audit logging to an external destination, build the alerts above and baseline for a few weeks.
  7. Protect recovery: encrypted, immutable snapshot repositories with a dedicated identity and quarterly restore tests.

Small versus large estates: a single-team cluster can get most of the value from security enabled, private binding, TLS, named users and disk encryption, with audit logs forwarded to an existing SIEM. Large estates with many tenants should standardise on SSO role mapping, per-agent API keys issued by automation, index-per-tenant or DLS designs, configuration-as-code for roles, and a central security monitoring cluster. Choosing between Elasticsearch and OpenSearch is mostly an operational and licensing decision; both can be secured to the same standard, but check which security features your Elasticsearch subscription includes before designing around DLS, FLS or auditing.

Common failure patterns

  • Security plugin disabled for convenience: a docker-compose.yml with DISABLE_SECURITY_PLUGIN=true or xpack.security.enabled: false copied from a tutorial into production, then exposed through a cloud load balancer.
  • Demo certificates in production: clusters still running the OpenSearch demo certificates, or self-signed certificates with verification turned off in clients, so any node or proxy can impersonate the cluster.
  • One superuser everywhere: the elastic or admin password in every Beats, Logstash and application config, never rotated because nobody knows what would break.
  • Secrets indexed as logs: application logs with bearer tokens and connection strings ingested unmasked, readable by every analyst role. The DeepSeek Database Exposure 2025 shows how quickly exposed logs become a key leak.
  • DLS undone by a second role: a user given a broad readall role for a dashboard, which, because roles combine with OR, removes every document filter on sensitive indices.
  • Audit that looks on but is not: OpenSearch audit.yml enabled without a storage type, or Elasticsearch audit files left on nodes that an attacker controls.

Framework mapping

ControlNIST SP 800-53 Rev. 5NIST CSF 2.0CIS Controls v8.1ISO/IEC 27001:2022 Annex A
Security enabled, SSO, per-client API keysIA-2, IA-5PR.AA-015, 6A.5.16, A.8.5
Least-privilege roles, DLS and FLSAC-6PR.AA-053, 6A.5.15, A.8.3
Private binding, firewalling, IP filteringSC-7PR.PS-014, 12A.8.20, A.8.22
Hardened configuration, destructive-action guardCM-6, CM-7PR.PS-014A.8.9
TLS on REST and transportSC-8PR.DS-023A.8.24
Disk and snapshot encryptionSC-28PR.DS-013A.8.24
Audit logging off-clusterAU-2, AU-12DE.CM-018A.8.15, A.8.16
Patching and supported versionsRA-5, SI-2ID.RA-017A.8.8
Snapshots and restore testsCP-9PR.DS-1111A.8.13

Practitioner checklist

  • Scan for and close every internet-reachable 9200, 9300, Kibana and Dashboards endpoint.
  • Confirm security is explicitly enabled on every cluster and that no deployment template sets xpack.security.enabled: false, plugins.security.disabled or DISABLE_SECURITY_PLUGIN.
  • Replace demo and auto-generated certificates with CA-issued node certificates, enable REST TLS and full verification on transport.
  • Vault the elastic or admin superuser, rotate it, and create named administrators through SSO.
  • Issue each shipper and application its own expiring API key or certificate with write-only or index-scoped roles.
  • Review holders of superuser, all_access and security-management privileges monthly.
  • Apply DLS, FLS or separate indices to sensitive data, and mask secrets and personal data at ingest.
  • Enable audit logging to an off-cluster destination and alert on failed logins, privilege denials and security changes.
  • Encrypt data volumes and snapshot repositories, make snapshots immutable and test restores quarterly.
  • Run supported versions only and patch security advisories within a severity-based SLA.

Standards and references

Related NHI Mgmt Group resources: Database Security Guide · Elastic Security Guide · MongoDB Security Guide · SIEM Guide · Log Management and Retention Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 26 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.