# Delete By Query Request Run on Alias needs Security Rights to Index

**URL:** <https://discuss.elastic.co/t/delete-by-query-request-run-on-alias-needs-security-rights-to-index/102480>\
**Category:** Elasticsearch\
**Created:** [October 2, 2017, 8:06pm UTC](https://discuss.elastic.co/t/delete-by-query-request-run-on-alias-needs-security-rights-to-index/102480 "2017-10-02T20:06:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cvarberg](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@cvarberg](https://discuss.elastic.co/u/cvarberg)\
**Post date:** [October 2, 2017, 8:06pm UTC](https://discuss.elastic.co/t/delete-by-query-request-run-on-alias-needs-security-rights-to-index/102480/1 "2017-10-02T20:06:16Z")

</div>

**Elasticsearch version** : 5.5.1

**JVM version** : 1.8.0\_131

**OS version** : CentOS 7.3.1611

**Description** :

In order to run the \_delete\_by\_query on an alias the user needs "delete" privileges to the actual index. I would expect that as long as the user has read/write rights to the alias they would be able to run a \_delete\_by\_query. It is also confusing as the request will return a 200 OK as long as there isn't actually anything to delete. If it finds something to delete then it fails out with a 403 Forbidden. I'm assuming once it finds something to delete it is trying to issue the actual delete on the index instead of the alias.

I am specifically trying to do this with a filtered alias, but I have tested it with a non filtered alias and the same results are seen

**Steps to reproduce** :

1. Create a new index `PUT testindex`
2. Add an alias `POST testindex/_alias/testalias`
3. Create role with read and write rights to alias  
`POST _xpack/security/role/testRole { "indices": [{ "names": [ "testalias"], "privileges": ["write", "read"] } ] }`
4. Create user with the role just created  
`POST _xpack/security/user/testUser { "roles": ["testRole"], "password": "elastic" }`
5. Run \_delete\_by\_query on alias using new user (200 OK is returned)  
`POST testalias/_delete_by_query { "query":{ "match_all": {} } }`
6. Add document to index  
`GET testindex/testtype/1 { "name": "test" }`
7. rerun \_delete\_by\_query on Alias with same user (403 Forbidden Returned)

**Error Message** :

`{ "index": "testindex", "type": "testtype", "id": "1", "cause": { "type": "security_exception", "reason": "action [indices:data/write/bulk[s]] is unauthorized for user [testUser]" }, "status": 403 }`

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [October 3, 2017, 4:43pm UTC](https://discuss.elastic.co/t/delete-by-query-request-run-on-alias-needs-security-rights-to-index/102480/2 "2017-10-03T16:43:33Z")

</div>

Hmm - I agree that you should get the same result for empty and non-empty indices. I agree that for consistency's sake we should allow it if you have permissions on the alias. I don't particularly like it because it feels tricky but if we can manage to fix it in a safe way then we will.

---

<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:** [October 31, 2017, 4:43pm UTC](https://discuss.elastic.co/t/delete-by-query-request-run-on-alias-needs-security-rights-to-index/102480/3 "2017-10-31T16:43:41Z")

</div>

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