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

Log REST target with 403 #29714

Closed
elasticmachine opened this issue Feb 10, 2017 · 23 comments
Closed

Log REST target with 403 #29714

elasticmachine opened this issue Feb 10, 2017 · 23 comments
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >enhancement good first issue low hanging fruit help wanted adoptme :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Data Management Meta label for data/management team Team:Security Meta label for security team

Comments

@elasticmachine
Copy link
Collaborator

Original comment by @PhaedrusTheGreek:

It's very common when debugging security to see a message like this:

[403] {\"error\":{\"root_cause\":[{\"type\":\"security_exception\",\"reason\":\"action [indices:data/write/bulk] is unauthorized for user [logstash4]\"}],\"type\":\"security_exception\",\"reason\":\"action [indices:data/write/bulk] is unauthorized for user [logstash4]\"},\"status\":403}

Without further exploration, it's not obvious which request has failed. We can see that it is a _bulk request, but on which index? Seeing the index and/or the full REST target with this error message would really be helpful!

@elasticmachine elasticmachine added :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC >enhancement help wanted adoptme good first issue low hanging fruit labels Apr 25, 2018
@ashishguptak
Copy link

ashishguptak commented May 1, 2018

Is this being worked upon? I can pick it up if not. I am a newbie, any pointers are much appreciated.

@jucaleb4
Copy link

Hi, I'm a newbie and also am looking to start. @ashishguptak have you gotten far with this yet?

@jucaleb4
Copy link

jucaleb4 commented Jun 27, 2018

@PhaedrusTheGreek which Java file can we get started with to fix this, and how can we reproduce this error

@adityasraghav
Copy link

anyone working on this ? If not I'd like to give it a go.

@TCalise
Copy link

TCalise commented Mar 2, 2019

@adityasraghav Will you be working on this? if not, I wouldn't mind taking it.

@biglandm
Copy link

Is this anybody currently working on this?

@minglinlu
Copy link

How to fix this problem? I wanna learn.

@fdartayre fdartayre added the :Data Management/Indices APIs APIs to create and manage indices and templates label Sep 20, 2019
@elasticmachine
Copy link
Collaborator Author

Pinging @elastic/es-core-features

@fdartayre
Copy link
Contributor

Reproduced in 7.3. The index actions (for instance [indices:data/write/bulk], [indices:admin/create], [indices:data/write/index] and [indices:admin/delete]) don't inform the name of the index in the response in case of failure, which can make debugging challenging.

Is there any update on this?

@fdartayre
Copy link
Contributor

Related: the name of the index is not logged either, even under the DEBUG logging level. It is only under the TRACE level of the o.e.t.TaskManager logger, so not really usable.

@GNUDimarik
Copy link

Hi everyone.
Investigating this. I hope it will first my commit here :-)

@GNUDimarik
Copy link

This question for developers I think:
Am I on right track?
Seems it happens here:

@getsaurabh02
Copy link

Hi,
I am going to take a stab at this one, in case no one is actively working on it.

@GNUDimarik
Copy link

I'll have a chance to back to this in next week.

@GNUDimarik
Copy link

@getsaurabh02 I have chance to do this. Are you working on it?

@auspicacious
Copy link

auspicacious commented Apr 7, 2020

Hi, I'm fairly new to Elasticsearch but I've been looking at this issue, and I think it could use some clarification. Some use cases already seem to be covered.

For instance, working off of master right now, let's say I make a bulk update request to two indices, but the user only has permissions to write to one of them. The API provides some helpful feedback:

{
  "took" : 9,
  "errors" : true,
  "items" : [
    {
      "update" : {
        "_index" : "test1",
        "_id" : "1",
        "_version" : 13,
        "result" : "noop",
        "_shards" : {
          "total" : 2,
          "successful" : 1,
          "failed" : 0
        },
        "_seq_no" : 12,
        "_primary_term" : 1,
        "status" : 200
      }
    },
    {
      "update" : {
        "_index" : "test2",
        "_id" : "1",
        "status" : 403,
        "error" : {
          "type" : "security_exception",
          "reason" : "action [indices:data/write/bulk[s]] is unauthorized for user [noprivs]"
        }
      }
    }
  ]
}

On the other hand, if the user doesn't have permissions to write to either index, the error message is simpler:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "security_exception",
        "reason" : "action [indices:data/write/bulk] is unauthorized for user [noprivs]"
      }
    ],
    "type" : "security_exception",
    "reason" : "action [indices:data/write/bulk] is unauthorized for user [noprivs]"
  },
  "status" : 403
}

So it does seem to be doing the right thing in partial failure situations. Looking at the logs at level DEBUG, there isn't as much information, which isn't ideal, but is that what the original feature request is looking for? Also, I have not yet checked the audit logs, but judging from the code they might also do the right thing.

Is this feature request already taken care of?

@JohnCFerguson
Copy link

I am going to take a crack at this just in case no one has had time for it. This will be my first time so hopefully I'm able to help.

@rjernst rjernst added Team:Data Management Meta label for data/management team Team:Security Meta label for security team labels May 4, 2020
@khobey
Copy link

khobey commented Aug 1, 2020

Is fix still needed for this one? I can work on this is still free. Thanks!

@GNUDimarik
Copy link

GNUDimarik commented Aug 1, 2020 via email

@khobey
Copy link

khobey commented Aug 1, 2020

Thanks. I'll give this a go.

@JanBucko
Copy link

JanBucko commented Oct 6, 2020

Hello, is anyone working on this issue actually ?

rodrigo-sp17 added a commit to rodrigo-sp17/elasticsearch that referenced this issue Jun 15, 2021
@rodrigo-sp17
Copy link

rodrigo-sp17 commented Jun 15, 2021

Hi guys! Just linked a PR that attempts to solve this issue. I'm new to Elasticsearch, so I'm might have overlooked some details that require a larger knowledge of the codebase.
I intend to follow up on this, so any feedback is very welcome!

@tvernum
Copy link
Contributor

tvernum commented Jul 7, 2021

The was resolved in #60357

@tvernum tvernum closed this as completed Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >enhancement good first issue low hanging fruit help wanted adoptme :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Data Management Meta label for data/management team Team:Security Meta label for security team
Projects
None yet
Development

Successfully merging a pull request may close this issue.