漏洞描述:
ElasticSearch是一個基於Lucene的搜索服務器。它提供了一個分布式多用戶能力的全文搜索引擎,基於RESTful web接口。Elasticsearch是用Java開發的,並作為Apache許可條款下的開放源碼發布,是當前流行的企業級搜索引擎。Elasticsearch的增刪改查操作全部由http接口完成。由於Elasticsearch授權模塊需要付費,所以免費開源的Elasticsearch可能存在未授權訪問漏洞。該漏洞導致,攻擊者可以擁有Elasticsearch的所有權限。可以對數據進行任意操作。業務系統將面臨敏感數據泄露、數據丟失、數據遭到破壞甚至遭到攻擊者的勒索。
Elasticsearch服務普遍存在一個未授權訪問的問題,攻擊者通常可以請求一個開放9200或9300的服務器進行惡意攻擊。
漏洞檢測:
漏洞檢測:
http://101.198.161.xxx:9200/_cat/indices/
http://101.198.161.xxx:9200/_plugin/head/
http://101.198.161.xxx:9200/_nodes/
http://101.198.161.xxx:9200/_status
http: //101.198.161.xxx:9200/_search?pretty
如圖即為未授權訪問:
漏洞修復:
1.限制IP訪問,禁止未授權IP訪問ElasticSearch端口(默認9200)。
2.通過ES插件形式來增加訪問驗證,需要注意增加驗證后切勿使用弱口令:
①shield插件,收費,暫不考慮。
②針對1.7.0版本之前的ElasticSearch,可采用elasticsearch-http-basic插件。
下載地址:https://github.com/Asquera/elasticsearch-http-basic/releases
elasticsearch-http-basic和其他ES插件一樣,安裝在plugins文件夾下以后,在config/elasticsearch.yml中統一配置:
http.basic.enabled true #開關,開啟會接管全部HTTP連接
http.basic.user “admin” #賬號
http.basic.password “admin_pw” #密碼
http.basic.ipwhitelist [“localhost”, “127.0.0.1”] #白名單內的IP訪問不需要通過賬號和密碼,支持IP和主機名,不支持IP區間或正則。
③針對elasticsearch2.x以后的版本可采用search-guard插件。
同樣在config/elasticsearch.yml中統一配置,在末尾追加以下內容:
searchguard.ssl.transport.pemcert_filepath: certificates/esnode.pem
searchguard.ssl.transport.pemkey_filepath: certificates/esnode-key.pem
searchguard.ssl.transport.pemtrustedcas_filepath: certificates/root-ca.pem
searchguard.ssl.transport.enforce_hostname_verification: false
searchguard.ssl.http.enabled: true
searchguard.ssl.http.pemcert_filepath: certificates/esnode.pem
searchguard.ssl.http.pemkey_filepath: certificates/esnode-key.pem
searchguard.ssl.http.pemtrustedcas_filepath: certificates/root-ca.pem
searchguard.allow_unsafe_democertificates: true
searchguard.allow_default_init_sgindex: true
searchguard.authcz.admin_dn:
- CN=kirk,OU=client,O=client,L=test,C=de
searchguard.enable_snapshot_restore_privilege: true
searchguard.check_snapshot_restore_write_privileges: true
searchguard.restapi.roles_enabled: ["sg_all_access"]
配置完成之后,默認訪問口令為”username:admin,pwd:admin”,修改默認admin密碼操作可參考https://blog.csdn.net/lu_wei_wei/article/details/100727090
3.架設nginx反向代理服務器,並設置http basic認證來實現elasticsearch的登錄認證。(具體可參考原文地址:https://www.sojson.com/blog/213.html)