Skip to content

/v3/roles does not validate the existence of user guid #4308

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

Open
vchrisb opened this issue Apr 11, 2025 · 0 comments
Open

/v3/roles does not validate the existence of user guid #4308

vchrisb opened this issue Apr 11, 2025 · 0 comments
Assignees

Comments

@vchrisb
Copy link

vchrisb commented Apr 11, 2025

It is possible to create a space/org role for an arbitrary user guid. The following does succeed, event if the guid does not exist:

cf curl /v3/roles -X POST   -d '{
     "relationships": {
       "organization": {
         "data": {
           "guid": "5989b03b-4d88-4eb7-a4a7-5bc428cd31bc"
         }
       },
       "user": {
         "data": {
           "guid": "not-existing"
         }
       }
     },
     "type": "organization_manager"
   }'

For a user, the cc api is validating if it exists, and will fail:

{
 "relationships": {
   "organization": {
     "data": {
       "guid": "5989b03b-4d88-4eb7-a4a7-5bc428cd31bc"
     }
   },
   "user": {
     "data": {
       "username": "not-existing"
     }
   }
 },
 "type": "organization_manager"
}

From briefly looking at the code https://github.com/cloudfoundry/cloud_controller_ng/blob/main/app/controllers/v3/roles_controller.rb#L123 , not lookup is done if a guid is passed as part of the message.

I stumbled across this, as the cf cli is currently testing if a client exist when using set-org-role or set-space-role. But to be able to test for existence, the authenticated user needs to have the clients.read scope, which isn't normally available.
cloudfoundry/cli@5b0cf09
I think the check should be move to the cc api and not handled in the cf cli. This would improve the usability of clients with the cf cli.

@svkrieger svkrieger self-assigned this Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants