Repository navigation
fix: add missing deployment ownership check in duplicate endpoint - #11916
yogeshwaran-c wants to merge 1 commit into
Conversation
The duplicate deployment endpoint fetched a deployment by ID without verifying it belonged to the function referenced in the URL. A caller with write access to one function could duplicate another function's deployment by supplying a mismatched deploymentId, copying the source into a new deployment attached to the attacker's function. Match the check already performed in sibling Get/Delete/Download endpoints by rejecting with DEPLOYMENT_NOT_FOUND when the deployment's resourceId does not match the function id.
Greptile SummaryThis PR correctly patches the Functions
Confidence Score: 4/5The Functions fix is correct and safe, but the same vulnerability remains unpatched in the Sites duplicate endpoint. Score is 4 rather than 5 because the same P1 security defect (missing ownership check) exists in the Sites module's duplicate endpoint and should be fixed in the same pass. src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php — needs the same ownership guard added.
|
| Filename | Overview |
|---|---|
| src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php | Adds the missing resourceId ownership check, consistent with sibling Get and Delete endpoints — fix is correct and well-placed. |
| src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php | Missing the same resourceId ownership check that this PR adds to the Functions duplicate endpoint — same cross-resource vulnerability exists here. |
Comments Outside Diff (1)
-
src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php, line 92-96 (link)Same ownership check missing in Sites duplicate endpoint
The Sites module's duplicate endpoint has the identical vulnerability this PR fixes for Functions: a deployment is fetched by ID without verifying it belongs to the requested
siteId. A caller withsites.writeaccess to Site B can pass Site A'sdeploymentIdand duplicate A's source into B.Sites/Http/Deployments/Get.phpalready guards against this at line 69–71 with the same pattern.
Reviews (1): Last reviewed commit: "fix: add missing deployment ownership ch..." | Re-trigger Greptile
|
Thanks for the review. The same missing ownership check in |
|
Closing as stale since there has been no activity for a while. Thanks for the contribution! If this is still relevant, feel free to rebase on |
Summary
The
createDuplicateDeploymentendpoint (POST /v1/functions/:functionId/deployments/duplicatewith aliases for the build path) fetches a deployment by ID without verifying it belongs to the function in the URL. A caller with write access to one function could pass another function'sdeploymentIdand the endpoint would duplicate the other function's source, attach the copy to the attacker's function, and kick off a build. The siblingGet,Delete, andDownload/Getendpoints already guard this with$deployment->getAttribute('resourceId') !== $function->getId(); the duplicate endpoint was the one outlier.This PR adds the same check after the
isEmptyguard, returningDEPLOYMENT_NOT_FOUNDto match sibling behavior and avoid leaking whether the foreign deployment ID exists.File changed:
src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.phpTest plan
docker compose exec appwrite test tests/e2e/Services/Functions --filter=FunctionsCustomServerTestpassesfunctionId=BanddeploymentId=<A's deployment>, verify it now returns404 DEPLOYMENT_NOT_FOUNDinstead of duplicating A's source into BfunctionIdstill succeeds