Repository navigation
fix(messaging): refuse a message update through another provider type's route (appwrite:appwrite:alert#4695) - #15409
Conversation
…'s route The SMS and push updaters loaded whatever message the request named and checked only that it existed. Delivery authority is the stored document alone -- the worker reads providerType from it -- so an email message reached through either route was still delivered as email: its stored attachments read and mailed out with authorization disabled, to the recipients the request chose. Only the email route demanded files.read for stored attachments, and the push route's check is keyed on an image, which an email message never carries. A key holding messages.write but not files.read could therefore submit a pending attachment-bearing email and redirect it. Assert the stored providerType against the route in all three updaters, before any schedule or message mutation, and hoist the stored-attachment files.read requirement onto the shared Messages\Action so it holds regardless of which route runs it. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Review complete. No issues found — approved ✅. The PR hardens the three message-update actions so an email, SMS, or push route can no longer touch a message of a different provider type, and so updating a message that carries stored attachments requires the
The fix closely follows the existing module patterns (guards as shared base-action helpers, guarded ordering before writes), and the test matrix covers all mismatch directions. Reviewed commit: 919b88a |
🟢 Tier S · Ready to mergeThe messaging update routes now reject messages whose stored provider type does not match the route. Attachment updates also enforce
📂 Walkthrough · 6
Reviewed |
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)
|
…-type fix(messaging): refuse a message update through another provider type's route (appwrite:appwrite:alert#4695) (cherry picked from commit ebbc824)
What does this PR do?
Fixes code-scanning alert appwrite:appwrite:alert#4695.
The SMS and push updaters loaded whatever message the request named and checked only that it existed. Delivery authority is the stored document alone —
Workers/Messaging.phpreloads the message and readsproviderTypefrom it — so an email message reached throughPATCH /v1/messaging/messages/sms/:messageIdor.../push/:messageIdwas still delivered as email: its stored attachments prepared, decrypted and mailed out withAuthorizationdisabled, to the recipients the request chose, with a body the request could rewrite.Only the email route demanded
files.readfor stored attachments, and the push route's check is keyed ondata['image'], which an email message never carries. A project key (or admin-mode session) holdingmessages.writebut notfiles.readcould therefore take an existing attachment-bearing email draft, flip it out of draft, and redirect it — exfiltrating private storage files it could not read to a mailbox of its choosing.Fix
assertProviderType()on the sharedMessages\Action, called in all three updaters immediately after the existence check and before any schedule or message mutation. A mismatch answersmessage_not_found(404): the message does not exist as far as that route is concerned.files.readrequirement moves out ofEmail/Update.phponto the same base asrequireAttachmentsScope(), keyed on the attachments the update resolves to rather than on one route's params, and every updater runs it — so the guard holds even if a future route forgets it.Push/Update.phpextendedUtopia\Platform\Actionrather than the module's ownMessages\Action; it now extends the latter, like its siblings.Test Plan
New
MessagingCustomServerTest::testMessageUpdateRejectsOtherProviderTypescovers, against amessages.write-only key, that the SMS and push routes refuse an attachment-bearing email draft, that its own route still refuses it for the attachments, that the message is left untouched, that the mismatch is refused in every direction, and that same-type updates still work. It fails onmainwith200 !== 404— the SMS route accepting the email message and moving it toprocessing.MessagingBase::testCreateDraftPushWithImageasserted that the email and SMS updaters would accept a push message and echo it back; that path is now a 404 and the assertion follows.Local run (
tests/e2e/Services/Messaging, 182 tests): all pass except the threetestCreateDraftPushWithImagevariants, which fail identically on unmodifiedmainin this environment at the public image-URL fetch (traefik hostname routing, not related to this change). Pint, PHPStan and Rector clean on the touched files.Related PRs
files.readguard this alert extends.🤖 Generated with Claude Code