Repository navigation
fix(migrations): hide the export download link from a data-blind key - #15268
Conversation
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.
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
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
Reviewed commit: 5600af4 |
🟢 Tier S · Ready to merge
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.
📂 Walkthrough · 4
✅ Fixed since the last review · 2
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
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.
fix(migrations): hide the export download link from a data-blind key (cherry picked from commit 8f4601d)
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/migrationsandGET /v1/migrations/{migrationId}return the signedoptions.downloadUrlpersisted 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.writecould still list the project's export migrations — including ones a console user or a data-scoped key created — read eachoptions.downloadUrl, and fetch the complete dumps, bypassing the collection's$permissions.This redacts
options.downloadUrlfrom 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
Actionbase soGetandXListapply it identically.Why the follow-up
A Strix retest of #15145 against current
mainconfirmed 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 amigrations.read+migrations.writekey and assertsoptions.downloadUrlis absent while the status is still visible, then reads it with adocuments.read/rows.readkey and asserts the link is present. Red before this change, green after.composer lintandcomposer analyzepass locally.Reported by a Strix penetration test (low, CVSS 3.1 after the creation-side fix).
Related: appwrite-labs/cloud#6673