弹性搜索索引经常被删除

Pra*_*ara 60 elasticsearch

我正在 google-cloud 上对个人项目运行弹性搜索,并将其用作我的应用程序的搜索索引。从过去 3 天开始,索引被神秘地删除了。我不知道为什么,我查看了所有删除索引调用的代码,还查看了日志。还是想不通。有什么想法吗?我该如何调试?

[2020-07-24T00:00:27,451][INFO ][o.e.c.m.MetaDataDeleteIndexService] [node-1] [users_index_2/veGpdqbNQA2ZcnrrlGIA_Q] deleting index
[2020-07-24T00:00:27,766][INFO ][o.e.c.m.MetaDataDeleteIndexService] [node-1] [blobs_index_2/SiikUAE7Rb6gS3_UeIwElQ] deleting index
[2020-07-24T00:00:28,179][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [gk01juo8o3-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:28,776][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [28ds9nyf8x-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:29,328][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [hw2ktibxpl-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:29,929][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [va0pzk1hfi-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:30,461][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [ruwhw3jcx0-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:30,973][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [wx4gylb2jv-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:31,481][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [hbbmszdteo-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:31,993][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [1gi0x5277l-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:32,494][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [sotglodbi9-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:33,012][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [khvzsxctwr-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:33,550][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [hgrhythm3g-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:34,174][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [ejyucop7ag-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:34,715][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [n1bgkmqp8r-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:35,241][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [vsw49c4kpp-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:35,747][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [qrb5x89icr-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:36,261][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [pv8n84itx6-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:36,856][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [wnnwmylxvs-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:37,392][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [g5tw6w2tqb-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:37,889][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [u7tobv31o2-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:38,474][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [ufvizrnmez-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T00:00:38,946][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [0i9wszne7l-meow] creating index, cause [api], templates [], shards [1]/[1], mappings []
[2020-07-24T01:30:00,001][INFO ][o.e.x.m.MlDailyMaintenanceService] [node-1] triggering scheduled [ML] maintenance tasks
[2020-07-24T01:30:00,002][INFO ][o.e.x.m.a.TransportDeleteExpiredDataAction] [node-1] Deleting expired data
[2020-07-24T01:30:00,010][INFO ][o.e.x.m.a.TransportDeleteExpiredDataAction] [node-1] Completed deletion of expired ML data
[2020-07-24T01:30:00,011][INFO ][o.e.x.m.MlDailyMaintenanceService] [node-1] Successfully completed [ML] maintenance tasks
[2020-07-24T01:30:00,039][INFO ][o.e.x.s.SnapshotRetentionTask] [node-1] starting SLM retention snapshot cleanup task
[2020-07-24T01:37:43,817][INFO ][o.e.c.m.MetaDataCreateIndexService] [node-1] [.kibana] creating index, cause [auto(bulk api)], templates [], shards [1]/[1], mappings []
Run Code Online (Sandbox Code Playgroud)

Sha*_*ine 118

看起来你被喵攻击击中

在公共网络上公开的数百个不安全的数据库是自动“喵”攻击的目标,这种攻击会在没有任何解释的情况下破坏数据。

该活动最近开始于攻击 Elasticsearch 和 MongoDB 实例,没有留下任何解释,甚至没有勒索。攻击随后扩展到其他数据库类型和在网络上打开的文件系统。

从这条推文中,您可以看到您遇到了与这些攻击相同的行为:

从 MongoDB 的日志中,您可以看到它先删除数据库,然后使用 $randomstring-meow 创建新数据库

请确保您没有为您的数据库使用默认用户名和密码,并且您的配置已设置为避免面向公众的交互。如果您需要访问您的数据库,请使用具有基于密钥的身份验证的 API,并且仅允许使用最低限度的功能。

编辑#1:您可以obvserve的攻击数据库这里shodan.io

编辑 #2:一些关于防止这种(和其他)攻击的建议(来自 HackerNews 用户contrarianmop):

此外,根据经验,如果托管 Web 应用程序,除了端口 80 和 443 之外,永远不会公开任何内容。

如果您必须公开除 http/s 之外的服务,请确保不要泄露其版本,确保其得到妥善保护并始终保持最新。运行此类服务的用户也应该是非特权用户,守护进程 chroot,并且操作系统应该具有适当的进程和文件系统权限。

编辑#3:一个有趣的理论,为什么攻击者使用的术语“喵”,是因为猫喜欢下降从(或击倒)项目

  • 从 6.8 开始,elasticsearch 的默认发行版中的安全性是免费的。所以防御喵喵的能力是免费的。请查看 https://www.elastic.co/blog/how-to-prevent-elasticsearch-server-breach-securing-elasticsearch 了解如何防止 Elasticsearch 服务器泄露。 (19认同)
  • @user5994461 那么你可能不应该在面向互联网的服务器上使用它,是吗? (14认同)
  • `“喵”这个词是因为猫喜欢从桌子上掉落(或敲击)物品`呵呵。我很少听说 SQL 服务器,但实际上它被称为“表”。 (5认同)
  • 这是一个很好的通用建议...除了 ElasticSearch 既不支持密码也不支持 api 密钥身份验证(在大多数人使用的免费版本中)。 (4认同)

dad*_*net 46

正如这里的一些人所回答的,您的集群已被 meow 攻击

从 6.8 开始,在 elasticsearch 的默认发行版中可以免费获得安全性。所以保护免受喵喵叫的能力是免费的。查看此博客文章,了解如何防止 Elasticsearch 服务器泄露。

更新:Elastic 还发布了一篇新的博客文章,介绍了这种特定的 Meow 攻击


dij*_*uis 27

你被喵喵叫了

https://www.bleepingcomputer.com/news/security/new-meow-attack-has-deleted-almost-4-000-unsecured-databases/

仔细检查所有配置(防火墙、弹性搜索等)以确保实例不可公开访问,并且对弹性搜索的访问是安全的(必须事先没有)。


use*_*461 13

注意:我刚刚在Hacker News上看到了您的问题,即将获得大量访问和建议。

弹性数据库正在被喵喵删除,这是一项扫描互联网以查找开放数据库并删除它们的新操作。见新“喵喵”的攻击已经删除了近4000名无担保数据库

这里有两个问题:

  1. 数据库完全暴露在互联网上。

  2. 数据库不受任何形式的身份验证或访问控制的保护。

你需要做什么:

  1. 断开数据库与 Internet 的连接。如果它在 Google Cloud 上运行,则实例甚至不应该有公共地址,数据库应该位于内部网络 (VPC) 中。

  2. 限制对数据库的访问。

不幸的是,最后一点说起来容易做起来。ElasticSearch在免费版中不支持任何形式的访问控制,假设您拥有免费版。

您可以采取的措施是对实例进行严格的防火墙设置以限制访问。使用 Google/AWS/Azure 中的防火墙功能很容易做到这一点。ElasticSearch 通常为客户端侦听端口 9200,为复制侦听端口 9300 或 9350。唯一需要访问的客户端通常是 kibana 来查看日志和 logstash/fluentd 来摄取日志,这只是允许流量的几个 IP。

如果您在企业工作,所有生产数据库都必须进行身份验证才能满足各种规定,因此您必须支付企业许可证并配置密码或证书身份验证。

  • 从 6.8 开始,elasticsearch 的默认发行版中的安全性是免费的。所以防御喵喵的能力是免费的。请查看 https://www.elastic.co/blog/how-to-prevent-elasticsearch-server-breach-securing-elasticsearch 了解如何防止 Elasticsearch 服务器泄露。 (7认同)

小智 9

更新:正如在各种答案和论坛中提到的,由于喵喵攻击,索引被删除,请关注Elasticsearch 的官方博客,了解如何自由保护您的 ES 集群免受这些攻击

旧答案:

如果您没有在应用程序中创建基于日期的索引,请尝试查看您是否偶然配置了索引生命周期管理策略

刚刚查看了您的日志,这些清楚地表明您的 ES 正在删除索引,请参阅日志中的以下几行来解释这一点。

[2020-07-24T00:00:27,451][INFO][oecmMetaDataDeleteIndexService] [node-1] [users_index_2/veGpdqbNQA2ZcnrrlGIA_Q] 删除索引 [2020-07-24T00:00:00:06:27,IndexService][node-1] [users_index_2/veGpdqbNQA2ZcnrrlGIA_Q] ] [blobs_index_2/SiikUAE7Rb6gS3_UeIwElQ] 删除索引


Jos*_*ody 6

如果您的 ES 实例运行在免费版(以及 6.8 之前的版本)上,它可能会受到“喵喵攻击”的打击,因为 ES 免费版不支持任何类型的访问控制

如果它没有在免费版上运行,或者被锁定在某种 VPC 后面,或者没有通过 80 或 443 暴露,但它仍然掉线,那么就会有更大的问题。

  • 从 6.8 开始,elasticsearch 的默认发行版中的安全性是免费的。所以防御喵喵的能力是免费的。请查看 https://www.elastic.co/blog/how-to-prevent-elasticsearch-server-breach-securing-elasticsearch 了解如何防止 Elasticsearch 服务器泄露。 (9认同)