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

Non-admin user tries to delete non-existing result 401 #5738

Open
amrita-shrestha opened this issue Mar 6, 2023 · 4 comments
Open

Non-admin user tries to delete non-existing result 401 #5738

amrita-shrestha opened this issue Mar 6, 2023 · 4 comments

Comments

@amrita-shrestha
Copy link
Contributor

amrita-shrestha commented Mar 6, 2023

Describe the bug

Non-admin users try to delete the non-existing users. Then the API request returns a 401 HTTP status code.

curl -u user:password DELETE 'https://localhost:9200/graph/v1.0/users/random-uuid' \

Expected behavior

The HTTP status code should be 404. Forbidden rather than 401 Unauthorized

Actual behavior

Return 401 Unauthorized

@amrita-shrestha amrita-shrestha changed the title Non-admin user tries to delete non-exisiting 401 Non-admin user tries to delete non-exisiting result 401 Mar 6, 2023
@amrita-shrestha amrita-shrestha changed the title Non-admin user tries to delete non-exisiting result 401 Non-admin user tries to delete non-existing result 401 Mar 6, 2023
@saw-jan
Copy link
Member

saw-jan commented Mar 16, 2023

CC @ScharfViktor @micbar
Do we expect non-admin user to get 404 Not Found on trying to DELETE non-existent user?

@ScharfViktor
Copy link
Contributor

it is not bug IMHO or low priority

backend seems to have two checks:

  • does the user with uuid exist (404)
  • does user rigth to delete (401)

if a user with uuid exists -> we get a 401. In any case, a non-admin cannot remove the user

@individual-it
Copy link
Member

I think for security reasons it would be better to return 401 if the user that tries to delete does not have enough permissions, because that would prevent people from guessing user-names.
With the current situation a non-privileged user can find out what users exist in the system, simple by sending delete requests and check for 404 vs 401

@amrita-shrestha
Copy link
Contributor Author

butonic gave some insight in this comment #5742 (comment)

In general here is a list of error codes returned by the ms graph api: https://learn.microsoft.com/en-us/graph/errors

Now the 401 Unauthorized vs 403 Forbidden vs 404 Not Found status code may look tricky, but hara are the guidelines:

  • we don't want to expose existence of resources if a user has no access to them, so we return a 404 Not Found instead of > a 403 Forbidden.
  • when a user has access to a resource but tries to execute an action that he does not have enough permissions for, e.g.
    when he tries to write to a read only share, we return a 403 Forbidden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants