fix(coderd): require deployment-wide workspace read permissions for WatchAllWorkspaceBuilds endpoint (#26985)

This commit is contained in:
Callum Styan
2026-07-06 13:04:48 -07:00
committed by GitHub
parent feef3602a3
commit bf58e8a402
2 changed files with 57 additions and 0 deletions
+14
View File
@@ -2249,6 +2249,20 @@ func (api *API) watchWorkspace(
func (api *API) watchAllWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
// This endpoint streams build events for every workspace in the deployment
// with no per-item filtering, so require deployment-wide read on workspaces.
// Without this, any authenticated user could enumerate all workspace names
// and observe build activity across organizations they do not belong to.
if !api.Authorize(r, policy.ActionRead, rbac.ResourceWorkspace.All()) {
httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{
Message: "You are not authorized to watch all workspace builds.",
Detail: "This requires permission to read all workspaces, which is granted by the " +
"Owner or Template Admin role. Please contact an administrator about your " +
"permissions if you feel this is an error.",
})
return
}
// Buffer enough updates to avoid blocking the pubsub callback while we're
// accepting the WebSocket connection. Accepting the connection signals to
// the client that the server is subscribed and ready to forward events.