Repository navigation
fix(messaging): require files.read to attach files to emails - #14827
Conversation
The worker delivers attached file contents, so attaching a file needs the same scope as reading it.
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
🧹 Nitpicks (1) — 🟢 1 low
This PR enforces the
Reviewed commit: 90deb7e |
🟢 Tier S · Ready to merge
The email create and update endpoints require Latest changes: The new commits move the update authorization check ahead of message mutations and include stored attachments when deciding whether
📂 Walkthrough · 3
✅ Fixed since the last review · 1
Reviewed the commits since |
There was a problem hiding this comment.
Adds a files.read scope gate for email message attachments on create and update, plus an e2e contract test for the scoped-key rejection path.
Key findings
- 🟡 Scope check runs after schedule writes in update — Update.php:203
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
Stored attachments are delivered when a draft is sent or scheduled, so the files.read check covers them as well as new ones, and runs before any schedule is written.
The findings that requested changes are resolved. See the summary comment for what is still open.
…ent-scope fix(messaging): require files.read to attach files to emails (cherry picked from commit a6154e1)
What
Email messages can attach storage files (
attachmentsonPOST /v1/messaging/messages/emailandPATCH /v1/messaging/messages/email/:messageId), and the messaging worker reads and decrypts those files when it sends the message. The endpoints only checked that the bucket and file exist, so a caller holdingmessages.writebut notfiles.readcould still have file contents delivered.Both endpoints now require
files.readin the caller's scopes when the message would carry attachments, and otherwise return401 general_unauthorized_scope. On update this covers the stored attachments when the field is omitted, and the check runs before any schedule is written. Clearing attachments with an empty list is still allowed. Messages without attachments are unchanged, and every console role already holds both scopes.Tests
MessagingCustomServerTest::testEmailAttachmentsRequireFilesRead: a draft with an attachment is created with a full key; a key with onlymessages.read/messages.writecan still create a draft without attachments, but gets401 general_unauthorized_scopewhen creating a message with an attachment, adding one, or updating (including scheduling) a draft that already has one; the refused update leaves the draft unscheduled; clearing the attachments succeeds. Runs on CI.Related: appwrite-labs/cloud#6666