Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fallback to anonymous user when credentials are present (Basic Authentication) #108563

Closed
AkshayGoyal022 opened this issue May 13, 2024 · 5 comments
Labels
>bug :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team v8.3.3

Comments

@AkshayGoyal022
Copy link

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

@AkshayGoyal022 AkshayGoyal022 added >bug needs:triage Requires assignment of a team area label labels May 13, 2024
@AkshayGoyal022 AkshayGoyal022 changed the title Don't fallback to anonymous user when credentials are present (Basic Auth) Don't fallback to anonymous user when credentials are present (Basic Authentication) May 13, 2024
@Mikep86 Mikep86 added :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC v8.3.3 and removed needs:triage Requires assignment of a team area label labels May 13, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label May 13, 2024
@albertzaharovits
Copy link
Contributor

albertzaharovits commented May 14, 2024

@AkshayGoyal022 The intention is that the anonymous role is also assigned to all other users that present any credential, even if the credentials they present map to other roles. That's because the anonymous role is assigned to users that don't show any credential, and it makes little sense to have fewer permissions when presenting a credential than when not.
I acknowledge that's not clear from the docs: https://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html.

@AkshayGoyal022
Copy link
Author

@albertzaharovits Not sure if I understand it completely. Do you mean anonymous role takes precedence over the role associated with the user?
From the documentation:

Incoming requests are considered to be anonymous if no authentication token can be extracted from the incoming request

But here we are passing the credentials. Also tried with Authorization Bearer header. So request shouldn't be considered as anonymous

@albertzaharovits
Copy link
Contributor

Do you mean anonymous role takes precedence over the role associated with the user?

I mean that xpack.security.authc.anonymous.roles are appended to the roles that are normally mapped to the user, see

allRoleNames = ArrayUtils.concat(user.roles(), anonymousUser.roles());
.

@albertzaharovits
Copy link
Contributor

We discussed this in our es-security team meeting yesterday, and decided we will not implement this.

We consider it a potential security problem if a client is able to get more or different permissions in case that it omits (eg by mistake) the credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team v8.3.3
Projects
None yet
Development

No branches or pull requests

4 participants