Skip to content

fix(messaging): withhold push image URL from callers without files.read - #15341

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/push-image-url-read-redaction
Nov 5, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/push-image-url-read-redaction

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

data.image.url is a bearer link: the storage endpoint behind it is public and checks only the token. Creating or updating a push image requires files.read, but other routes returned the stored URL without it.

Route Before After, without files.read
GET /v1/messaging/messages/:id url returned bucketId, fileId only
GET /v1/messaging/messages url returned bucketId, fileId only
PATCH /v1/messaging/messages/email/:id url returned bucketId, fileId only
PATCH /v1/messaging/messages/sms/:id url returned bucketId, fileId only
if (!isset($data['image']['url']) || \in_array('files.read', $request->getScopes(), true)) {
    return $message;
}

unset($data['image']['url']);

Only the response changes. The stored message keeps its URL, so delivery is unaffected.

Covered by extending the push image e2e test in MessagingBase. The new assertions have not been run yet, locally or against the unfixed code.

The URL is a bearer capability for the file: its endpoint is public and checks only the token. The create and update gates required files.read, but the read routes, and the email and SMS update routes, which accept any message ID, returned the stored URL to any caller.
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. 🟠 1 high · 🟡 1 medium

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

🟠 High — Redact image URL on Push/Create and Push/Update · Update.php:375 · file not in diff

// src/Appwrite/Platform/Modules/Messaging/Http/Messages/Push/Update.php
375	            ->dynamic($message, Response::MODEL_MESSAGE);

The redactImageUrl guard added in this PR covers Get, XList, and the Email/Sms update responses, but Push/Update.php still returns the raw message at line 375, and Push/Create.php does the same at line 328 (src/Appwrite/Platform/Modules/Messaging/Http/Messages/Push/Update.php:375). These are precisely the routes that populate data.image.url: they build the signed /storage/.../push URL server-side from the caller-supplied bucketId/fileId, and push is the only message type that carries an image. A key holding messages.write but not files.read can create or update a push message and receive the bearer-capability image URL straight from the response, defeating the invariant the PR establishes for the sibling endpoints.


🟡 Medium — Redact image URL in delete event payload · Delete.php:97–99 · file not in diff

// src/Appwrite/Platform/Modules/Messaging/Http/Messages/Delete.php
97	        $queueForEvents
98	            ->setParam('messageId', $message->getId())
99	            ->setPayload($response->output($message, Response::MODEL_MESSAGE));

Messages/Delete.php embeds the full unredacted message document in the messages.[messageId].delete event payload via $response->output($message, Response::MODEL_MESSAGE) (src/Appwrite/Platform/Modules/Messaging/Http/Messages/Delete.php:99). The HTTP response itself is 204 no-content, but the bearer-capability data.image.url for push messages is then delivered to all event subscribers (webhooks, functions, realtime), including ones with no files.read relationship. This re-opens through the event channel the exact disclosure the PR closes on the HTTP responses.


This PR adds a shared Action base for the messaging Messages routes that strips data.image.url (a signed, bearer-capable file URL) from message documents returned over the API when the caller lacks files.read. The same redaction is applied to messages embedded in event payloads published from update flows.

Files Change
src/Appwrite/Platform/Modules/Messaging/Http/Messages/Action.php New shared base action with getScopes() augmentation (adds files.read) and response redaction helper.
src/Appwrite/Platform/Modules/Messaging/Http/Messages/Get.php Extends the new base; message gets now redact data.image.url for non-files.read callers.
src/Appwrite/Platform/Modules/Messaging/Http/Messages/XList.php Extends the new base; list results are redacted per-message.
src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Update.php Extends the new base; email update responses and published event payloads are redacted.
src/Appwrite/Platform/Modules/Messaging/Http/Messages/Sms/Update.php Extends the new base; SMS update responses and published event payloads are redacted.
tests/e2e/Services/Messaging/MessagingBase.php E2E coverage: asserts data.image.url is absent without files.read and present with it.

Reviewed commit: 62a76f7

@appwrite

appwrite Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The changed response paths use the shared redactor, and the e2e coverage exercises URL withholding and continued availability with files.read.

Adds a shared message-response redactor that omits push image bearer URLs when the request lacks files.read, while leaving the stored message unchanged. Applies it to message get/list and email/SMS update responses, with e2e assertions for callers with and without the scope.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 6
File Change
src/Appwrite/Platform/Modules/Messaging/Http/Messages/Action.php Adds shared logic to remove the push image URL from returned messages without files.read.
src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Update.php Redacts image URLs in email update responses.
src/Appwrite/Platform/Modules/Messaging/Http/Messages/Get.php Redacts image URLs in single-message responses.
src/Appwrite/Platform/Modules/Messaging/Http/Messages/Sms/Update.php Redacts image URLs in SMS update responses.
src/Appwrite/Platform/Modules/Messaging/Http/Messages/XList.php Redacts image URLs in each message returned by list.
tests/e2e/Services/Messaging/MessagingBase.php Adds e2e assertions for withheld URLs on message get/list and update, and URL availability with files.read.

Reviewed 62a76f7 · 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 5, 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 5, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/push-image-url-read-redaction (after).

Metric Before After Change
🚀 Requests/sec 196.16 203.18 ⚪ +3.6%
⏱️ Latency P50 85.65 ms 85.77 ms ⚪ +0.1%
⏱️ Latency P95 213.32 ms 195.56 ms 🟢 -8.3%
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 85.77 195.56 12,597 203.18 -17.76
Account 153.65 292.6 663 11.05 -36.33
TablesDB 83.23 159.23 6,851 111.91 -14.1
Storage 79.38 185.26 3,315 56.44 -1.14
Functions 115.87 220.4 1,768 30.75 -26.91

Top API waits (after)

API request Max wait (ms)
account.name.update 580.87
tablesdb.rows.create 439.47
account.prefs.update 434.47
functions.create 417.68
functions.variables.update 417.11

@ChiragAgg5k
ChiragAgg5k merged commit a5b3597 into main Nov 5, 2026
35 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/push-image-url-read-redaction branch November 5, 2026 17:18
@ChiragAgg5k ChiragAgg5k self-assigned this Nov 9, 2026
ChiragAgg5k added a commit that referenced this pull request Nov 12, 2026
…tion

fix(messaging): withhold push image URL from callers without files.read

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