GHSA-26rh-24rg-j3vv Goploy: Cross-namespace IDOR and RCE via body-supplied row id in project and project_file handlers
Summary`Project.AddFile`, `Project.EditFile`, `Project.RemoveFile`, and `Project.Edit` in `cmd/server/api/project/handler.go` accept a project or project-file row id from the JSON body and act on it without checking that the project belongs to the caller's namespace. The corresponding `model.ProjectFile.GetData` and `model.Project.GetData` queries filter only by row id. A user holding the `manager` role (or any role that includes the `FileSync` / `EditProject` permission) in their own namespace can read, write, or delete files in any project across the install, and can rewrite any project's git remote URL by submitting the foreign id in the body. The git-URL primitive escalates to RCE on the next deploy because `Edit` runs `git remote set-url` on the project's working tree.Affected`zhenorzz/goploy` `develop` HEAD as of 2026-05-27. Verified against the `zhenorzz/goploy:1.17.5` Docker image (`docker.io/zhenorzz/goploy@sha256:69d08e1d16d7a7167426c89456c4bcef8e077a16554a4067ff258fff26d5cd44`).The four handlers and the model lookups have been in this shape across the file API and project metadata API.Vulnerable code`cmd/server/api/project/handler.go::AddFile` (creates file under any project's directory; body controls `projectId`):`cmd/server/api/project/handler.go::EditFile` (overwrites file content; body controls file id, server derives project from the file row):`cmd/server/api/project/handler.go::RemoveFile` (deletes file row + on-disk file by body id):`cmd/server/api/project/handler.go::Edit` (updates any project's metadata; on URL change runs `git remote set-url` in the project working tree):`internal/model/project_file.go::ProjectFile.GetData` filters only by row id, no namespace join:`internal/server/route.go::Route.hasPermission` checks only namespace-level permission ids; nothing in the request flow verifies that the body-supplied project id belongs to `gp.Namespace.ID`:ReachableAny logged-in user assigned the `manager` role in their own namespace can call `/project/addFile`, `/project/editFile`, `/project/removeFile`, and `/project/edit`. The seeded `manager` role (`role.id = 1`) is granted both `FileSync` (`permission.id = 68`) and `EditProject` (`permission.id = 17`) by `database/goploy.sql`. Multi-tenant deployments typically assign `manager` to each tenant's project owner; once a tenant's manager holds these permissions in their own namespace, they hold them globally for these four endpoints.Proof of conceptSetup against the published Docker image:Set up two namespaces and two non-super-manager users, each assigned `manager` (role_id=1) only in their own namespace:Negative control: Bob's own namespace has no projects.Exploit 1 — Bob overwrites Alice's file content:Exploit 2 — Bob plants a new file in Alice's project directory:Exploit 3 — Bob deletes Alice's file:Exploit 4 — Bob rewrites Alice's project git remote URL. On the next deploy, goploy runs `git -C <alice-prod-tree> remote set-url origin <attacker-url>` and clones / pulls attacker code, leading to RCE under goploy's user:Positive control: Bob editing a file in his own namespace (after creating one) goes through the same code path and succeeds normally — the patch must keep that working.Suggested fixAdd a namespace-scoped variant of `GetData` so the model layer requires `(id, namespace_id)` and switch the four handlers over.`internal/model/project_file.go`:`internal/model/project.go`: add a parallel `Project.GetDataInNamespace` that joins on `namespace_id`.`cmd/server/api/project/handler.go`:`EditFile` and `RemoveFile` switch to `model.ProjectFile{ID: ...}.GetDataInNamespace(gp.Namespace.ID)`.`AddFile` calls a new `model.Project{ID: reqData.ProjectID}.GetDataInNamespace(gp.Namespace.ID)` precheck before `os.Create` and `AddRow`.`Edit` calls `model.Project{ID: reqData.ID}.GetDataInNamespace(gp.Namespace.ID)` before `EditRow`.`sql.ErrNoRows` from the namespace-scoped lookup becomes the correct denial for any cross-namespace id. The same pattern should be applied to other body-id consumers in this file (`Remove`, `SetAutoDeploy`, `UploadFile`, `AddTask`, `EditProcess`, etc.) but the four endpoints above are the immediately exploitable ones.PatchFix proposed in https://github.com/zhenorzz/goploy-ghsa-26rh-24rg-j3vv/pull/1. The PR diff adds the namespace-scoped model variants and switches the four exposed handlers to use them.CreditReported by tonghuaroot.
CVSS v3.1 score: 9.6