Skip to content

Shared workspaces: scoped tokens can't run coder start, and use-role users can't report usage #30423

Open

Description

@EhabY

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 with coder: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 with organization:read; I haven't re-verified that.
  • GET /api/v2/users/{user} returns 404 for another user, because user:read scoped 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

  1. Share a workspace with a member (ACL role admin) and stop it.
  2. As the member, create a token with the scopes above.
  3. 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_connect
  • read
  • ssh
  • workspace_start
  • workspace_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

  1. linear-code commented on Oct 6, 2026

    @linear-code
  2. added
    cli
    api
    needs-triage
    on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: rbacapibugclineeds-triageworkspaces

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions