Skip to content

fix(sites): require project read permission for private previews - #14936

Merged
abnegate merged 1 commit into
mainfrom
fix/preview-project-read-permission
Oct 27, 2026
Merged

abnegate merged 1 commit into
mainfrom
fix/preview-project-read-permission

Conversation

@shimonewman

Copy link
Copy Markdown
Contributor

Summary

  • Private site previews now require the project's read permission, matching HTTP admin mode and realtime. A confirmed organization membership whose only role belongs to another project is no longer enough.
  • Unconfirmed invitations stay denied because User::getRoles() skips them.
  • testPreviewDomain covers a confirmed member scoped to another project, then the same member after they receive this project's developer role.

Fixes the remaining gap in https://github.com/appwrite/appwrite/security/code-scanning/4297. The unconfirmed-membership check landed earlier in 40495bc019.

Test plan

  • docker compose exec appwrite test tests/e2e/Services/Sites/SitesCustomServerTest.php --filter=testPreviewDomain (1 test, 143 assertions)
  • Confirm an organization owner and a team-wide developer can still open a private preview
  • Confirm a member with only project-{otherId}-developer is redirected to /auth/preview

Made with Cursor

A confirmed organization membership was enough to open a private preview, including a role scoped only to a different project.

Co-authored-by: Cursor <[email protected]>
@luxor-code-review

luxor-code-review Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


The change replaces the preview-JWT team-membership test with the same fresh-Authorization + Input(PermissionType::Read, $project->getPermissionsByType(PermissionType::Read)) pattern already used by HTTP admin mode and realtime, so preview access now requires an actual project-read role rather than any confirmed membership on the project's team. Verified parity: role strings emitted by User::getRoles() match Platform/Permission.php project-read grants, unconfirmed memberships are excluded, and no wildcard path widens access; the 301 redirect to /auth/preview for unauthenticated/expired/removed users is unchanged.

Files Change
app/controllers/general.php Swap membership-existence check for a project-read permission check on the preview proxy path.
tests/e2e/Services/Sites/SitesCustomServerTest.php Add e2e coverage: a confirmed member scoped only to another project gets 301, then 200 after being granted this project's developer role.

Reviewed commit: 40832fe

@ghost

ghost commented Oct 25, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Private site preview authorization now checks the signed-in user’s read access to the target project, rather than accepting any confirmed membership in its organization. The preview-domain E2E test exercises denial for a member scoped to a different project and access after granting the target project’s developer role.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
app/controllers/general.php Authorize private previews only when the user's roles satisfy the project's read permissions.
tests/e2e/Services/Sites/SitesCustomServerTest.php Add E2E coverage for a confirmed membership scoped to another project and subsequent target-project access.

Reviewed 40832fe · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost 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

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

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/preview-project-read-permission (after).

Metric Before After Change
🚀 Requests/sec 216.87 221.91 ⚪ +2.3%
⏱️ Latency P50 77.57 ms 78.24 ms ⚪ +0.9%
⏱️ Latency P95 187.65 ms 180.21 ms ⚪ -4%
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 78.24 180.21 13,737 221.91 -7.44
Account 147.7 273.25 723 11.96 +14.24
TablesDB 77.08 144.36 7,471 122.12 +10.26
Storage 69.55 163.74 3,615 61.25 -12.91
Functions 109.16 206.14 1,928 33.41 -45.24

Top API waits (after)

API request Max wait (ms)
tablesdb.rows.increment 432.63
functions.create 416.63
account.name.update 415.76
account.prefs.update 374.51
tablesdb.rows.create 334.04

@abnegate
abnegate merged commit 2d08020 into main Oct 27, 2026
69 checks passed
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.

2 participants