Skip to content

fix: backport VCS, functions and outbound security fixes to 1.9.x - #14911

Merged
ChiragAgg5k merged 20 commits into
1.9.xfrom
fix/1.9.x-security-compute
Oct 24, 2026
Merged

ChiragAgg5k merged 20 commits into
1.9.xfrom
fix/1.9.x-security-compute

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Backports security fixes from main to 1.9.x. One commit per PR. No schema changes or migrations.

PR Status Notes
#14771 Ported
#14783 Ported user installations lookup uses utopia-php/fetch
#14793 Ported 1.9.x passed the installation state unsigned; this adds the HMAC signature too, and the callback rechecks that the user's current project roles still grant vcs.read
#14800 Skipped only the GitHub provider exists on 1.9.x, so no repository can belong to another provider
#14808 Partial root directory validation and builds worker confinement; the build artifact checks target the orchestrator build path, which 1.9.x does not have
#14185 Ported also returns 400 instead of 500 for invalid execution headers
#14786 Partial preview rule ownership and wider domain hash; the jobs worker cache key and lock changes target a worker 1.9.x does not have
#14823 Ported the pending-invite e2e step is dropped: on 1.9.x an invite sent by a console owner is confirmed immediately, so that state cannot be reached
#14874 Ported
#14794 Ported file uploads now record uploaderId in metadata, which the internal import ownership check needs
#14870 Partial Appwrite sources already use the resolver on 1.9.x; Supabase and NHost sources now use it too, and the Supabase database host is checked and dialled by address. Deployment-host trust is not ported
#14798 Partial API and worker validation of NHost subdomain, region and database name; the Label validator and NHost database address pinning live in utopia-php/validators and utopia-php/migration and need a library release
#14868 Ported DocumentsDB and VectorsDB source key probes
#14811 Ported host checks on save, test, and before each send; new _APP_ALLOWED_INTERNAL_ADDRESSES (1.9.10) to allow an internal relay. The vendored messaging library has no address option, so an app-side SMTP adapter dials each server on its checked address
#14812 Ported
#14822 Ported the notifications worker does not exist on 1.9.x; & in the redirect is left as written because 1.9.x's plain-text email part is the stripped HTML, so & would break its links
#14827 Ported the API hook now keeps the request's scopes, as on main
#14875 Ported Provider model filter strips secrets; identifiers stay readable with providers.read

Related: appwrite-labs/cloud#6671

@luxor-code-review

luxor-code-review Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high · 🟡 2 medium

💬 Inline comments (3)

  • 🟠 \array_any requires PHP 8.4; project targets PHP 8.3 — general.php:266
  • 🟡 Legacy stored root directories with .. now fail builds — Builds.php:421
  • 🟡 x-fallback-cookies header leaks session secrets to user code — general.php:302
🧹 Nitpicks (4) — 🟢 4 low
  • 🟢 Project-not-found path bypasses failure-URL fallback (Get.php:122) — The GitHub callback computes $redirectFailure = $state->failure ?: $settings (src/Appwrite/Platform/Modules/VCS/Http/GitHub/Callback/Get.php:99) and every failure branch uses it, except the project-not-found branch at line 122, which passes the raw $state->failure.
  • 🟢 Directory validator accepts names the worker mangles (Builds.php:359) — Directory::isValid accepts values like .config/app and ..hidden/a (asserted in the unit test for dotted names), but the builds worker strips every leading dot via \ltrim($rootDirectory, '.') (src/Appwrite/Platform/Modules/Functions/Workers/Builds.php:359-361, same pattern at 425-427 and 489-491), turning .config/app into config/app.
  • 🟢 Directory validator narrows accepted path inputs (Create.php:99) — rootDirectory, providerRootDirectory, and templateRootDirectory params switched from new Text(128, 0) to the new Appwrite\Vcs\Validator\Directory (e.g. src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php:99).
  • 🟢 Nonce lock documents are never deleted or expired (Get.php:113) — The single-use nonce lock written at src/Appwrite/Platform/Modules/VCS/Http/GitHub/Callback/Get.php:113 creates a vcsCommentLocks document with only $id and no $expires attribute, and no code path ever deletes these vcs-state-* documents.

This change reworks how preview executions isolate caller credentials and how builds resolve the user-specified root directory inside cloned repositories. The header-sanitization work strips a_session_* cookies and the preview JWT before headers reach user code, adds a dedicated Headers validator with a reserved-header strip list, and reworks preview-domain authorization to use sessionActive() plus confirmed team membership. Build confinement adds a confine() helper, a new Directory validator replacing plain Text params on function/site create/update and template deployments, and symlink-safe path checks in the builds worker. VCS state handling is rewritten into a signed State object with single-use nonce locks, and the branch preview-domain hash is widened for legacy/new rule compatibility.

Files Change
app/controllers/general.php, src/Appwrite/Utopia/Request.php Preview-domain header/cookie stripping, cookie-jar reconstruction, membership-based preview authorization
src/Appwrite/Functions/Validator/Headers.php, src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php, src/Appwrite/Platform/Workers/Functions.php Reserved-header validator, execution header sanitization, worker-side keep-list handling
src/Appwrite/Vcs/Validator/Directory.php, src/Appwrite/Platform/Modules/Functions/Workers/Builds.php, function/site create/update + template deployment endpoints rootDirectory validation and path confinement in the build pipeline
src/Appwrite/Vcs/State.php, src/Appwrite/Platform/Modules/VCS/Http/GitHub/* Signed OAuth state, single-use nonce locks, failure-URL handling
src/Appwrite/Filter/BranchDomain.php, src/Appwrite/Platform/Modules/Compute/Base.php, src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php New preview-domain hash with legacy-rule fallback and ownership checks
src/Appwrite/SDK/Specification/Format/OpenAPI3.php, tests/** SDK spec support for the new validator and unit/e2e coverage for all of the above

Reviewed commit: 915dd05

@ghost

ghost commented Oct 24, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

This backport adds signed, user-bound VCS installation state, repository-root and preview-domain protections, request-header and cookie filtering, and migration-file ownership checks. It also validates and pins outbound SMTP and migration connections, adds attachment-scope checks, and updates deleted-project worker handling and provider response filtering. The SMTP private-host e2e cases now provide a password when changing servers so they exercise the host-validation behavior.

Latest changes: The SMTP private-host e2e cases now pass an explicit password for the server change, keeping the test focused on rejecting the private host under the password-preservation rule.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 10
File Change
.env, app/config/variables.php, docker-compose.yml Configure and pass through the internal-address allowlist used by outbound SMTP checks.
app/controllers/api/messaging.php, src/Appwrite/Platform/Workers/Messaging.php, src/Appwrite/Platform/Workers/Mails.php, src/Appwrite/Platform/Modules/Project/Http/Project/SMTP, src/Appwrite/Messaging/Adapter/Email/SMTP.php, src/Appwrite/SMTP/Validator/Host.php, src/Appwrite/Network/Validator/PublicHostname.php Validate SMTP destinations, dial checked addresses, and enforce attachment read scope; add regression coverage including explicit credentials in private-host update cases.
app/controllers/general.php, src/Appwrite/Utopia/Request.php, src/Appwrite/Functions/Validator/Headers.php, src/Appwrite/Platform/Workers/Functions.php, src/Appwrite/Platform/Modules/Functions/Http, src/Appwrite/Platform/Modules/Sites/Http Restrict preview authorization, filter session cookies and reserved headers, validate repository roots, and cover those behaviors in e2e tests.
src/Appwrite/Vcs/State.php, src/Appwrite/Platform/Modules/VCS/Http/GitHub, src/Appwrite/Platform/Modules/VCS/Http/Installations, src/Appwrite/Filter/BranchDomain.php, tests/e2e/Services/VCS, tests/unit/Vcs, tests/unit/Filter Sign and bind GitHub installation state, recheck project access, secure branch previews, and add VCS regression coverage.
src/Appwrite/Platform/Modules/Compute/Base.php, src/Appwrite/Platform/Modules/Functions/Workers/Builds.php, src/Appwrite/SDK/Specification/Format/OpenAPI3.php, src/Appwrite/Vcs/Validator/Directory.php, tests/unit/Vcs/Validator Constrain repository build paths and expose/test the directory validator.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations, src/Appwrite/Platform/Modules/Migrations/Validator/Endpoint.php, src/Appwrite/Platform/Workers/Migrations.php, src/Appwrite/Platform/Modules/Health/Http/Health/Certificate/Get.php, tests/e2e/Services/Migrations, tests/e2e/Services/Health, tests/unit/Network/Validators, tests/unit/SMTP/Validator Validate migration inputs and pin outbound connections to checked destinations, with endpoint and certificate regression coverage.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/CSV/Imports/Create.php, src/Appwrite/Platform/Modules/Migrations/Http/Migrations/JSON/Imports/Create.php, src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Create.php Record upload ownership and enforce ownership checks for internal migration files.
src/Appwrite/Platform/Workers/Deletes.php, src/Appwrite/Platform/Tasks/Maintenance.php, app/init/worker/message.php Handle deletion jobs for removed projects without treating an empty project as the platform database.
src/Appwrite/Utopia/Response/Model/Provider.php Filter provider secrets from model responses while keeping identifiers readable.
tests/e2e/Services/Account, tests/e2e/Services/Functions, tests/e2e/Services/Messaging, tests/e2e/Services/Projects, tests/e2e/Services/Project/SMTPBase.php, tests/e2e/Services/Sites, tests/e2e/Services/Teams, tests/resources/functions, tests/resources/sites, tests/unit/Functions/Validator, tests/unit/Utopia/RequestTest.php Add regression coverage for the backported request, messaging, function, site, SMTP, and provider security behaviors.

Reviewed the commits since 61362ab · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 24, 2026

@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 A · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing 1.9.x (before) to fix/1.9.x-security-compute (after).

Before

Scenario P50 (ms) P95 (ms) Requests RPS
API total 15.06 131.61 185 32.6
Account 29.38 166.63 35 6.85
TablesDB 14.18 21.53 35 7.99
Storage 13.34 124.92 75 16.73
Functions 23.73 31.96 40 9.03

After

Scenario P50 (ms) P95 (ms) Requests RPS
API total 14.21 128.83 185 32.8
Account 28.49 188.13 35 6.84
TablesDB 13.64 20.85 35 8.01
Storage 12.47 119.49 75 16.96
Functions 24.3 33.09 40 9.17

Delta

Scenario P95 delta (ms)
API total -2.78
Account +21.51
TablesDB -0.67
Storage -5.42
Functions +1.13
Top API waits
API request Max wait (ms)
account.sessions.email.create 573.21
account.password.update 188
account.create 134.88

@luxor-code-review luxor-code-review Bot 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.

This PR hardens function/site preview isolation and build path confinement — stripping session cookies/headers before user code runs, confining rootDirectory to repository paths, replacing VCS preview-domain hashing, and signing GitHub OAuth state — but introduces a PHP 8.4-only function on the PHP 8.3 runtime and a few compatibility gaps.

Key findings

  • 🟠 \array_any requires PHP 8.4; project targets PHP 8.3 — general.php:266
  • 🟡 Legacy stored root directories with .. now fail builds — Builds.php:421
  • 🟡 x-fallback-cookies header leaks session secrets to user code — general.php:302

Comment thread app/controllers/general.php Resolved
Comment thread app/controllers/general.php Resolved
@ChiragAgg5k
ChiragAgg5k force-pushed the fix/1.9.x-security-compute branch from 2e896d8 to f5b4523 Compare October 24, 2026 12:04
ghost
ghost previously requested changes Oct 24, 2026

@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 B · 1 blocking finding to address. Summary

Comment thread src/Appwrite/Platform/Workers/Mails.php Resolved
@ChiragAgg5k
ChiragAgg5k force-pushed the fix/1.9.x-security-compute branch from f5b4523 to 7943c1b Compare October 24, 2026 12:08
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit 7943c1b - 2 flaky tests
Test Retries Total Time Details
TablesDBCustomServerTest::testOrQueries 1 689ms Logs
TablesDBTransactionsConsoleClientTest::testBulkDeleteMatchingUpdatedDocuments 1 240.40s Logs
Commit ffb81c9 - 1 flaky test
Test Retries Total Time Details
TablesDBACIDTest::testDurability 1 240.26s Logs
Commit bb4f857 - 1 flaky test
Test Retries Total Time Details
RealtimeConsoleClientTest::testIndexesTablesAPI 1 332ms Logs
Commit 61362ab - 1 flaky test
Test Retries Total Time Details
FunctionsServerTest::testCreateExecution 1 39ms Logs
Commit 8547818 - 1 flaky test
Test Retries Total Time Details
LegacyCustomServerTest::testCreatedAfter 1 240.54s Logs

Note: Flaky test results are tracked for the last 5 commits

ArnabChatterjee20k and others added 2 commits October 24, 2026 13:32
#14783)

Ported by hand: 1.9.x has no clientForOAuth2 resource, so the user installations lookup uses utopia-php/fetch.

(cherry picked from commit acab02f)
@ChiragAgg5k
ChiragAgg5k force-pushed the fix/1.9.x-security-compute branch from 7943c1b to 6963aa3 Compare October 24, 2026 12:35
ghost
ghost previously requested changes Oct 24, 2026

@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 B · 1 blocking finding to address. Summary

@ChiragAgg5k
ChiragAgg5k force-pushed the fix/1.9.x-security-compute branch from 6963aa3 to a185a4d Compare October 24, 2026 12:52
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

ghost
ghost previously requested changes Oct 24, 2026

@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 C · 1 blocking finding to address. Summary

@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 B · See the inline comments. Summary

@ChiragAgg5k
ChiragAgg5k force-pushed the fix/1.9.x-security-compute branch 2 times, most recently from 9aa91c5 to ffb81c9 Compare October 24, 2026 13:13
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@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 B · See the inline comments. Summary

ChiragAgg5k and others added 7 commits October 24, 2026 14:42
…kport #14793)

1.9.x passed the GitHub installation state unsigned, so this also adds the HMAC signature the callback now verifies. Only the GitHub provider exists on 1.9.x.

(cherry picked from commit bbbc01d)
Ported the root directory validation and the builds worker confinement. The build artifact checks target the orchestrator build path, which 1.9.x does not have.

(cherry picked from commit e2c3e34)
Ported the preview rule ownership check and the wider, separated branch domain hash (existing previews keep their legacy domain). The jobs worker cache key and lock changes target a worker 1.9.x does not have. The ownership tests live in the existing BranchDomainTest because the rule activation helper does not exist on 1.9.x.

(cherry picked from commit 9fc6d27)
…view access (backport #14823)

(cherry picked from commit ff45743)
…ernal imports to their owner (backport #14794)

1.9.x stores no uploader on files, so uploads now record uploaderId in the file metadata for the internal import ownership check. PublicHostname gains address() for the certificate check.

(cherry picked from commit 74e4d5f)
Ported the API and worker validation of the NHost subdomain, region and database name. 1.9.x uses the vendored utopia-php/migration 1.14 and utopia-php/validators, so the Label validator and the NHost database address pinning need a library release; the shape check uses Text allow-lists instead.

(cherry picked from commit 45b90fa)
…B (backport #14868)

Ported with the 1.9.x raw client probes. The TablesDB probe keeps its 1.9.x condition, and the tests use the 1.9.x scope names, where DocumentsDB and VectorsDB share the collections and documents scopes.

(cherry picked from commit 67d57dc)
…MTP (backport #14811)

Project SMTP and messaging SMTP provider hosts are checked against public addresses on save, on the SMTP test endpoint, and again by the mails and messaging workers before each send. Project SMTP verification dials the checked address of a single server and no longer echoes the server reply. Adds _APP_ALLOWED_INTERNAL_ADDRESSES (introduced in 1.9.10) so an internal relay can still be allowed. Pinning worker connections to the checked address needs the messaging library's SMTP addresses option, which 1.9.x's vendored utopia-php/messaging does not have.

(cherry picked from commit 1c3636d)
…14822)

The notifications worker does not exist on 1.9.x.

(cherry picked from commit aedd88a)
…#14827)

Ported by hand into the 1.9.x messaging controller. 1.9.x did not keep the request's scopes, so the API hook now stores them on the request as on main.

(cherry picked from commit a6154e1)
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
@ChiragAgg5k
ChiragAgg5k force-pushed the fix/1.9.x-security-compute branch from ffb81c9 to bb4f857 Compare October 24, 2026 13:42
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@ghost
ghost dismissed stale reviews from themself October 24, 2026 13:43

The findings that requested changes are resolved. See the summary comment for what is still open.

@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

@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

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@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

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@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

@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

…ompute

# Conflicts:
#	src/Appwrite/Utopia/Request.php
#	tests/e2e/Services/Sites/SitesCustomServerTest.php
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

@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

1.9.x now requires the password again whenever the SMTP host changes (backport of #14795), so the private-host regression test passes it.
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@hansi-codes review

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.

3 participants