Skip to content

fix(proxy): claim a rule domain only on a DNS label boundary - #15303

Merged
ChiragAgg5k merged 3 commits into
mainfrom
fix/proxy-domain-label-boundary
Nov 4, 2026
Merged

ChiragAgg5k merged 3 commits into
mainfrom
fix/proxy-domain-label-boundary

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

What

Proxy\Action::isAppwriteOwned() decided whether a requested custom domain belongs to the platform with a bare str_ends_with($domain, $appwriteDomain). That matches sibling names that merely end with the configured site/function domain string but are not subdomains of it — e.g. with _APP_DOMAIN_FUNCTIONS_FALLBACK=fallback.localhost, the name evilfallback.localhost passed.

A project holding rules.write could therefore submit such a domain and have the rule stored in verified status with owner = Appwrite, which makes the certificate worker skip DNS validation. The rule is the record the edge uses to route a hostname to a project's site/function.

Fix

Match on a DNS label boundary: the domain must equal the platform domain, or end with . + the platform domain (a real subdomain). Lookalike siblings now take the normal DNS-verification path like any other custom domain.

Finding

Strix #4 (low, CVSS 3.1). Suffix check treats any domain ending with the platform domain string as Appwrite-owned.

Test

Extended testCreateRuleOnFunctionsFallbackDomain: a <uniq>fallback.localhost lookalike creates 201 but is not verified (it is not claimed as Appwrite-owned), alongside the existing real-subdomain success and the rejected exact/nested cases.

composer lint and composer analyze pass.

Part of appwrite-labs/infrastructure#1013

isAppwriteOwned matched the platform domain with a bare str_ends_with, so
a sibling name like `<x>fallback.localhost` was treated as Appwrite-owned
and stored verified with owner=Appwrite, skipping DNS validation. Require
the domain to equal the platform domain or be a subdomain of it, and
assert a lookalike is not auto-verified in the Proxy e2e.
@luxor-code-review

luxor-code-review Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to

🟡 Medium — Sibling-domain suffix match remains in SSL task · src/Appwrite/Platform/Tasks/SSL.php

The PR fixes the evil-appwrite.io sibling-domain bypass in isAppwriteOwned(), but the same bare suffix match survives in the ssl CLI task, which still marks any domain ending in the platform suffix as owner: 'Appwrite' (src/Appwrite/Platform/Tasks/SSL.php:76-81). The certificates worker then skips DNS verification entirely for rules owned by Appwrite (src/Appwrite/Platform/Workers/Certificates.php:552-558). An operator running the ssl task for a lookalike domain therefore gets a rule that bypasses domain-ownership validation on the TLS-cert issuance path — the same impact this PR's fix closes in the HTTP path.


This PR hardens isAppwriteOwned() in the Proxy module so that domains merely ending in a platform suffix (e.g. evil-appwrite.io) no longer count as Appwrite-owned; the e2e Proxy suite covers the new fallback-domain rule behavior. The change closes a real bypass in the HTTP request path, but the identical bare-suffix check survives in the ssl CLI task, keeping the certificate-issuance path exposed.

Files Change
src/Appwrite/Platform/Modules/Proxy/Action.php Tightens the ownership check to require a DNS label boundary (exact match or .suffix) instead of a bare str_ends_with.
tests/e2e/Services/Proxy/ProxyBase.php Adds e2e coverage for fallback-domain rule creation reflecting the corrected ownership semantics.

Reviewed commit: 4fa4def

@appwrite

appwrite Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The updated test exercises the vulnerable suffix case and verifies the lookalike is not auto-verified; no issues were found in the incremental changes.

Proxy rule ownership now requires an exact configured platform domain or a domain suffix separated by a DNS label boundary. The Proxy E2E test covers both a genuine fallback subdomain and a lookalike sibling that must take the normal DNS-verification path.

Latest changes: The new commits make the lookalike test use a valid sibling label (xfallback) that still matches the old bare suffix check.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Platform/Modules/Proxy/Action.php Recognizes platform-owned domains only on an exact match or DNS label boundary.
tests/e2e/Services/Proxy/ProxyBase.php Tests real fallback subdomains and lookalike siblings that must not be auto-verified.

Merged main (51b1d0c); no changes to this PR's code since 54ab373 · Details · Comment @appwrite review to re-run, or mention @appwrite with a question.

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

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Nov 4, 2026

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.

The 2-label sibling was rejected by the level restriction before reaching
the ownership check; <uniq>.xfallback.localhost passes the restriction yet
is not a subdomain of fallback.localhost.
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/proxy-domain-label-boundary (after).

Metric Before After Change
🚀 Requests/sec 206.54 214.28 ⚪ +3.7%
⏱️ Latency P50 83 ms 79.46 ms ⚪ -4.3%
⏱️ Latency P95 198.9 ms 197.13 ms ⚪ -0.9%
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 79.46 197.13 13,680 214.28 -1.77
Account 159.16 304.63 720 12.01 +18.15
TablesDB 76.45 139.62 7,440 118.79 -15.5
Storage 73.81 168.17 3,600 59.21 -12.61
Functions 122.54 239.22 1,920 32.26 -9.58

Top API waits (after)

API request Max wait (ms)
tablesdb.rows.create 574.55
functions.variables.update 528.67
account.name.update 519.48
functions.create 464.35
account.prefs.update 355.96

@ChiragAgg5k ChiragAgg5k closed this Nov 4, 2026
@ChiragAgg5k ChiragAgg5k reopened this Nov 4, 2026
@ChiragAgg5k
ChiragAgg5k merged commit ecc65c0 into main Nov 4, 2026
69 of 72 checks passed
@ChiragAgg5k ChiragAgg5k self-assigned this Nov 5, 2026
ChiragAgg5k added a commit that referenced this pull request Nov 12, 2026
fix(proxy): claim a rule domain only on a DNS label boundary

(cherry picked from commit ecc65c0)
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