Commit Graph

35227 Commits

Author SHA1 Message Date
Prem Palanisamy c71fa9d1bc Restore region check alongside host check 2026-05-24 13:48:59 +01:00
Prem Palanisamy 8f1f485184 Resolve custom-domain rule into allowlist before host check 2026-05-24 13:43:03 +01:00
Prem Palanisamy 927acbefb2 Scope rules lookup to source project 2026-05-24 13:33:43 +01:00
Prem Palanisamy 14616fd2eb Query rules by source host directly instead of loading project rules 2026-05-24 13:29:56 +01:00
Prem Palanisamy 0cdb13b398 Apply host check to Appwrite-to-CSV/JSON exports too 2026-05-24 13:25:36 +01:00
Prem Palanisamy f7baeae70c Drop loopback rewrite + helpers from OSS 2026-05-24 13:07:58 +01:00
Prem Palanisamy 9c774acf02 Trim verbose host-check comments 2026-05-24 12:43:15 +01:00
Prem Palanisamy 9c1a82bcb6 Remove loopback exception from host allowlist
Per Greptile P0: loopback as an unconditional "local" host is exploitable.
An attacker submitting endpoint=http://localhost/v1 with a victim's
projectId would bypass the host-validation gate and hit the DB fast path
against the victim's DSN. Dev clusters that genuinely use localhost as the
public domain already pass the host check via the Hostname validator
matching _APP_DOMAIN=localhost — no special-case needed.
2026-05-24 11:11:03 +01:00
Prem Palanisamy adb4665b20 Accept loopback addresses as local source endpoints
A worker container can never legitimately fetch source data from its own
loopback, but the address still means "this same cluster" to whoever wrote
it (internal automation, dev/single-node setups, console pasting localhost
in OSS dev). Treat it as local so the DB fast path is used and downstream
SDK fallbacks within the migration get the worker-host rewrite they need.
2026-05-24 09:42:13 +01:00
Prem Palanisamy fb79505503 Gate loopback rewrite to DB fast path only
Unconditional rewrite on the SDK path could silently redirect a
misrouted external migration to this cluster's own internal API — if
the caller had a valid apiKey for any project on this cluster, the
migration would read from us instead of the typed external source.
Restore the original DB-only gate.
2026-05-23 16:04:02 +01:00
Prem Palanisamy 7f4066bb86 Use Utopia Hostname validator for source-host allowlist matching
Mirrors src/Appwrite/Network/Cors.php, which already uses Hostname for
CORS allow-listing. Replaces the inline exact + suffix-with-dot logic
with the validator's built-in exact + wildcard handling (*.domain).
Normalizing _APP_DOMAIN through parse_url too closes the same
port-suffix gap that the previous commit closed for _APP_MIGRATION_HOST.
2026-05-23 15:37:19 +01:00
Prem Palanisamy c5fe22e4be Strip port from _APP_MIGRATION_HOST before host equality check
parse_url(PHP_URL_HOST) strips the port from the source URL, so an env
value like 'appwrite:8080' would never equal the parsed source host
'appwrite'. Normalize the env value through the same parse_url so the
local-fast-path routing still triggers when the deployment publishes
the migration host with an explicit port.
2026-05-23 15:25:58 +01:00
Prem Palanisamy 12a6a1f482 Trim verbose comments to essentials 2026-05-23 14:49:25 +01:00
Prem Palanisamy ced8594752 Mirror cloud worker: empty-endpoint fallback + loopback rewrite
Three parity changes with appwrite-labs/cloud#4103:

1. Empty endpoint clause in $isLocalEndpoint so callers bypassing
   processMigration's defaulting (e.g. unit tests) still get the DB path
   when _APP_MIGRATION_HOST is configured.

2. resolveLocalEndpoint + getMigrationEndpoint helpers, with the inline
   construction in processMigration consolidated to use them.

3. Always rewrite loopback source URLs (localhost / 127.0.0.1 / etc.)
   to the internal host for SourceAppwrite, on both DB and SDK paths.
   Loopback addresses are unreachable from inside the worker container;
   the rewrite preserves legit dev scenarios. SDK auth still gates access.
2026-05-23 14:40:12 +01:00
Prem Palanisamy 7f5b0225b7 Trim verbose comment in source-resolution check 2026-05-22 18:09:43 +01:00
Prem Palanisamy 2eb5aca116 Accept _APP_MIGRATION_HOST too when matching local source endpoint
_APP_DOMAIN is the public host users paste from console, but programmatic
migrations that leave `endpoint` blank default to _APP_MIGRATION_HOST in
processMigration. Both are valid references to this cluster; checking only
_APP_DOMAIN rejected the second pattern (e.g. CI tests pass the internal
host directly) and routed legitimate intra-cluster migrations to SDK.
2026-05-22 17:58:14 +01:00
Prem Palanisamy 2b08313cda Use parse_url + str_ends_with for endpoint check
Substring matching on the full URL hit false positives in three ways:
the domain in a query string, a `customer.com.attacker.io` suffix attack,
and `fake-customer.com` superstring matches. Parse the host out of the
URL and match against `_APP_DOMAIN` exactly or as a `.`-prefixed suffix
(to allow region subdomains like `fra.localhost`).
2026-05-22 15:26:48 +01:00
premtsd-code a91796db14 Merge branch '1.9.x' into fix-migrations-trust-endpoint-for-source 2026-05-22 13:19:09 +01:00
Prem Palanisamy 5f96db51c2 Use endpoint substring match against _APP_DOMAIN for local source
The apiKey-ownership approach required reading project keys and was specific to
the bug case. The simpler endpoint check covers the same bug — same projectId
on source and destination only means "local" when the source endpoint actually
contains this installation's public domain.
2026-05-22 13:02:51 +01:00
Harsh Mahajan 8436fb0175 Merge pull request #12375 from appwrite/fix/organization-projects-api
Fix: organization project API headers and queries
2026-05-22 16:46:45 +05:30
harsh mahajan 6a4dcd76a7 Keep organization projects schema unchanged 2026-05-22 15:45:32 +05:30
harsh mahajan e831b3e952 Add project status index 2026-05-22 15:39:16 +05:30
Prem Palanisamy 249bc80a3b Use array_map + in_array for project key match 2026-05-22 11:05:54 +01:00
harsh mahajan 4dec4f2ff2 Fix organization project API headers and queries 2026-05-22 15:32:44 +05:30
Prem Palanisamy b6583e231c Iterate keys in PHP instead of querying encrypted secret field 2026-05-22 11:00:40 +01:00
Prem Palanisamy 0ca4234d94 Reuse isAppwriteToAppwrite for credential defaulting check 2026-05-22 10:27:23 +01:00
Prem Palanisamy e1ebdd1c4e Skip credential defaulting for Appwrite -> Appwrite migrations 2026-05-22 10:23:48 +01:00
Prem Palanisamy f3955f92b2 Split source resolution into readable early-return style 2026-05-22 10:08:28 +01:00
Prem Palanisamy 0a2d29ecd5 Drop local candidate var, use $this->sourceProject directly 2026-05-22 10:03:13 +01:00
Prem Palanisamy 28b065463f Inline source resolution back into processSource 2026-05-22 09:58:11 +01:00
Prem Palanisamy 3684cdc588 Extract canReadSourceFromLocalDb helper 2026-05-22 09:53:47 +01:00
premtsd-code 2bfa65f518 Merge branch '1.9.x' into fix-migrations-trust-endpoint-for-source 2026-05-22 09:47:07 +01:00
Prem Palanisamy 4e5a624e06 Drop redundant !== false on Database::findOne result 2026-05-22 09:45:37 +01:00
Prem Palanisamy 0c367acd6d Short-circuit to SDK path when local source lookup is empty 2026-05-22 09:37:42 +01:00
Prem Palanisamy a0e8fe92fe Hoist credential guard to start of processSource 2026-05-22 09:26:29 +01:00
Prem Palanisamy e35cfa928a Verify apiKey ownership to safely take DB fast path for SourceAppwrite 2026-05-22 09:22:01 +01:00
Harsh Mahajan aa4c6b6e8f Merge pull request #12374 from appwrite/fix/smtp-test-email-missing-platform-vars
Fix missing platform variables in SMTP test email template
2026-05-22 13:39:59 +05:30
harsh mahajan 2628cc31fc Remove unused $plan injection 2026-05-22 13:12:50 +05:30
harsh mahajan e3768ce8ee Fix missing platform variables in SMTP test email template
The SMTP test email uses email-base-styled.tpl as its base template,
which contains {{platform}}, {{logoUrl}}, {{accentColor}}, and social/
legal link placeholders. These were never passed as template variables,
causing them to render as literal strings (e.g. "{{platform}} logo").

Inject the platform config and pass the variables to MailMessage,
matching the pattern used by OTP and magic-url email flows.

Co-Authored-By: Harsh Mahajan <harsh@appwrite.io>
2026-05-22 13:03:48 +05:30
Jake Barnby dfc5f1c8dc Merge pull request #12371 from appwrite/fix-project-smtp-port-type
fix(project): cast smtpPort to int in response model
2026-05-22 19:09:07 +12:00
Harsh Mahajan e375009a49 Merge pull request #12373 from appwrite/feat-ser-401-expose-build-trigger-fields
Expose providerBranches and providerPaths in Function and Site response
2026-05-22 12:36:59 +05:30
harsh mahajan cf1623bc91 Expose providerBranches and providerPaths in Function and Site response models
These fields were already persisted on update but omitted from the response
model, causing them to disappear after a page refresh in the console.

Co-Authored-By: Harsh Mahajan <harsh@appwrite.io>
2026-05-22 12:27:05 +05:30
Prem Palanisamy e364082577 fix(project): cast smtpPort to int in response model 2026-05-22 07:52:25 +01:00
Prem Palanisamy 507f9d6c6c Require explicit endpoint + apiKey for external Appwrite sources 2026-05-22 07:16:18 +01:00
Prem Palanisamy cbf2fd6e6a fix(migrations): support external Appwrite sources 2026-05-22 06:58:19 +01:00
Luke B. Silver 9951ccdca3 Merge pull request #12338 from appwrite/fix/coroutines-correctness
chore: migrate to utopia-php/http feat-safe-wildcards
2026-05-21 21:58:55 +01:00
loks0n 035cbacbfb Use 'params' injection in V20 filter
Drops the redundant Route::resolveParams() call. The matched path
params are now provided directly via the new frame-local 'params'
injection from utopia-php/http, avoiding a second URL parse.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 21:09:55 +01:00
loks0n 690c72b789 Use 'route' injection in remaining api/auth init hooks
The 'route' injection is frame-local and non-nullable inside a
matched action's hooks. Replaces \$utopia->match() lookups in api.php
and auth.php init hooks, drops the dead \$utopia inject from the
session shutdown hook, and removes the now-redundant null guards.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 21:09:41 +01:00
loks0n dd0c8af160 Use 'route' injection in shutdown hooks
The 'route' injection introduced in utopia-php/http feat-safe-wildcards
is frame-local and non-nullable inside a matched action's hooks, so
the shutdown handlers in api.php and mock.php no longer need to call
match() and dereference a nullable result.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 21:09:41 +01:00
loks0n 933fffd763 Use route template instead of request URI for documentsdb path check
The documentsdb/vectorsdb routes are registered with
setHttpPath('/v1/documentsdb/...') with no aliases, so getPath()
returns a template containing the substring we're matching against
— and matches the prior getMatchedPath() semantics without depending
on the raw request URI.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 21:09:41 +01:00