Repository navigation
fix: add missing deployment ownership checks in Sites endpoints - #11919
yogeshwaran-c wants to merge 1 commit into
Conversation
Two Sites deployment endpoints fetched a deployment by ID without verifying it belonged to the site referenced in the URL path: - PATCH /v1/sites/:siteId/deployment (updateSiteDeployment) - POST /v1/sites/:siteId/deployments/duplicate (createDuplicateDeployment) A caller with write access to one site could activate or duplicate a deployment belonging to another site by supplying a mismatched deploymentId. For updateSiteDeployment this rewrites the target site's active deployment and propagates the change to platform rules; for createDuplicateDeployment it copies another site's source bundle into a new deployment attached to the caller's site. 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 site id.
Greptile SummaryAdds a Confidence Score: 5/5Safe to merge — the two-line guard is correct, minimal, and consistent with all sibling endpoints. No logic issues, no style issues. The fix closes a real IDOR vulnerability using the exact same pattern as the rest of the file family, with no risk of regression. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: add missing deployment ownership ch..." | Re-trigger Greptile |
Sites activate (PATCH .../deployment) and duplicate endpoints only checked that a deployment existed, not that it belonged to the site in the URL path. A caller with sites.write on one site could activate or copy a deployment from another site. Match Get/Delete/Download by rejecting with DEPLOYMENT_NOT_FOUND when resourceId does not match, and add e2e coverage. Supersedes the conflicting appwrite#11919 approach with a rebased fix + tests. Co-authored-by: Chirag Aggarwal <[email protected]>
|
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
Two Sites deployment endpoints fetched a deployment by ID without verifying it belonged to the site referenced in the URL path:
PATCH /v1/sites/:siteId/deployment(updateSiteDeployment) insrc/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.phpPOST /v1/sites/:siteId/deployments/duplicate(createDuplicateDeployment) insrc/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.phpBecause only
isEmpty()was checked, a caller withsites.writeaccess to any site could pass adeploymentIdbelonging to a different site. ForupdateSiteDeploymentthis activates the foreign deployment on the caller's site (updatingdeploymentId, screenshots, and propagating the change into the matching platformrulesdocuments). ForcreateDuplicateDeploymentit transfers the foreign deployment's source bundle into a brand-new deployment attached to the caller's site and kicks off a build.Sibling endpoints (
Sites/Http/Deployments/Get.php,Delete.php,Download/Get.php) already reject this withDEPLOYMENT_NOT_FOUNDwhen$deployment->getAttribute('resourceId') !== $site->getId(). This PR adds the same guard to the two endpoints that were missing it.The check is placed directly after the
isEmpty()check so the error is raised before any mutation (document update, rule rewrite, file transfer, or build queue).Test plan
PATCH /v1/sites/:siteA/deploymentwith adeploymentIdthat belongs to site B now responds404 deployment_not_foundinstead of silently switching site A's active deployment.POST /v1/sites/:siteA/deployments/duplicatewith adeploymentIdthat belongs to site B now responds404 deployment_not_foundand does not create a new deployment or transfer the source bundle.deploymentIdbelongs to the site referenced in the URL.tests/e2e/Services/Sitespass.