Skip to content

fix: add missing deployment ownership checks in Sites endpoints - #11919

Closed
yogeshwaran-c wants to merge 1 commit into
appwrite:mainfrom
yogeshwaran-c:fix/sites-deployment-ownership-check
Closed

yogeshwaran-c wants to merge 1 commit into
appwrite:mainfrom
yogeshwaran-c:fix/sites-deployment-ownership-check

Conversation

@yogeshwaran-c

Copy link
Copy Markdown

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) in src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php
  • POST /v1/sites/:siteId/deployments/duplicate (createDuplicateDeployment) in src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php

Because only isEmpty() was checked, a caller with sites.write access to any site could pass a deploymentId belonging to a different site. For updateSiteDeployment this activates the foreign deployment on the caller's site (updating deploymentId, screenshots, and propagating the change into the matching platform rules documents). For createDuplicateDeployment it 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 with DEPLOYMENT_NOT_FOUND when $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/deployment with a deploymentId that belongs to site B now responds 404 deployment_not_found instead of silently switching site A's active deployment.
  • POST /v1/sites/:siteA/deployments/duplicate with a deploymentId that belongs to site B now responds 404 deployment_not_found and does not create a new deployment or transfer the source bundle.
  • Both endpoints continue to work unchanged when deploymentId belongs to the site referenced in the URL.
  • Existing E2E tests under tests/e2e/Services/Sites pass.

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-apps

greptile-apps Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a resourceId ownership guard to the two Sites deployment endpoints that were missing it (updateSiteDeployment and createDuplicateDeployment), closing an IDOR vulnerability where a caller could pass a deploymentId belonging to a different site. The fix is minimal, correctly placed (after isEmpty(), before any mutation), and exactly mirrors the pattern already present in the sibling Get, Delete, and Download endpoints.

Confidence Score: 5/5

Safe 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

Filename Overview
src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php Adds ownership check resourceId !== site->getId() after the isEmpty guard — matches the identical pattern in Get.php, Delete.php, and Download/Get.php.
src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php Adds the same ownership guard before the status !== ready check and all mutations; consistent with sibling endpoints.

Reviews (1): Last reviewed commit: "fix: add missing deployment ownership ch..." | Re-trigger Greptile

@ChiragAgg5k
ChiragAgg5k changed the base branch from 1.9.x to main June 23, 2026 09:54
pull Bot pushed a commit to steinsi/appwrite that referenced this pull request Aug 5, 2026
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]>
@HarshMN2345

Copy link
Copy Markdown
Member

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 main and reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants