# How can I encrypt the data stored in indexes?

**URL:** <https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691>\
**Category:** Kibana\
**Tags:** kibana-plugin-development\
**Created:** [October 3, 2022, 2:05pm UTC](https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691 "2022-10-03T14:05:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)\
**Post date:** [October 3, 2022, 2:05pm UTC](https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691/1 "2022-10-03T14:05:06Z")

</div>

Hi,

I am developing my own external custom plugin in React.

And I am planning to store personal information of customers and their inventory data as well in Elasticsearch, in addition to logging data. I am planning to implement multi-tenancy as well.

How can I encrypt the data so that sensitive information like passwords will not be visible to the users themselves and other tenants also.

Kingly guide me

Thanks

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [October 3, 2022, 2:22pm UTC](https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691/2 "2022-10-03T14:22:39Z")

</div>

You need to encrypt it before sending to Elasticsearch.

Note that you will also not be able to search on any of those encrypted information.

---

<div class="post-metadata">

**Author:** ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)\
**Post date:** [October 4, 2022, 6:17am UTC](https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691/3 "2022-10-04T06:17:44Z")

</div>

Hi,

Thanks for the reply

So both encryption and decryption, and key management and assignment should be done and maintained by the developer right?

I saw that saved objects can be encryption by mentioning the encryption key in the yml file. Can I store data as saved objects rather than in indices? Or are saved objects a completely different concept ?

Thanks

---

<div class="post-metadata">

**Author:** ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)\
**Post date:** [October 4, 2022, 11:00am UTC](https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691/4 "2022-10-04T11:00:59Z")

</div>

Hi,

I went through 100+ posts on the forum, and this is what I understood regarding encryption in ES

1. Data-in-transit encryption is there in ES
2. Data-at-rest encryption can be implemented in 2 ways:  
a. Manually encrypting data before indexing and decrypting on retrieval  
b. Using OS level encryption (dm-crypt)

I do understand dm-crypt and also that the data will be transparent to authorized ES users. But what happens in between? Meaning how does dm-crypt get the key to encrypt the data and how the data is transparent to ES?

Thanks

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [October 4, 2022, 12:39pm UTC](https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691/5 "2022-10-04T12:39:59Z")

</div>

> [@Sheereen](#):
>
> Data-in-transit encryption is there in ES

Yes, you have encrypted communications between elasticsearch nodes and clients.

> [@Sheereen](#):
>
> Data-at-rest encryption can be implemented in 2 ways:  
> a. Manually encrypting data before indexing and decrypting on retrieval  
> b. Using OS level encryption (dm-crypt)

That's right, if you want to store encrypted data in elasticsearch you will need to encrypt it before you store it or use a OS level encryption.

The OS level encryption is transparent for Elasticsearch and any other software in the system, so if you store a sensitive information in plain text, everyone who is authorized to query on that field will be able to see that information.

What that kind encryption do is to protect your data if your disk is powered off and removed from the system, while it is powered on and in the system, everyone with access to the system may be able to see it.

You can read more about it [here](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/security_hardening/encrypting-block-devices-using-luks_security-hardening), [here](https://www.linux.com/training-tutorials/how-encrypt-linux-file-system-dm-crypt/#:~:text=The%20dm-crypt%20system%20sits,of%E2%80%9D%20the%20encrypted%20LUKS%20format.) and [here](https://discuss.elastic.co/t/how-should-i-encrypt-data-at-rest-with-elasticsearch/96).

---

<div class="post-metadata">

**Author:** ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)\
**Post date:** [October 4, 2022, 1:32pm UTC](https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691/6 "2022-10-04T13:32:25Z")

</div>

Thanks a lot Leandro for the detailed explanation.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 1, 2022, 1:32pm UTC](https://discuss.elastic.co/t/how-can-i-encrypt-the-data-stored-in-indexes/315691/7 "2022-11-01T13:32:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
