Repository navigation
Description
Found while auditing the VS Code extension's OAuth scopes (coder/vscode-coder#1138, coder/vscode-coder#1128). Both affect workspaces shared with another user.
1. coder start and coder update fail on a shared workspace with any scoped token
With dynamic parameters, prepWorkspaceBuild (cli/create.go) resolves the owner with OrganizationMember(org, owner) and falls back to User(owner). For a scoped token both fail:
GET /api/v2/organizations/{org}/members/{user}returns 404 for a token withcoder:workspaces.operate coder:workspaces.access workspace:create user:read user:read_personal. It does so even for the caller's own membership. The review also reported a 500 withorganization:read; I haven't re-verified that.GET /api/v2/users/{user}returns 404 for another user, becauseuser:readscoped this way only covers the caller.
So the CLI fails with:
get owning member: Resource not found or you do not have access to this resource
The same user's unscoped session starts the workspace. A REST start build (POST /api/v2/workspaces/{id}/builds) with the same token also works, so only the CLI's owner lookup is blocked. organization_member:read is not a public low-level scope, so a client can't request it directly. Per the review, no scope short of coder:all avoids the failure.
Repro
- Share a workspace with a member (ACL role
admin) and stop it. - As the member, create a token with the scopes above.
- Run
CODER_SESSION_TOKEN=<token> coder start -y <owner>/<workspace>.
Expected: the start succeeds. Either the member lookup works for scoped tokens with access to the workspace, or the CLI resolves the owner in a way such tokens can.
2. Users shared a workspace with the use role can't report usage
POST /api/v2/workspaces/{id}/usage authorizes policy.ActionUpdate on the workspace (postWorkspaceUsage, coderd/workspaces.go). The use workspace role (db2sdk.go) grants only:
application_connectreadsshworkspace_startworkspace_stop
It doesn't grant update, so coder ssh --usage-app=… (used by VS Code and others) can't report usage on such workspaces, whatever the token's scopes. UpdateWorkspaceUsageWithBodyContext only logs failed to post workspace usage as a warning, so the workspace's usage stops being recorded with no visible error.
Expected: anyone allowed to SSH into or connect to the workspace can report usage. For example, authorize usage with ssh or application_connect instead of update, or add the needed action to the use role.
Activity
linear-code commentedon Oct 6, 2026
ENG-3449