Skip to content

fix(sites): reject activating or duplicating another site's deployment - #13103

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/sites-deployment-ownership
Aug 5, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/sites-deployment-ownership

Conversation

@cursor

@cursor cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds missing deployment ownership checks to two Sites endpoints:

  • PATCH /v1/sites/:siteId/deployment (updateSiteDeployment)
  • POST /v1/sites/:siteId/deployments/duplicate (createDuplicateDeployment)

These endpoints previously only checked isEmpty(), so a caller with sites.write on one site could activate or duplicate a deployment belonging to a different site. Sibling Get/Delete/Download endpoints already reject this with DEPLOYMENT_NOT_FOUND when resourceId does not match.

This mirrors the Functions activate ownership fix in #13086.

Test Plan

  • Added e2e coverage in SitesCustomServerTest:
    • testUpdateSiteDeploymentRequiresOwnership
    • testCreateDuplicateDeploymentRequiresOwnership

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web View Automation 

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 #11919 approach with a rebased fix + tests.

Co-authored-by: Chirag Aggarwal <[email protected]>
@cursor
cursor Bot requested a review from ChiragAgg5k August 5, 2026 03:37
@cursor
cursor Bot marked this pull request as ready for review August 5, 2026 03:37
@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds ownership validation to Sites deployment activation and duplication, preventing a deployment belonging to one site from being operated on through another site.

  • Verifies each deployment's resourceId matches the requested site before activation or duplication.
  • Returns DEPLOYMENT_NOT_FOUND for cross-site deployment references.
  • Adds end-to-end coverage for rejection through a non-owning site and success through the owning site.

Confidence Score: 5/5

The PR appears safe to merge, with ownership checks consistently applied and focused end-to-end coverage for both affected endpoints.

The new guards compare the deployment's owning resource with the requested site before any activation or duplication side effect, matching established sibling endpoint behavior without introducing a concrete regression.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php Adds a deployment-to-site ownership guard before duplicating, consistent with existing Sites endpoint behavior.
src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php Prevents activating another site's deployment by validating resourceId before checking readiness or updating the site.
tests/e2e/Services/Sites/SitesCustomServerTest.php Covers cross-site rejection and owning-site success for both activation and duplication using the established build-ready timeout and teardown patterns.

Reviews (1): Last reviewed commit: "fix(sites): reject activating or duplica..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/sites-deployment-ownership (after).

Metric Before After Change
🚀 Requests/sec 167.48 167.08 ⚪ -0.2%
⏱️ Latency P50 86.01 ms 85.48 ms ⚪ -0.6%
⏱️ Latency P95 302.72 ms 298.97 ms ⚪ -1.2%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 85.48 298.97 10,488 167.08 -3.75
Account 164.76 463.56 552 9.21 +58.54
TablesDB 82.66 271.05 5,704 92.59 -5.2
Storage 76.16 284.18 2,760 46.82 +1.03
Functions 125.98 373.33 1,472 25.55 -20.75

Top API waits (after)

API request Max wait (ms)
functions.delete 1,389.75
functions.variables.update 1,204.51
tablesdb.rows.create 835.93
tablesdb.rows.get 833.19
storage.buckets.create 800.84

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