Skip to content

fix: don't allow sharing admins to change own role#21634

Merged
jaaydenh merged 3 commits intomainfrom
workspace-sharing-6106
Jan 30, 2026
Merged

fix: don't allow sharing admins to change own role#21634
jaaydenh merged 3 commits intomainfrom
workspace-sharing-6106

Conversation

@jaaydenh
Copy link
Contributor

@jaaydenh jaaydenh commented Jan 22, 2026

@jaaydenh jaaydenh self-assigned this Jan 22, 2026
@jaaydenh jaaydenh force-pushed the workspace-sharing-6106 branch from 2b491cc to 7193d1c Compare January 27, 2026 10:39
@jaaydenh jaaydenh marked this pull request as ready for review January 27, 2026 11:02
@jaaydenh jaaydenh requested review from aslilac and geokat January 27, 2026 11:02
Copy link
Contributor

@geokat geokat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@geokat
Copy link
Contributor

geokat commented Jan 27, 2026

We now have an interesting loophole: ws owners can't share with themselves, but if they admin-share with someone, that someone will be able to share with the ws owner (and the ws owner won't be able to remove the share) :)

})
return
}

Copy link
Contributor

@geokat geokat Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should add a check to close the loophole?

Suggested change
if _, ok := req.UserRoles[workspace.OwnerID.String()]; ok {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "You cannot change the workspace owner's sharing role.",
})
return
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary since, changing the workspace owner's role would have no effect?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly necessary. But without this, workspace owners can be added to the ACL by users they shared with:

  • Alice shares with Bob using admin role
  • Bob shares "back" with Alice (just for funzies :))
  • Alice is stuck with her name in the ACL list that she can't remove (due to this PR).

It won't affect the actual access permissions, but the workspace ACL (and the related UI) will be in a state that the ws owner can't change

@jaaydenh
Copy link
Contributor Author

jaaydenh commented Jan 28, 2026

If another admin shares the workspace with the workspace owner does it even matter? I'm assuming the ws owner will always be the owner and the share is irrelevant?

@geokat
Copy link
Contributor

geokat commented Jan 28, 2026

If another admin shares the workspace with the workspace owner does it even matter? I'm assuming the ws owner will always be the owner and the share is irrelevant?

Yes, the share will be irrelevant for all practical reasons.

@jaaydenh jaaydenh merged commit 4847920 into main Jan 30, 2026
30 checks passed
@jaaydenh jaaydenh deleted the workspace-sharing-6106 branch January 30, 2026 11:27
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A shared workspace user with Admin permission can change their own role to Use

2 participants