Repository navigation
fix(realtime): address cross-tree event copies to the right audience - #15002
Conversation
Realtime role names are subscription-tree-relative: `user:{id}` names a
project user in the project tree but a console user in the console tree,
and either identity can be minted by signing up with a colliding custom
ID. Execution events were published to the `console` subscriber carrying
the project user's `user:{id}` read roles, so a console account created
with a victim's user ID received execution updates (payload includes
logs and errors) from every project in the region; the reverse leaked
admin executions to project users.
Resolve each copy's roles against the tree it is delivered to: the
console copy of a project event is re-addressed to the project's
organization team (what the console subscribes with), and the project
copy of a console-keyed event is dropped.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Review complete. No issues found — approved ✅. The change teaches
Review scans across correctness, concurrency, security, realtime authorization, eventing semantics, and test coverage surfaced only minor observations below the reporting threshold (notably that wildcard/guest roles in the rewrite path are worth watching, and that unit tests cover the resolver rather than end-to-end delivery); no blocking defects were found. Reviewed commit: 1f55e80 |
🟢 Tier S · Ready to mergeThe realtime event publisher now omits project-tree copies when an event is keyed to the console tree. The added unit and end-to-end tests cover console-scoped event routing and execution event delivery.
📂 Walkthrough · 3
✅ Fixed since the last review · 1
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)
|
…n reads Address review feedback on #15002: document that re-addressing the console copy to the org team neither broadens nor narrows the read set, because the console reads executions in admin mode where isPrivileged already drops the per-execution permission filter. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Thanks — I looked into the broadening concern and I believe this matches the existing read boundary rather than widening it. The console reads executions in admin mode, and The prior behavior addressed the console copy with the execution's I've added a comment at the call site documenting this equivalence (e000a6d). Happy to add an e2e asserting a non-triggering org member receives the console copy while a colliding foreign-project user does not, if that'd help — but narrowing below the team role would break live execution logs for org admins, who are authorized to see them. Could you re-review? |
|
@hansi-codes review |
Review follow-up on #15002: the bare team:{teamId} role is held by every confirmed member, but only privileged members (owner/developer/ admin per User::isPrivileged) bypass the per-execution permission filter when the console reads executions in admin mode — a plain member cannot GET another user's execution. Addressing the console copy to the dimensioned privileged roles (team:{teamId}/owner, …) matches that HTTP read boundary instead of broadening to all members. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@hansi-codes review |
Review follow-up on #15002 (reverse-direction leak): in admin mode $user is the console user, so stamping read(user:{id}) on the execution put a console identity into a project-scoped resource's permissions. The project realtime copy carries it, so a project user who signs up with the colliding id receives the admin's execution updates — logs and errors included. Grant the user read permission only for a genuine project user (not privileged, not an API key); privileged and key callers already read the execution through their own authority, and the console receives its realtime copy via the organization's privileged roles. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@hansi-codes review |
The findings that requested changes are resolved. See the summary comment for what is still open.
Review follow-up on #15002: the prior commit leaves a privileged (admin- or key-invoked) execution with an empty read-permission list, and fromPayload only built execution channels when that list was non-empty — so the console copy never fired and lost live status/log updates. Build the execution channels unconditionally: the console copy is re-addressed to the org's privileged roles in Event\Realtime, while the project copy keeps the execution's read roles and so matches nothing when there is no project user (no colliding-id leak) and the invoking user otherwise. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@hansi-codes review |
The findings that requested changes are resolved. See the summary comment for what is still open.
Review follow-up on #15002: the previous guard used isPrivileged, but an admin-mode member (the built-in member role has executions.write) is not privileged yet $user is still the console user — so user:{consoleUserId} was stamped and leaked to a colliding project user. Gate on the mode instead: grant the user read permission only for a genuine project user ($mode !== APP_MODE_ADMIN), which covers every admin-mode caller regardless of org role. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@hansi-codes review |
The findings that requested changes are resolved. See the summary comment for what is still open.
…t publishers Review follow-up on #15002: making the worker default to private removed a legitimate signed-in project user's read of executions triggered by direct event publishers (documents, transactions, S3 object events). Carry the resolved read permission on the Event object, set once in the api init hook where the mode is known (admin -> none, otherwise the triggering project user), propagated by Event::from(). The function publishers forward Event::getExecutionPermissions() instead of letting the worker derive it, so admin-mode stays private while a normal project user keeps access. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@hansi-codes review |
The worker action() now takes the execution store; update the unit test's direct invocation to supply a stub so it exercises the new signature. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
On the two remaining findings: Direct event publishers (Functions.php:610): resolved in e7f8008 — the read permission is resolved once in the Admin-mode member self-read (Create.php:296): this is a deliberate, security-necessary trade-off, not an oversight. For a non-privileged admin-mode |
|
@hansi-codes review |
End-to-end proof of the fix: a project user runs an async execution
(read-scoped to user:{id}); a console account registered with the same
custom id must not receive it. Asserts the triggering project user does
receive it (positive control that the event fires), and the colliding
console account receives nothing. Reproduced the leak on main (the
console account received the execution) before the fix.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Reworked to a delivery-only fix (aligns with #14976): an event's own read roles — e.g. an execution's user:{id} — are meaningful only in its project's subscription tree. The same role delivered to the shared console tree matches an unrelated console account with that id. trigger() now re-addresses the console copy to the project's read roles (getPermissionsByType(Read)) so only real org members receive it; the project copy is unchanged, so the end user still does. Reverts the earlier stored-permission/threading approach (Create.php, worker, Func/Event, api init hook, publishers), which mutated the execution's stored permission and caused read regressions — the delivery layer is the right place, and stored permissions are left untouched. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Reworked to a delivery-only fix. Reproduced the leak e2e first (a console account registered with a project user's custom id receives that user's execution on the console realtime tree), then fixed it the right way: |
…sole-fanout # Conflicts: # src/Appwrite/Event/Realtime.php
A console-scoped event (rules.*.create, deployments) is published to
['console', projectId] but carries the project's console read roles
(team:{orgId} and friends). The project-tree copy forwarded those roles
unchanged, so a project-local team with a colliding id could receive the
console-scoped event. Skip the project copy: the event belongs only in
the console tree.
Unit regression on Event\Realtime::trigger() locks both directions: a
console-scoped event stays in the console tree, and an execution's console
copy is still re-addressed to the project read roles while the project copy
keeps user:{id} for the end user.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@hansi-codes review |
setUp() mutated the process-wide pools registration, so a later test in the same process (e.g. Locking\LockPoolTest) could no longer retrieve its pool. Swap the whole global registry for a fresh one in setUp and restore the previous registry in tearDown, leaving the original untouched. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@hansi-codes review |
The findings that requested changes are resolved. See the summary comment for what is still open.
|
@hansi-codes re: the still-open finding "Preserve execution access for admin-mode members" ( This PR does not modify
On the substance: the fix can't be to stamp a project-tree read role on the admin-mode execution. The execution lives in the project tree, and an admin-mode member's project-visible roles ( A correct fix authorizes the admin-mode read at the auth layer (admin-mode requests already pass the project-read gate in |
|
No findings on the current diff. You’re right: the admin-mode member execution-read concern is pre-existing and not a blocker for this delivery-only change. I withdraw it for this PR. The change confines console-targeted events to the console tree and uses the project’s read roles for the console copy of project events ( |
|
@hansi-codes re-review |
|
No findings on the current diff. The routing drops project-tree copies when the adapter targets |
Found in the 2026-10-27 security sweep.
Realtime role names are subscription-tree-relative:
user:{id}names a project user in the project tree but a console user in the console tree, and either identity can be minted by signing up with a colliding custom ID (consolePOST /v1/accountaccepts custom IDs).Execution events were published to the
consolesubscriber carrying the project user'suser:{id}read roles (Workers/Functions.php→Messaging/Adapter/Realtime.php→Event/Realtime.php, which sends one copy per subscriber). So:project=console&channels[]=executions, received that user's execution updates — includinglogsanderrors, which routinely carry secrets — across every project in the region.Fix: resolve each copy's roles against the tree it is delivered to, in a shared
resolveSubscriberRoles()onAppwrite\\Event\\Realtime. The console copy of a project event is re-addressed to the project's organization team (team:{teamId}, what the console actually subscribes with); the project copy of a console-keyed event is dropped. Same-project and console-origin deliveries are unchanged.Verification: unit regression
tests/unit/Event/RealtimeTest.php(6 cases, green) pins the role resolution for all tree-crossing directions plus the console-project and no-org cases. Confirmed no regression to same-projectaccountdelivery.🤖 Generated with Claude Code