Skip to content

fix(migrations): hide the export download link from a data-blind key - #15268

Merged
ChiragAgg5k merged 2 commits into
mainfrom
fix/migrations-export-link-scope
Nov 3, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
fix/migrations-export-link-scope

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

What

Follow-up to #15145. That PR capped export creation to a data-read scope, so a migrations.write-only key can no longer create an export. But the read side stayed open: GET /v1/migrations and GET /v1/migrations/{migrationId} return the signed options.downloadUrl persisted on every export migration (a 7-day, caller-unbound token), and that link downloads the full collection with no credential at all.

So a key holding only migrations.read / migrations.write could still list the project's export migrations — including ones a console user or a data-scoped key created — read each options.downloadUrl, and fetch the complete dumps, bypassing the collection's $permissions.

This redacts options.downloadUrl from both read endpoints when the caller presents an API key that holds none of the data read scopes (documents.read, rows.read, documentsdb.documents.read, vectorsdb.documents.read). A console/admin session carries no API key on the request and still receives the link, as does a key that can read the data.

The check lives on the shared Migrations Action base so Get and XList apply it identically.

Why the follow-up

A Strix retest of #15145 against current main confirmed the creation leg is closed but flagged this read-side path as still reachable (downgraded medium → low). This closes it.

Test

Extended MigrationsBase::testCreateJSONExport: after the export completes, it reads the migration with a migrations.read+migrations.write key and asserts options.downloadUrl is absent while the status is still visible, then reads it with a documents.read/rows.read key and asserts the link is present. Red before this change, green after. composer lint and composer analyze pass locally.

Reported by a Strix penetration test (low, CVSS 3.1 after the creation-side fix).

Related: appwrite-labs/cloud#6673

Capping export creation to a data-read scope left the read side open: GET
/v1/migrations and GET /v1/migrations/{id} returned the caller-unbound signed
options.downloadUrl to any migrations.read holder, and the link downloads the
full collection with no credential. A migrations-only key could harvest links
from exports a console user or a data-scoped key had created.

Redact options.downloadUrl from both read endpoints when the caller presents an
API key that holds none of the data read scopes (documents.read, rows.read,
documentsdb.documents.read, vectorsdb.documents.read). A console session carries
no key on the request and still sees the link.
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 E2E asserts redaction only on Get, not on XList (MigrationsBase.php:8244) — The new e2e coverage in MigrationsBase.php (lines 8244-8262) exercises redactExportLink only through GET /migrations/:migrationId, while XList.php:97 applies the same redaction through a separate array_map path.

This PR hides the migration export download link from API responses unless the caller presents a key with a data-read scope. Redaction is implemented once on the shared Migrations Action base and applied from both the Get and XList endpoints, gated on the x-appwrite-key header; the e2e Migrations suite asserts the link is removed for unprivileged callers.

Files Change
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Action.php Adds shared redactExportLink() helper that strips options.downloadUrl when the caller lacks a data-read key scope.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Get.php, XList.php Apply the redaction helper to single-migration and list responses.
tests/e2e/Services/Migrations/MigrationsBase.php Adds e2e assertions verifying downloadUrl is redacted in responses for callers without the data-read scope.

Reviewed commit: 5600af4

@appwrite

appwrite Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The updated family-specific check matches the export creation gate, and the added coverage verifies redaction on both migration read endpoints.

Migration GET and list responses redact export download URLs from API keys that lack the data-read scope for the export's database family, while preserving access for console sessions and appropriately scoped keys. The export test verifies migration-only access, family-specific scopes, and consistent behavior on both read endpoints.

Latest changes: The latest commits select the required read scope from each migration's parent database family and add cross-family and list-endpoint assertions.

Verdict New comments Fixed Still open
✅ Approved 0 2 0
📂 Walkthrough · 4
File Change
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Action.php Redacts export links according to the read scope required by the migration's database family.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Get.php Applies shared export-link redaction to individual migration responses.
src/Appwrite/Platform/Modules/Migrations/Http/Migrations/XList.php Applies shared export-link redaction to every migration in list responses.
tests/e2e/Services/Migrations/MigrationsBase.php Checks individual and list response visibility for migration-only, family-mismatched, and data-reader keys.
✅ Fixed since the last review · 2
  • Match link access to the export's database family · src/Appwrite/Platform/Modules/Migrations/Http/Migrations/Action.php:137
  • Cover redaction on the list endpoint · src/Appwrite/Platform/Modules/Migrations/Http/Migrations/XList.php:97

Reviewed the commits since 5600af4 · 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 B · 1 blocking finding to address. Summary

@github-actions

github-actions Bot commented Nov 3, 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.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/migrations-export-link-scope (after).

Metric Before After Change
🚀 Requests/sec 189.52 189.58 ⚪ 0%
⏱️ Latency P50 89.58 ms 92.38 ms ⚪ +3.1%
⏱️ Latency P95 215.74 ms 211.39 ms ⚪ -2%
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 92.38 211.39 11,799 189.58 -4.35
Account 163.89 320.56 621 10.33 +9.54
TablesDB 89.66 165.64 6,417 105.88 -12.12
Storage 85.07 200.35 3,105 52.87 +10.99
Functions 124.25 249.08 1,656 28.97 +3.18

Top API waits (after)

API request Max wait (ms)
account.name.update 478.29
functions.create 444.04
storage.buckets.create 433.74
account.prefs.update 433.67
functions.variables.update 428.09

The download link was granted to any data read scope, so a rows.read key
could obtain a DocumentsDB export's full dump. Demand the scope the
family's own export-creation gate demands, keyed on the migration's
parentResourceType, and cover both the single read and the list endpoint
in e2e, including a cross-family negative.

@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

@ChiragAgg5k
ChiragAgg5k merged commit 8f4601d into main Nov 3, 2026
34 checks passed
@ChiragAgg5k ChiragAgg5k self-assigned this Nov 4, 2026
ChiragAgg5k added a commit that referenced this pull request Nov 12, 2026
fix(migrations): hide the export download link from a data-blind key

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