Description
Elasticsearch Version
8.3.3
Installed Plugins
No response
Java Version
bundled
OS Version
Darwin Kernel Version 23.4.0
Problem Description
We are observing one weird behaviour with anonymous access. Looks like it falls back to anonymous user if credentials are present and user doesn't have required permissions.
I see something similar being fixed in 7.6.0 #51042. Is there a way to disable fallback if credentials are present?
Steps to Reproduce
Create user with role
curl -X POST "localhost:9200/_security/role/new_test_role?pretty" -H 'Content-Type: application/json' -d'
{
"cluster": ["monitor"],
"indices": [
{
"names": [ "foo*" ],
"privileges": ["all"]
}
]
}
'
curl -X POST "localhost:9200/_security/user/new_test_user?pretty" -H 'Content-Type: application/json' -d'
{
"password" : "new_test_password",
"roles" : [ "new_test_role" ],
"full_name" : "New Test User",
"email" : "new_test_user@coupa.com"
}
'
^ Notice this user only has access to indices starting with foo*
cluster's config/elasticsearch.yml settings:
xpack.security.enabled: true
xpack.security.authc:
anonymous:
username: anonymous_user
roles: superuser
authz_exception: true
Now if i send a request with credentials of this user, i am able to access indices which aren't allowed.
Request:
curl -X GET "http://new_test_user:new_test_password@localhost:9200/bar/_search?pretty"
I even tried with Authorization Header but still same result (`curl -H "Authorization: Basic bmV3X3Rlc3RfdXNlcjpuZXdfdGVzdF9wYXNzd29yZA==" -XGET "http://localhost:9200/bar/_search?pretty")
Logs (if relevant)
No response