Repository navigation
fix(network): reuse resolved addresses for outbound requests - #14028
Conversation
Webhook deliveries and the favicon and image avatars resolve the target host while validating it, then curl resolved it again on its own. The validators now expose the addresses they resolved as CURLOPT_RESOLVE entries, and those requests reuse them, so every request goes to the addresses that were validated and skips the duplicate lookup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
🔵 Tier A · Mergeable after minor fixes
The validators retain successfully checked DNS addresses and expose them as cURL resolve entries. Webhook deliveries and image requests reuse those entries, while favicon fetching pins each redirect hop separately. The updated hostname tests send real requests to local IPv4 and IPv6 listeners and check that the original Host header is preserved. Latest changes: The newest commits enable overriding IP classification in the named test fake and replace resolve-entry string assertions with local cURL request tests.
Fix with agent prompt### Issue 1
src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php:264
**Cover address pinning through the real request path**
The existing `FetcherTest` always supplies a scripted client, so it bypasses this new cURL branch; the new validator tests only check generated entries. Please add a deterministic e2e regression that verifies the actual destination stays pinned, including after a redirect—removing `CURLOPT_RESOLVE` from the fetch path currently leaves all focused tests passing.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 7
⏳ Still open from earlier reviews · 1
Reviewed the commits since |
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Replace the assertions on formatted CURLOPT_RESOLVE strings with requests sent through the curl adapter for hostnames that have no DNS record, and assert they reach a local listener at the resolved address (IPv4, IPv6 and a trailing-dot host). The IP policy is now late-static-bound like the lookup, so the named fake can accept loopback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Combines #14028 (reuse validated addresses via CURLOPT_RESOLVE for webhooks and avatars) with the connected-IP guard: each of those fetches pins to the validated addresses and still sets PublicHostname::curlOptions(). isAllowed() calls static::isPublicIp() so the fixed-table test subclass from #14028 keeps working. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main moved by 20 commits, which left the PR conflicting, so GitHub ran no CI on f4351e9. The commits bring: - the email-password session duration parameter (#14004); - resolved-address reuse for outbound requests (#14028); - VCS and build commands through Utopia\Command (#14022); - the full first chunk in the resume ownership test (#14026). That is the same change as the branch's e24bef4, so it merged cleanly. The one conflict was the import block of src/Appwrite/Deployment/Deployments.php. The branch had added ClientExceptionInterface and main had added Utopia\Command, so both stay, in alphabetical order. Main changed neither the root composer.json nor composer.lock, and none of its changes touch the database 8 API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…SRF) utopia-php/client: a Client takes a required Destination and passes it to its adapter through Adapter::withDestination(). Every adapter enforces it on the address each connection actually reaches, per connection and per redirect hop (curl: CURLOPT_PREREQFUNCTION; Swoole: dial a checked address), drops proxies unless the destination permits one, and refuses to send without a destination. Anywhere, PublicInternet and IPRange are the destinations. The shared AdapterContract tests prove the behaviour for both adapters. A PHPStan extension bans curl_init/curl_multi_init outside the Curl adapter. utopia-php/dns: Lookup and Lookup\Recursive resolve a hostname through configured recursive resolvers over TCP, failing over past a broken server and failing closed on a partial answer. Appwrite: clientForOAuth2, clientForWebhooks and clientForAvatars are built in resources.php over PublicInternet plus this container's _APP_ALLOWED_INTERNAL_ADDRESSES. publicHostname and publicURL are ordinary validators over the same destination and _APP_DNS_EXTERNAL; publicHostname also returns a checked address for a migration's Postgres connection. OAuth2, OIDC JWKS, webhooks, messaging webhooks, avatars, identity photos and migrations use them. OAuth2 takes a required Client. The executor, VCS, domains, reCAPTCHA, installer and assistant raw curl sites move onto Utopia\Client. The CURLOPT_RESOLVE pinning from #14028 and the PublicHostname statics are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…SRF) utopia-php/client: a Client takes a required Destination and passes it to its adapter through Adapter::withDestination(). Every adapter enforces it on the address each connection actually reaches, per connection and per redirect hop (curl: CURLOPT_PREREQFUNCTION; Swoole: dial a checked address), drops proxies unless the destination permits one, and refuses to send without a destination. Anywhere, PublicInternet and IPRange are the destinations. The shared AdapterContract tests prove the behaviour for both adapters. A PHPStan extension bans curl_init/curl_multi_init outside the Curl adapter. utopia-php/dns: Lookup and Lookup\Recursive resolve a hostname through configured recursive resolvers over TCP, failing over past a broken server and failing closed on a partial answer. Appwrite: clientForOAuth2, clientForWebhooks and clientForAvatars are built in resources.php over PublicInternet plus this container's _APP_ALLOWED_INTERNAL_ADDRESSES. publicHostname and publicURL are ordinary validators over the same destination and _APP_DNS_EXTERNAL; publicHostname also returns a checked address for a migration's Postgres connection. OAuth2, OIDC JWKS, webhooks, messaging webhooks, avatars, identity photos and migrations use them. OAuth2 takes a required Client. The executor, VCS, domains, reCAPTCHA, installer and assistant raw curl sites move onto Utopia\Client. The CURLOPT_RESOLVE pinning from #14028 and the PublicHostname statics are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What does this PR do?
Webhook deliveries and the favicon and image avatars resolve the target host while validating it (
PublicHostname/PublicURL), and then curl resolved the same host again when sending the request. This makes those requests reuse the addresses from validation:PublicHostname::getResolve($port)returns the addresses from the last successful check asCURLOPT_RESOLVEentries (IPv6 bracketed, host kept as given, including a trailing dot, which curl matches exactly). IP literals return nothing, since curl does not resolve them.PublicURL::getResolve()does the same for a validated URL, deriving the port from the URL.assertSafeUrl()on every redirect hop it follows.Each request now goes to the exact addresses that were validated, and the duplicate DNS lookup is skipped.
Host, SNI and certificate checks still use the original hostname.Test Plan
PublicHostnameTestcases use a fixed-table resolver (a named subclass, which is why the lookup is nowstatic::resolve()). They cover the entry format with mixed IPv4/IPv6 answers, trailing-dot hostnames, IP literals, and entries being cleared after a failed check.PublicURLTestcase covers IP literals and failed checks.Hostheader.Related PRs and Issues
Checklist
🤖 Generated with Claude Code