-
Notifications
You must be signed in to change notification settings - Fork 186
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
fix: return 403 when non-admin tries to do admin requests #6945
Conversation
Kudos, SonarCloud Quality Gate passed! |
@saw-jan Still a thing? or close? |
I there can be a clarification on the following query, then it would be helpful to decide whether to work on it or close.
Sorry, I totally forgot about this PR |
6dcb51b
to
ec4bf13
Compare
@@ -48,7 +48,7 @@ func RequireAdmin(rm *roles.Manager, logger log.Logger) func(next http.Handler) | |||
return | |||
} | |||
|
|||
errorcode.AccessDenied.Render(w, r, http.StatusUnauthorized, "Unauthorized") | |||
errorcode.AccessDenied.Render(w, r, http.StatusForbidden, "Forbidden") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with that in the current context. So 403 is the way to go.
Needs to be reviewed by dev team if this is correct and right place to do it
|
ec4bf13
to
3cf671e
Compare
564d0a9
to
4fbef3c
Compare
Quality Gate passedIssues Measures |
The other thing that we need to check is that these status codes should not "leak" information about what exists and does not exist. When a user with not enough privileges tries to modify or delete something (user, group, space...) that exists, they get a 403 "forbidden" - good. If they try the same modify or delete to a non-existent user, group, space, then they should also get a 403 "forbidden". If they get 404 "not found" then they will know that the item really does not exist, and that "403" indicates that the item exists (and they do not have permission). Similarly for "create" requests - if a 403 "forbidden"is given when trying to create a new user that does not already exist, then 403 should also be given if "create" is attempted for a user that already exists. |
@saw-jan is there an issue about testing the cases where 403 and/or 404 status responses might leak information? |
fix: return 403 when non-admin tries to do admin requests
There are some tests like this one ocis/tests/acceptance/features/apiGraphUserGroup/deleteUser.feature Lines 78 to 82 in 775913c
|
Good. If there are the same sort of test scenarios for non-existent group, non-existent space... for trying to delete and trying to modify then we are good. |
I will check for other test cases |
Description
With this PR, all the graph
admin requests
if done by thenon-admin
users will respond with403 Forbidden
instead of401 Unauthorized
.Motivation: #5742 (comment)
403
in some test scenarios.But the above comment doesn't describe more about
401 Unauthorized
vs403 Forbidden
. It is agreeable to respond with403
when non-admin users do admin requests but the standard/policy and also from a security point of view, it could be different in oCIS.The main motive of the PR is to have some conclusion and if agreed upon then hopefully merge the fix, if not then change the test expectation.
**Non-admin scenarios: should they respond with
403
,401
or404
❓ **Related Issue
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: