Skip to content

fix(deployment): isolate Local build workers from sibling project trees - #14098

Merged
abnegate merged 2 commits into
mainfrom
cursor/local-builds-volume-isolation-586c
Oct 5, 2026
Merged

abnegate merged 2 commits into
mainfrom
cursor/local-builds-volume-isolation-586c

Conversation

@abnegate

@abnegate abnegate commented Oct 4, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Fixes Help Scout report HS 1468629 Finding 2 (reporter: Kikoichi): on _APP_STORAGE_DEVICE=Local, Deployments::storage() attached the entire shared appwrite-builds volume (_APP_BUILDS_VOLUME) at APP_STORAGE_BUILDS (/storage/builds) to every project's build worker. Tenant build commands then ran with read/write access to every other project's /storage/builds/app-<projectId>/<deploymentId>/ artifacts.

This is a Docker/Kubernetes volume-mount scope issue (CWE-653), not CVE-2026-89036 (tar argument injection, already fixed). Remote/S3 is unchanged: that branch mounts no volume and copies artifacts through the sidecar.

Isolation contract

  • For DeviceType::Local, the worker receives one named-volume mount: source _APP_BUILDS_VOLUME, subPath app-{projectId}, path $device->getRoot() (/storage/builds/app-{projectId}).
  • Sibling app-{otherProject} trees are not on that mount. A path such as /storage/builds/app-other is not under the attached path, so the worker cannot list or write another project's build tree through the shared volume.
  • OPEN_RUNTIMES_BUILD_OUTPUT_DIR, OPEN_RUNTIMES_BUILD_CACHE_ARTIFACT, buildPath(), cachePath(), and deviceForBuilds stay the same Appwrite-side paths. Package-manager cache remains shared across a resource's deployments inside the same project.
  • The project directory is created on the Local device before submit so Docker's named-volume Subpath exists (the orchestrator maps Volume.subPath to Docker VolumeOptions.Subpath / Kubernetes VolumeMount.subPath and does not create volumes).
  • Per-project (not per-deployment) is the tenant boundary and keeps cache on the same mount. Same-project deployments still share that tree; that is outside the reported cross-tenant issue.

Finding 3 (same report, not in this PR)

Blind SSRF on Migrations report/create. Appwrite and Supabase report/create already validate the source endpoint with PublicHostname (resolve + private/reserved-range deny). NHost/Firebase do not take a free-form URL. Timeouts / extra IP-pin on the outbound client are a separate change.

Test Plan

  • Unit: tests/unit/Deployment/DeploymentsTest.php
    • testLocalBuildMountsOnlyTheProjectDirectory — Local payload mounts app-{projectId} (not APP_STORAGE_BUILDS) and keeps output/cache/buildPath aligned.
    • testLocalBuildMountCannotReachSiblingProject — a sibling app-project2 path is not under project1's mount; two projects get distinct subPaths.
  • These fail if the Local branch mounts the whole volume again.
  • composer lint / composer format on the touched PHP files when the environment has PHP.
  • Full unit suite: docker compose exec appwrite test tests/unit/Deployment/ (PHP/Docker were not available in this agent environment).

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 Open in Cursor 

The Local storage strategy mounted the entire shared builds volume into
every build container. Mount only app-{projectId} via the orchestrator
Volume.subPath so one project's build cannot list or write another's
tree, while buildPath, cachePath, and deviceForBuilds stay unchanged.

Co-authored-by: Jake Barnby <[email protected]>
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → cursor/local-builds-volume-isolation-586c (after).

Metric Before After Change
🚀 Requests/sec 181.73 188.8 ⚪ +3.9%
⏱️ Latency P50 94.83 ms 90.46 ms ⚪ -4.6%
⏱️ Latency P95 226.93 ms 215.61 ms ⚪ -5%
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 90.46 215.61 11,856 188.8 -11.32
Account 172.31 325.03 624 10.36 -26.57
TablesDB 86.52 163.25 6,448 105.48 -10.62
Storage 83.32 189.58 3,120 52.9 -0.4
Functions 132.99 269.79 1,664 28.64 -10.29

Top API waits (after)

API request Max wait (ms)
account.name.update 468.97
functions.create 424.07
account.prefs.update 393.35
functions.delete 392.25
tablesdb.rows.delete 389.69

@abnegate
abnegate marked this pull request as ready for review October 5, 2026 05:15
@ghost

ghost commented Oct 5, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

No concrete defects were found in the changed code or its storage-path contracts.

Local build jobs now mount only the current project's subdirectory of the builds volume, while retaining the existing output and cache paths. The change creates the project directory before submission, updates the volume documentation, and adds unit coverage for project-specific mount payloads.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
app/config/variables.php Documents project-scoped builds-volume mounts.
src/Appwrite/Deployment/Deployments.php Creates the Local project directory and mounts it using a project-specific subPath.
tests/unit/Deployment/DeploymentsTest.php Adds checks for scoped mounts and unchanged output/cache path alignment.

Reviewed d40089c · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@abnegate
abnegate merged commit 537fa27 into main Oct 5, 2026
50 checks passed
@abnegate
abnegate deleted the cursor/local-builds-volume-isolation-586c branch October 5, 2026 05:22
abnegate added a commit that referenced this pull request Oct 5, 2026
Bring in main 537fa27 (#14097 console membership role changes and
invitations need the team owner or an API key; #14098 Local build workers
attach only the project's app-<projectId> subdirectory of the builds volume)
so the PR is mergeable again.

Conflicts:
- tests/unit/Deployment/DeploymentsTest.php: kept both sides. Imports are the
  union (orchestrator Jobs/exceptions for the submission-recovery tests plus
  Model\Volume for the volume-isolation tests). The branch's submission tests
  and Memory-adapter helpers stay, followed by main's two Local build mount
  tests and their withLocalBuilds() helper; buildPayload() takes main's
  projectId parameter (auto-merged).

Adaptations: none. Main's changes touch no database APIs; composer.json and
composer.lock are unchanged, database stays at e8cb1af9a.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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