Secure an AtlasMart Elasticsearch deployment from first boot by separating HTTP TLS, transport TLS, certificate trust, enrollment/bootstrap artifacts, realms, and long-lived application identities.
Secure-by-Default Principles, Node/HTTP TLS, Certificates, Trust, and Enrollment/Bootstrap Concepts
Design equivalent AtlasMart retention intent in Elastic and OpenSearch while documenting non-equivalent lifecycle, tiering, policy-update, simulation, and managed-service behavior.
Learning outcomes
AtlasMart’s developers can reach a fresh Elasticsearch node, but
the first implementation stores the
elastic superuser password in an application
environment file and disables certificate verification because
“it is only internal.” That collapses bootstrap authority,
transport trust and application identity into one secret. This
lesson separates those mechanisms before any application role is
created.
Distinguish HTTP TLS from transport TLS and explain which peers each channel authenticates.
Validate an Elasticsearch HTTP certificate against the generated CA instead of bypassing verification.
Explain first-start security auto-configuration, the elastic bootstrap administrator and short-lived enrollment tokens.
Separate certificate trust, user authentication, realms and role authorization as independent controls.
Replace the superuser-as-application anti-pattern with a staged least-privilege identity plan.
Examples target the official self-managed
Elasticsearch 9.5.3 / Kibana 9.5.3
distribution, reviewed 11 September 2026. The lab reuses
atlasmart-es at
https://localhost:9200, the generated HTTP CA
copied earlier as atlasmart-es-http-ca, and
ELASTIC_PASSWORD only as a bootstrap
administrator credential. Use curl --cacert;
never teach -k as an Elasticsearch security
shortcut. The official distribution includes a bundled OpenJDK
and Elastic recommends using it; no external JVM is required
by this lab. Kibana examples assume 9.5.3 when UI behavior
matters. OpenSearch 3.8.0 is mentioned only to mark
non-portable boundaries; Chapter 20 teaches its Security
plugin separately.
Encrypted communications, native/file authentication, core role-based access control, Kibana Spaces, and API-key management are available in the free Basic self-managed distribution. Document/field-level security and Elasticsearch/Kibana audit logging are subscription-sensitive features; verify the current Elastic subscription matrix for your deployment before using them as mandatory controls. The mandatory lab therefore succeeds on Basic with index-level RBAC, separate identities and short-lived API keys, and presents DLS/FLS/audit as an optional extension plus a deterministic fallback.
Never paste passwords, API-key secrets, service tokens, private keys or CA private material into lesson HTML, source control, shell transcripts or screenshots. The examples use environment variables and display only identifiers or expected response shapes.
The generation environment does not run the AtlasMart Docker cluster, so requests are deterministic lab instructions and response fragments are expected shapes/invariants, not fabricated captures. Record your own certificate fingerprints/expiry, 401/403 evidence, key identifiers/expiration, audit events where licensed, and application p95/p99 latency under authenticated load.
1. Start with channels, not usernames
Elasticsearch has two network planes that are easy to conflate. The HTTP layer is the REST interface used by applications, Kibana and administrators, normally on port 9200. The transport layer is Elasticsearch’s internal node-to-node protocol, normally on port 9300. In a secured multi-node cluster, transport uses mutual TLS so cluster members authenticate each other. HTTP TLS encrypts and authenticates the server to clients and can optionally participate in client-certificate authentication when PKI realms are configured.
| Control | Question answered | AtlasMart rule |
|---|---|---|
| HTTP TLS | Is this client talking to the intended Elasticsearch endpoint over an encrypted channel? | Trust the generated HTTP CA; no -k. |
| Transport TLS | Are participating nodes authenticated/encrypted members of the same cluster trust domain? | Use the cluster transport CA/certificates; not application credentials. |
| Authentication | Who is making this request? | Native user, API key, token, service account, realm-backed identity, etc. |
| Authorization | What may that identity do? | Roles/privileges decide cluster, index, application and run-as actions. |
| Audit | What security-relevant event was recorded? | A separate observable control; availability depends on subscription/configuration. |
2. Observe automatic security setup without turning it into permanent architecture
On a first eligible self-managed start, Elasticsearch 9.5.3 can
automatically enable security, generate HTTP and transport
certificates, configure TLS settings, set the
elastic superuser password, and create a Kibana
enrollment token. An enrollment token is a bootstrap artifact
used to establish trusted initial configuration; it is not a
reusable application bearer token. Kibana enrollment tokens are
short-lived (the current auto-setup documentation states 30
minutes).
# PowerShell/Git Bash variables are examples; do not commit their values.
export ES_URL="https://localhost:9200"
export ES_CA="/path/to/http_ca.crt"
export ELASTIC_USER="elastic"
# ELASTIC_PASSWORD should come from your local secret store/session.
curl --fail --silent --show-error \
--cacert "$ES_CA" \
-u "$ELASTIC_USER:$ELASTIC_PASSWORD" \
"$ES_URL/_security/_authenticate?pretty"
Expected invariant: the call succeeds only when both the TLS trust decision and the credential are valid. The authentication response identifies the principal, authentication realm/type and roles. It does not prove the principal is least-privileged.
3. Prove certificate trust instead of disabling it
openssl s_client \
-connect localhost:9200 \
-CAfile "$ES_CA" \
-verify_return_error \
-servername localhost </dev/null
Capture the subject/SAN, issuer, validity dates and verification
result. A certificate can be cryptographically valid but still
be wrong for the hostname; hostname verification is part of
server identity. If your production clients connect through
search.atlasmart.example, the certificate must be
valid for that name rather than merely for
localhost.
# WRONG: this removes server-certificate verification.
curl -k -u "$ELASTIC_USER:$ELASTIC_PASSWORD" https://localhost:9200/
# CORRECT: trust the CA that signed the server certificate.
curl --cacert "$ES_CA" -u "$ELASTIC_USER:$ELASTIC_PASSWORD" "$ES_URL/"
CA verification proves that the presented certificate chains to a trusted issuer and matches the endpoint identity under the client’s verification rules. It does not prove the application credential is appropriately scoped; authorization is tested separately.
4. Realms identify users; roles authorize them
A realm is an authentication mechanism that can identify users. Native and file realms are straightforward self-managed choices; other realm types such as LDAP/Active Directory, PKI, SAML/OIDC/JWT/Kerberos have distinct configuration and subscription/deployment constraints. Do not design “LDAP role JSON” as if realm configuration and RBAC are the same layer. A user can authenticate successfully and still receive a 403 because its roles do not authorize the requested action.
GET /_security/_authenticate
GET /_security/user
GET /_security/role
The chapter’s mandatory lab uses the native realm for reproducibility. That is a learning choice, not a claim that every production organization should manage human identities natively.
5. Bootstrap authority is intentionally too powerful for applications
The built-in elastic superuser is appropriate for
controlled bootstrap and emergency administration. It is
deliberately inappropriate for AtlasMart search or ingest
processes because compromise grants cluster-wide authority. The
correct progression is: bootstrap securely, create narrow roles
and identities, validate forbidden operations, create/rotate
machine credentials, then reduce how often humans need the
bootstrap credential.
PUT atlasmart-products-secure-v1
{
"settings": {"number_of_shards": 1, "number_of_replicas": 0},
"mappings": {
"dynamic": "strict",
"properties": {
"sku": {"type":"keyword"},
"name": {"type":"text", "fields":{"keyword":{"type":"keyword"}}},
"category": {"type":"keyword"},
"tenant_id": {"type":"keyword"},
"price": {"type":"scaled_float", "scaling_factor":100},
"cost_internal": {"type":"scaled_float", "scaling_factor":100},
"updated_at": {"type":"date"}
}
}
}
6. Boundary: Elastic security APIs are not OpenSearch Security APIs
OpenSearch 3.8.0 uses the OpenSearch Security plugin with its
own certificates, internal users, roles, role mappings, tenants
and REST APIs. Shared ancestry does not make
/_security/role, Elastic enrollment tokens, Elastic
service accounts or Kibana Spaces portable. Chapter 20 builds
the OpenSearch model directly. This chapter compares only enough
to prevent accidental cross-product assumptions.
7. Production judgment
Certificate rotation, CA ownership, private-key storage, network exposure, reverse proxies/load balancers and managed-cloud boundaries belong in the threat model. Monitor certificate expiry before outages occur. Separate administrator endpoints from application paths where network controls permit. Measure authentication/TLS overhead in the real topology, but do not trade server identity verification for marginal latency.
Check your understanding
- Why are HTTP TLS and transport TLS separate concepts?
- What does the automatic enrollment token represent?
- Why is curl -k unsafe as a normal lab pattern?
- Does successful /_security/_authenticate prove least privilege?
- Why not keep using elastic in AtlasMart services?
Review the answers
1. HTTP TLS protects client-to-Elasticsearch REST traffic; transport TLS protects/authenticates node-to-node cluster traffic.
2. A short-lived bootstrap mechanism for initial trusted enrollment, not a reusable application credential.
3. It disables certificate verification and teaches clients to accept an unauthenticated endpoint.
4. No. It proves authentication; authorization must be tested with allowed and forbidden operations.
5. Its superuser blast radius is far larger than an application needs; dedicated roles/keys make compromise and rotation containable.
Summary and next step
Preserve the evidence, assumptions, version boundaries, and safety checks established in this lesson. Carry them into the next lesson—or, at the end of the capstone, into the production runbook—rather than treating this lesson as an isolated recipe.
References
- Elastic: Secure your cluster — Current security architecture and deployment-type responsibility.
- Elastic: Automatic security setup — First-start TLS, elastic password, and Kibana enrollment-token behavior.
- Elastic: TLS for cluster communications — HTTP versus transport TLS and trust boundaries.
- Elastic: Users and roles — Authentication and RBAC model.
- Elasticsearch privileges reference — Cluster, index, application and run-as privilege semantics.
- Elastic: API key API — Expiration and role-descriptor scoping.
- Elastic: Service accounts — Predefined service accounts and service tokens.
- Elastic: DLS/FLS — Read-oriented document/field restrictions and limitations.
- Elastic: Run as — Delegated request semantics and supported authenticators.
- Elastic: Audit logging — Audit-event configuration and subscription notice.
- Elastic self-managed subscriptions — Current Basic/paid feature boundaries.
- Elastic downloads — Pinned Elasticsearch 9.5.3 release baseline.