Skip to content

fix: add missing deployment ownership check in status update endpoints - #11868

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

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

Conversation

@yogeshwaran-c

Copy link
Copy Markdown

Summary

  • Added missing deployment ownership validation to the deployment status update (cancel build) endpoints for both functions and sites
  • The PATCH /v1/functions/:functionId/deployments/:deploymentId/status and PATCH /v1/sites/:siteId/deployments/:deploymentId/status endpoints did not verify that the deployment belongs to the specified function/site
  • The corresponding GET and DELETE deployment endpoints already perform this check ($deployment->getAttribute('resourceId') !== $function->getId()), so this was an oversight in the status update endpoints
  • Without this check, a valid deployment ID from a different function/site could be used to cancel builds through a mismatched parent resource

Test plan

  • Verify that canceling a deployment build with a matching function/site ID works correctly
  • Verify that attempting to cancel a deployment using a function/site ID that does not own the deployment returns a 404 error
  • Verify the same behavior for both the functions and sites deployment status update endpoints

The deployment status update (cancel build) endpoints for both functions
and sites did not verify that the deployment belongs to the specified
function or site. The corresponding Get and Delete deployment endpoints
already perform this check via resourceId comparison. Without this check,
a deployment from a different function/site could be canceled using a
mismatched parent resource ID.
@greptile-apps

greptile-apps Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds the missing deployment ownership check ($deployment->getAttribute('resourceId') !== $resource->getId()) to the cancel-build (status update) endpoints for both functions and sites, closing a gap that already existed in the GET and DELETE deployment endpoints. The added guard is identical in structure to those sibling endpoints, so the fix is consistent with the codebase pattern.

Confidence Score: 5/5

Safe to merge — minimal, targeted fix with no side effects.

Both changes exactly mirror the check already present in the Get and Delete endpoints for the same resources. No new logic is introduced; the fix simply closes an authorization gap on the PATCH path.

No files require special attention.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php Adds deployment ownership check (resourceId vs function ID) consistent with the Get and Delete endpoints; no issues found.
src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php Adds deployment ownership check (resourceId vs site ID) consistent with the Get and Delete endpoints; no issues found.

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:55
pull Bot pushed a commit to steinsi/appwrite that referenced this pull request Aug 5, 2026
Functions and Sites status-update (cancel) endpoints fetched a
deployment by ID without verifying it belonged to the function/site
in the URL path. A caller with write access on one resource could
cancel a build belonging to another.

Match Get/Delete/Download by rejecting with DEPLOYMENT_NOT_FOUND when
resourceId does not match.

Supersedes the stale appwrite#11868 approach with a rebased fix.

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