# Elasticsearch Injection Attacks

**URL:** <https://discuss.elastic.co/t/elasticsearch-injection-attacks/79759>\
**Category:** Elasticsearch\
**Created:** [March 23, 2017, 2:11pm UTC](https://discuss.elastic.co/t/elasticsearch-injection-attacks/79759 "2017-03-23T14:11:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JagjitSingh1](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@JagjitSingh1](https://discuss.elastic.co/u/JagjitSingh1)\
**Post date:** [March 23, 2017, 2:11pm UTC](https://discuss.elastic.co/t/elasticsearch-injection-attacks/79759/1 "2017-03-23T14:11:23Z")

</div>

**INTRODUCTION:**

We have a system where we store job applications from candidates into Elasticsearch. We further present all candidates who have applied for a job in a candidate list(grid with candidates).

We also have a search field on the same site where we can filter candidates. We are actually making full text search to match candidates based on the input from the user.

**MORE DETAILS:**

So, the users can enter input. Right now, we are using the input from users directly in a query to Elasticsearch, for example:

```
queryStringQuery = new QueryStringQuery
{
      Fields = new Field("firstName").And("lastName").And("education").And("workExperience").And("currentPosition").And("currentEmployer").And("attachments.attachment.content"),
      Query = "*" + query.Freetext + "*" 
}; 

```

If you look at the **Query** parameter, you can notice that we are setting it to **query.Freetext** (Which is input from the user).

The user can input malicious content ( Injection Attack ).

**QUESTION:**

**How does Elasticsearch handle mailicious content in the query? What can I do to prevent it?**

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 23, 2017, 3:09pm UTC](https://discuss.elastic.co/t/elasticsearch-injection-attacks/79759/2 "2017-03-23T15:09:03Z")

</div>

What kind of malicious content you think they can send here?

---

<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:** [April 20, 2017, 3:09pm UTC](https://discuss.elastic.co/t/elasticsearch-injection-attacks/79759/3 "2017-04-20T15:09:04Z")

</div>

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