Skip to content

fix(migrations): apply the outbound host policy to migration sources - #14870

Merged
abnegate merged 6 commits into
mainfrom
fix/migration-outbound-policy
Oct 23, 2026
Merged

abnegate merged 6 commits into
mainfrom
fix/migration-outbound-policy

Conversation

@abnegate

Copy link
Copy Markdown
Member

What does this PR do?

Migration sources (the worker, and the Appwrite, Supabase and NHost report routes) now apply the PublicHostname destination policy on every connection, the same one webhooks and OAuth use, via a new PublicHostname::getDestinations(). An Appwrite source on this deployment's own hosts keeps its existing local-endpoint trust.

Test Plan

New e2e test using a DNS fixture (tests/resources/dns/zones.conf, extra_hosts in docker-compose.override.yml). Migrations e2e 81/81, tests/unit/Network 84/84. Lint and PHPStan are clean.

Related PRs and Issues

  • None

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?

🤖 Generated with Claude Code

Migration sources (the worker, and the Appwrite, Supabase and NHost report routes) now apply the PublicHostname destination policy on every connection, the same one webhooks and OAuth use, via a new PublicHostname::getDestinations(). An Appwrite source on this deployment's own hosts keeps its existing local-endpoint trust.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. 🟡 1 medium

💬 Inline comments (1)

  • 🟡 Deployment-host exemption is dead for internal hosts and strips rebinding pinning — Get.php:81
🧹 Nitpicks (3) — 🟢 3 low
  • 🟢 Worker-path rebinding test never pins the failure cause (MigrationsBase.php:363) — The new rebinding test asserts assertNotEmpty($migration['errors']) on the worker path (tests/e2e/Services/Migrations/MigrationsBase.php:369) without checking the error type or message, unlike the report half of the same test which asserts migration_provider_error at line 361.
  • 🟢 Scheme-qualified _APP_MIGRATION_HOST misparsed in allowlist (Get.php:102) — isDeploymentHost() derives its allowlist via parse_url('http://' .
  • 🟢 Rebinding regression test covers Appwrite source only (MigrationsBase.php:345) — The new e2e test testMigrationSourceRebindingToPrivateAddressIsRefused (tests/e2e/Services/Migrations/MigrationsBase.php:345-401) exercises only the Appwrite source, while the PR also enables destination pinning for the Supabase and NHost sources (src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Supabase/Report/Get.php, .../NHost/Report/Get.php, worker at src/Appwrite/Platform/Workers/Migrations.php:352).

This PR hardens migration source connections against DNS rebinding by wiring PublicHostname::getDestinations() into setDestinations() on migration sources, both in the HTTP report endpoints and the Migrations worker, and adds an e2e regression test plus Docker DNS fixtures for the rebinding scenario.

Files Change
src/Appwrite/Network/Validator/PublicHostname.php Exposes resolved destination addresses via getDestinations().
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/*/Report/Get.php Applies destination pinning to Appwrite (conditionally, exempting deployment hosts), NHost, and Supabase report sources.
src/Appwrite/Platform/Workers/Migrations.php Applies the same conditional destination pinning on the worker path for Appwrite sources.
tests/e2e/Services/Migrations/MigrationsBase.php Adds a DNS-rebinding refusal regression test for the Appwrite source.
docker-compose.override.yml, tests/resources/dns/zones.conf Adds host-gateway mapping and a rebinding DNS zone so the test can exercise the check.

Note: two correctness scan producers failed to publish artifacts; their coverage (deployment-host exemption logic) was instead adjudicated via the security and domain scans.

Reviewed commit: f6f993d

@ghost

ghost commented Oct 23, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The incremental change introduces no actionable issues.

Migration source connections now apply the public-host destination policy across the worker and the Appwrite, Supabase, and NHost report routes, while preserving trust for configured deployment hosts. The PR adds deployment-host validation and coverage for private deployment destinations and DNS rebinding.

Latest changes: The latest test update accepts an existing proxy rule for the private test hostname and only deletes the rule when this run created it.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 12
File Change
app/init/resources.php Registers the deployment-host validator for dependency injection.
docker-compose.override.yml Adds DNS fixture host mappings and a fixed Appwrite test-network address for private-host migration requests.
src/Appwrite/Network/Validator/DeploymentHostname.php Validates configured deployment hostnames and their subdomains.
src/Appwrite/Network/Validator/PublicHostname.php Exposes the configured destination policy for migration connections.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Appwrite/Create.php Validates Appwrite migration source destinations while preserving trust for deployment hosts.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Appwrite/Report/Get.php Validates Appwrite report destinations and permits configured deployment hosts.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/NHost/Report/Get.php Applies destination restrictions to NHost report connections.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Supabase/Report/Get.php Applies destination restrictions to Supabase report connections.
src/Appwrite/Platform/Workers/Migrations.php Applies destination restrictions to migration worker connections while preserving verified deployment-host access.
tests/e2e/Services/Migrations/MigrationsBase.php Covers private deployment-host migration behavior and safely reuses a pre-existing proxy rule.
tests/resources/dns/zones.conf Adds DNS fixture records for the private deployment hostname.
tests/unit/Network/Validators/DeploymentHostnameTest.php Tests accepted deployment-host formats and rejected inputs.

Reviewed the commits since f217a0a · 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

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@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.

Adds DNS-rebinding protections to migration sources by pinning connections to validated destinations, with e2e coverage and test DNS fixtures.

Key findings

  • 🟡 Deployment-host exemption is dead for internal hosts and strips rebinding pinning — Get.php:81

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/migration-outbound-policy (after).

Metric Before After Change
🚀 Requests/sec 195.66 211.11 🟢 +7.9%
⏱️ Latency P50 87.46 ms 81.22 ms 🟢 -7.1%
⏱️ Latency P95 211.95 ms 195.71 ms 🟢 -7.7%
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 81.22 195.71 13,509 211.11 -16.24
Account 157.48 290.61 711 11.79 -14.61
TablesDB 77.41 139.33 7,347 118.36 -26.68
Storage 77.54 188.26 3,555 58.69 -4.5
Functions 119.03 239.92 1,896 31.94 -4.95

Top API waits (after)

API request Max wait (ms)
account.name.update 440.04
functions.variables.update 373.37
storage.buckets.create 367.56
functions.create 367.41
tablesdb.rows.create 349.9

…and the worker

The report and create routes ran the public address check before the
deployment host exemption, so an internal _APP_MIGRATION_HOST or a
subdomain of _APP_DOMAIN at a private address was refused there while the
worker accepted it. Check deployment hosts first in all three, and keep
holding every other host to the checked addresses on each connection.

The deployment hosts move into a DeploymentHostname validator shared by
the routes and the worker, which also reads a scheme-qualified
_APP_MIGRATION_HOST or _APP_DOMAIN by its host instead of misparsing it.

The rebinding test now pins the worker's refusal to the aborted connection
rather than any failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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

@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 and others added 2 commits October 23, 2026 16:09
… network

The test connected back to the API through the docker host, which Linux runners do not route for a container on a user-defined network. The API now has a fixed address on the appwrite network and the fixture host points at it, so the host check still sees the fixture's private address while the connection stays inside the network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI enables router protection, which only serves the API on platform hostnames and connected API domains, so the source refused the test's requests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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

@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 6d258d2 into main Oct 23, 2026
71 checks passed
@abnegate
abnegate deleted the fix/migration-outbound-policy branch October 23, 2026 04:05
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…(backport #14870)

1.9.x already pins Appwrite sources to checked public addresses through the migration library's resolver. This applies the same resolver to the Supabase and NHost sources and connects to the checked address of the Supabase database host, which 1.9.x did not check at all. The deployment host trust and its DNS fixture test are not ported.

(cherry picked from commit 6d258d2)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…(backport #14870)

1.9.x already pins Appwrite sources to checked public addresses through the migration library's resolver. This applies the same resolver to the Supabase and NHost sources and connects to the checked address of the Supabase database host, which 1.9.x did not check at all. The deployment host trust and its DNS fixture test are not ported.

(cherry picked from commit 6d258d2)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…(backport #14870)

1.9.x already pins Appwrite sources to checked public addresses through the migration library's resolver. This applies the same resolver to the Supabase and NHost sources and connects to the checked address of the Supabase database host, which 1.9.x did not check at all. The deployment host trust and its DNS fixture test are not ported.

(cherry picked from commit 6d258d2)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…(backport #14870)

1.9.x already pins Appwrite sources to checked public addresses through the migration library's resolver. This applies the same resolver to the Supabase and NHost sources and connects to the checked address of the Supabase database host, which 1.9.x did not check at all. The deployment host trust and its DNS fixture test are not ported.

(cherry picked from commit 6d258d2)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…(backport #14870)

1.9.x already pins Appwrite sources to checked public addresses through the migration library's resolver. This applies the same resolver to the Supabase and NHost sources and connects to the checked address of the Supabase database host, which 1.9.x did not check at all. The deployment host trust and its DNS fixture test are not ported.

(cherry picked from commit 6d258d2)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…(backport #14870)

1.9.x already pins Appwrite sources to checked public addresses through the migration library's resolver. This applies the same resolver to the Supabase and NHost sources and connects to the checked address of the Supabase database host, which 1.9.x did not check at all. The deployment host trust and its DNS fixture test are not ported.

(cherry picked from commit 6d258d2)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…(backport #14870)

1.9.x already pins Appwrite sources to checked public addresses through the migration library's resolver. This applies the same resolver to the Supabase and NHost sources and connects to the checked address of the Supabase database host, which 1.9.x did not check at all. The deployment host trust and its DNS fixture test are not ported.

(cherry picked from commit 6d258d2)
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…d-policy

fix(migrations): apply the outbound host policy to migration sources

(cherry picked from commit 6d258d2)
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.

1 participant