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

Get Cluster returns PermissionDenied for non-existing clusters #10830

Closed
3 tasks done
clementblaise opened this issue Oct 6, 2022 · 3 comments
Closed
3 tasks done

Get Cluster returns PermissionDenied for non-existing clusters #10830

clementblaise opened this issue Oct 6, 2022 · 3 comments
Labels
bug Something isn't working component:api API bugs and enhancements

Comments

@clementblaise
Copy link

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug
Argocd API Get Cluster returns PermissionDenied for non-existing clusters

To Reproduce

argocd cluster get non-existant
FATA[0000] rpc error: code = PermissionDenied desc = permission denied

Expected behavior

API should return not found

Screenshots

Version

argocd: v2.4.14+029be59.dirty
  BuildDate: 2022-10-05T19:03:58Z
  GitCommit: 029be590bfd5003d65ddabb4d4cb8a31bff29c18
  GitTreeState: dirty
  GoVersion: go1.19.2
  Compiler: gc
  Platform: darwin/arm64

Server version is v2.4.13

Logs

Existing cluster

time="2022-10-06T15:32:44Z" level=info msg="received unary call /version.VersionService/Version" grpc.method=Version grpc.request.claims="{\"iat\":1664380119,\"iss\":\"argocd\",\"jti\":\"32676cf1-bda2-4b05-90f9-9622a8aab76f\",\"nbf\":1664380119,\"sub\":\"crossplane\"}" grpc.request.content= grpc.service=version.VersionService grpc.start_time="2022-10-06T15:32:44Z" span.kind=server system=grpc
time="2022-10-06T15:32:44Z" level=info msg="finished unary call with code OK" grpc.code=OK grpc.method=Version grpc.service=version.VersionService grpc.start_time="2022-10-06T15:32:44Z" grpc.time_ms=8.773 span.kind=server system=grpc
time="2022-10-06T15:32:44Z" level=info msg="received unary call /cluster.ClusterService/Get" grpc.method=Get grpc.request.claims="{\"iat\":1664380119,\"iss\":\"argocd\",\"jti\":\"32676cf1-bda2-4b05-90f9-9622a8aab76f\",\"nbf\":1664380119,\"sub\":\"crossplane\"}" grpc.request.content="name:\"in-cluster\" " grpc.service=cluster.ClusterService grpc.start_time="2022-10-06T15:32:44Z" span.kind=server system=grpc
time="2022-10-06T15:32:44Z" level=info msg="finished unary call with code OK" grpc.code=OK grpc.method=Get grpc.service=cluster.ClusterService grpc.start_time="2022-10-06T15:32:44Z" grpc.time_ms=8.848 span.kind=server system=grpc

Non existing cluster

time="2022-10-06T15:34:20Z" level=info msg="received unary call /version.VersionService/Version" grpc.method=Version grpc.request.claims="{\"iat\":1664380119,\"iss\":\"argocd\",\"jti\":\"32676cf1-bda2-4b05-90f9-9622a8aab76f\",\"nbf\":1664380119,\"sub\":\"crossplane\"}" grpc.request.content= grpc.service=version.VersionService grpc.start_time="2022-10-06T15:34:20Z" span.kind=server system=grpc
time="2022-10-06T15:34:20Z" level=info msg="finished unary call with code OK" grpc.code=OK grpc.method=Version grpc.service=version.VersionService grpc.start_time="2022-10-06T15:34:20Z" grpc.time_ms=10.9 span.kind=server system=grpc
time="2022-10-06T15:34:21Z" level=info msg="received unary call /cluster.ClusterService/Get" grpc.method=Get grpc.request.claims="{\"iat\":1664380119,\"iss\":\"argocd\",\"jti\":\"32676cf1-bda2-4b05-90f9-9622a8aab76f\",\"nbf\":1664380119,\"sub\":\"crossplane\"}" grpc.request.content="name:\"non-existing\" " grpc.service=cluster.ClusterService grpc.start_time="2022-10-06T15:34:21Z" span.kind=server system=grpc
time="2022-10-06T15:34:21Z" level=warning msg="finished unary call with code PermissionDenied" error="rpc error: code = PermissionDenied desc = permission denied" grpc.code=PermissionDenied grpc.method=Get grpc.service=cluster.ClusterService grpc.start_time="2022-10-06T15:34:21Z" grpc.time_ms=10.283 span.kind=server system=grpc
@janwillies
Copy link

@jgwest jgwest added the component:api API bugs and enhancements label Oct 7, 2022
@cleverhu cleverhu mentioned this issue Oct 8, 2022
10 tasks
cleverhu pushed a commit to cleverhu/argo-cd that referenced this issue Oct 8, 2022
Fixes: argoproj#10830
Signed-off-by: cleverhu <[email protected]>
@cleverhu
Copy link
Contributor

cleverhu commented Oct 8, 2022

It is a bug, so I pulled a request for this.

@crenshaw-dev
Copy link
Member

@clementblaise I believe this behavior is intentional, to avoid letting unauthorized users enumerate the clusters by trial and error. By returning a 403 both for "that doesn't exist" and "you're not allowed to see that," we prevent the user from determining which clusters exist.

Generally the preferred way of doing this is to return a 404 (like you get a 404 in GitHub when attempting to view a repo which you're not allowed to access).

Unfortunately, we can't go the 404 route while still allowing users to update clusters by name instead of URL. If the user gets an unauthorized error when updating a cluster by name, they can infer that the cluster by that name exists, because the RBAC check can only be performed if the server was able to retrieve the cluster's URL (i.e. the cluster exists).

I'd like to return a nicer error message while 1) preventing cluster enumeration and 2) allowing users to get clusters by name. But for the moment, I can't think of a way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component:api API bugs and enhancements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants