Skip to content

Commit 4b6c9b0

Browse files
committed
Do not leak if an organization name exists
1 parent 96a5727 commit 4b6c9b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

coderd/users.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,10 @@ func (api *api) organizationByUserAndName(rw http.ResponseWriter, r *http.Reques
510510
organizationName := chi.URLParam(r, "organizationname")
511511
organization, err := api.Database.GetOrganizationByName(r.Context(), organizationName)
512512
if errors.Is(err, sql.ErrNoRows) {
513-
httpapi.Write(rw, http.StatusNotFound, httpapi.Response{
514-
Message: fmt.Sprintf("no organization found by name %q", organizationName),
513+
// Return unauthorized rather than a 404 to not leak if the organization
514+
// exists.
515+
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
516+
Message: "unauthorized",
515517
})
516518
return
517519
}

0 commit comments

Comments
 (0)