ElasticSearch单机或集群未授权访问漏洞

漏洞处理方法:

1、可以使用系统防火墙

来做限制只允许ES集群和Server节点的IP来访问漏洞节点的9200端口,其他的全部拒绝。

2、在ES节点上设置用户密码

漏洞现象:直接访问9200端口不需要密码验证

修复过程

2.1 生成认证文件

必须要生成认证文件,且ES配置文件里要引用这些生成的认证文件,否则启动ES的时候,日志会报错:Caused by: javax.net.ssl.SSLHandshakeException: No available authentication scheme。
CA 证书

[root@node1 elasticsearch-7.6.2]# su es
[es@node1 elasticsearch-7.6.2]$ ./bin/elasticsearch-certutil ca
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.

The 'ca' mode generates a new 'certificate authority'
This will create a new X.509 certificate and private key that can be used
to sign certificate when running in 'cert' mode.

Use the 'ca-dn' option if you wish to configure the 'distinguished name'
of the certificate authority

By default the 'ca' mode produces a single PKCS#12 output file which holds:
    * The CA certificate
    * The CA's private key

If you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the CA certificate and private key

Please enter the desired output file [elastic-stack-ca.p12]: 
Enter password for elastic-stack-ca.p12 :

在这里插入图片描述

2.2 生成p12密钥

使用第一步生成的证书,生成p12秘钥

[es@node1 elasticsearch-7.6.2]$ ./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.

The 'cert' mode generates X.509 certificate and private keys.
    * By default, this generates a single certificate and key for use
       on a single instance.
    * The '-multiple' option will prompt you to enter details for multiple
       instances and will generate a certificate and key for each one
    * The '-in' option allows for the certificate generation to be automated by describing
       the details of each instance in a YAML file

    * An instance is any piece of the Elastic Stack that requires an SSL certificate.
      Depending on your configuration, Elasticsearch, Logstash, Kibana, and Beats
      may all require a certificate and private key.
    * The minimum required value for each instance is a name. This can simply be the
      hostname, which will be used as the Common Name of the certificate. A full
      distinguished name may also be used.
    * A filename value may be required for each instance. This is necessary when the
      name would result in an invalid file or directory name. The name provided here
      is used as the directory name (within the zip) and the prefix for the key and
      certificate files. The filename is required if you are prompted and the name
      is not displayed in the prompt.
    * IP addresses and DNS names are optional. Multiple values can be specified as a
      comma separated string. If no IP addresses or DNS names are provided, you may
      disable hostname verification in your SSL configuration.

    * All certificates generated by this tool will be signed by a certificate authority (CA).
    * The tool can automatically generate a new CA for you, or you can provide your own with the
         -ca or -ca-cert command line options.

By default the 'cert' mode produces a single PKCS#12 output file which holds:
    * The instance certificate
    * The private key for the instance certificate
    * The CA certificate

If you specify any of the following options:
    * -pem (PEM formatted output)
    * -keep-ca-key (retain generated CA key)
    * -multiple (generate multiple certificates)
    * -in (generate certificates from an input file)
then the output will be be a zip file containing individual certificate/key files

Enter password for CA (elastic-stack-ca.p12) : 

Please enter the desired output file [elastic-certificates.p12]: 
Enter password for elastic-certificates.p12 : 

Certificates written to /home/elasticsearch-7.6.2/elastic-certificates.p12

This file should be properly secured as it contains the private key for 
your instance.

This file is a self contained file and can be copied and used 'as is'
For each Elastic product that you wish to configure, you should copy
this '.p12' file to the relevant configuration directory
and then follow the SSL configuration instructions in the product guide.

For client applications, you may only need to copy the CA certificate and
configure the client to trust this certificate.

在这里插入图片描述

2.3 将p12认证文件copy到其他节点

[es@node1 elasticsearch-7.6.2]$ cd config/
[es@node1 config]$ ll
total 36
-rw-rw---- 1 es es  3284 Dec 14 07:49 elasticsearch.yml
-rw-rw---- 1 es es  2301 Mar 26  2020 jvm.options
-rw-rw---- 1 es es 17545 Mar 26  2020 log4j2.properties
-rw-rw---- 1 es es   473 Mar 26  2020 role_mapping.yml
-rw-rw---- 1 es es   197 Mar 26  2020 roles.yml
-rw-rw---- 1 es es     0 Mar 26  2020 users
-rw-rw---- 1 es es     0 Mar 26  2020 users_roles
[es@node1 config]$ mkdir certs
[es@node1 config]$ cp ../elastic-certificates.p12 certs/
[root@node1 elasticsearch-7.6.2]# scp -r config node2:/home/elasticsearch-7.6.2/
log4j2.properties                                                                                100%   17KB  12.2MB/s   00:00    
users_roles                                                                                      100%    0     0.0KB/s   00:00    
roles.yml                                                                                        100%  197   406.7KB/s   00:00    
users                                                                                            100%    0     0.0KB/s   00:00    
role_mapping.yml                                                                                 100%  473     1.0MB/s   00:00    
elasticsearch.yml                                                                                100% 3284     3.2MB/s   00:00    
jvm.options                                                                                      100% 2301     4.4MB/s   00:00    
elastic-certificates.p12                                                                         100% 3443     3.1MB/s   00:00    
[root@node1 elasticsearch-7.6.2]# scp -r config node3:/home/elasticsearch-7.6.2/
log4j2.properties                                                                                100%   17KB  14.6MB/s   00:00    
users_roles                                                                                      100%    0     0.0KB/s   00:00    
roles.yml                                                                                        100%  197   492.4KB/s   00:00    
users                                                                                            100%    0     0.0KB/s   00:00    
role_mapping.yml                                                                                 100%  473     1.1MB/s   00:00    
elasticsearch.yml                                                                                100% 3284     2.7MB/s   00:00    
jvm.options                                                                                      100% 2301     5.0MB/s   00:00    
elastic-certificates.p12                                                                         100% 3443     3.9MB/s   00:00    
[root@node1 elasticsearch-7.6.2]#

2.4 修改所有ES节点配置文件

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

在这里插入图片描述

2.5 启动集群各节点

[es@node1 elasticsearch-7.6.2]$ ./bin/elasticsearch -d

2.6 自动生成密码

集群也是一台节点生成密码即可

[es@node1 elasticsearch-7.6.2]$ ./bin/elasticsearch-setup-passwords auto
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
The passwords will be randomly generated and printed to the console.
Please confirm that you would like to continue [y/N]y


Changed password for user apm_system
PASSWORD apm_system = BY8QVLtnyPiIKQKWB9TH

Changed password for user kibana
PASSWORD kibana = 4MLTzLOC6LGYHkGw0YuW

Changed password for user logstash_system
PASSWORD logstash_system = GatyQw87IIPPs8dNReSf

Changed password for user beats_system
PASSWORD beats_system = WsahN3DcIKa4514sxv4n

Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = KBqzFIkgkxytVpswaJW6

Changed password for user elastic
PASSWORD elastic = ltwcC9q77f0yZMV9CPWl

[es@node1 elasticsearch-7.6.2]$

在这里插入图片描述

3、验证漏洞是否修复成功

在这里插入图片描述

[es@node1 elasticsearch-7.6.2]$ curl http://192.168.200.167:9200/_cat/indices?pretty  -u elastic
### 回答1: elasticsearch授权访问漏洞是指在elasticsearch服务器上,由于正确配置访问控制,导致攻击者可以通过简单的HTTP请求获取敏感数据或者进行恶意操作的漏洞。这种漏洞可能会导致数据泄露、篡改、删除等安全问题,因此需要及时修复。建议管理员对elasticsearch服务器进行安全加固,限制访问权限,避免出现授权访问漏洞。 ### 回答2: Elasticsearch是一种流行的开源分布式搜索和分析引擎,具有高性能和可扩展性。然而,由于管理不当和配置错误,可能会导致elasticsearch授权访问漏洞漏洞,允许恶意攻击者访问敏感数据,并对系统造成损害。 当elasticsearch集群没有正确配置安全性控制时,攻击者可以轻松地通过网络访问elasticsearch集群,然后使用静态或动态的scripting引擎,执行任意代码,包括创建、修改或删除数据。攻击者还可以使用elasticsearch的API执行一些危险操作,例如下达搜索查询,误删除数据,或利用任意文件读取漏洞访问系统文件。 为了避免elasticsearch授权访问漏洞,需要采取一些安全措施: 1. 配置安全性控制:确保只有授权用户才能访问elasticsearch集群,这可以使用访问控制列表(ACL)来实现。禁用默认的授权模式,并使用X-Pack来加密通信,保护通信机密性。 2. 删除不必要的插件:一些插件可能存在安全漏洞,应该删除不需要的插件,并确保保持最新的安全补丁。 3. 监控日志:监控elasticsearch集群日志,早期检测和响应可能的攻击行为。 4. 更新软件:更新elasticsearch软件,保持最新版本,以便及时修补已知的安全漏洞。 总之,elasticsearch授权访问漏洞是一种严重的安全漏洞,攻击者可以访问系统中的敏感数据和文件,并且对系统造成严重的损害。为了避免这种漏洞,应该采取安全措施,并优化elasticsearch集群的配置。 ### 回答3: elasticsearch是目前世界上最受欢迎的开源搜索引擎之一,它支持快速的分布式搜索和分析功能。但是,由于其默认配置存在漏洞,攻击者可以通过授权访问elasticsearch导致数据泄露或文件损坏等安全问题。 elasticsearch授权访问漏洞的成因是在线上环境中,elasticsearch默认的配置不是禁止外部访问的,只要攻击者可以通过网络访问elasticsearch的IP和端口,就可以执行各种命令。例如,攻击者可以通过浏览器URL或专门的工具(如curl)发送HTTP请求,获取敏感数据、删除索引、修改设置等,通过执行这些操作,攻击者可以轻易地导致数据丢失或系统崩溃等安全问题。 为了防止elasticsearch授权访问漏洞,需要合理地配置elasticsearch,安全地部署elasticsearch,并定期检查和更新新版本。以下是一些预防措施: 1.禁用外部访问:为elasticsearch配置只在本地使用时可以使用的IP地址,使其只能在服务器上本地访问到,其他IP地址就不能访问。 2.限制访问:为elasticsearch配置访问授权规则,只允许特定的客户端或IP地址进行访问操作。 3.强身鉴定:开启elasticsearch的身份认证机制,例如使用用户名和密码进行身份验证,可以避免授权访问。 4.安装热更新:对于已知问题,elasticsearch通常会及时发布新版本,以修补漏洞和增强安全性能。安装最新版的elasticsearch可以有效地提高安全性。 总之,任何系统都存在潜在的安全风险,我们需要定期更新、监控、维护这些先进的技术,以保护我们的系统和数据免受数据泄露、文件损坏等安全问题的影响。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值