Skip to content

fix(auth): stop granting rules.read to project end users - #15013

Merged
ChiragAgg5k merged 2 commits into
mainfrom
fix/console-resources-scope
Oct 27, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
fix/console-resources-scope

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

The users role (every project end-user session) carried rules.read, so any signed-in user could list and read the project's proxy rules. Those routes are documented admin/key only.

GET /v1/proxy/rules
X-Appwrite-Project: <project>
Cookie: a_session_<project>=<end-user session>

before: 200 {"total": N, "rules": [...]}
after:  401 general_unauthorized_scope

rules.read was added to the role only so console users could call GET /v1/console/resources, which is already console-only (projects group) and the role already holds projects.read.

Changes

  • Console/Http/Resources/Get.php: scope rules.read → projects.read
  • app/config/roles.php: drop rules.read from $member

Admin roles (owner/developer/admin) and API keys keep rules.read; the console reads rules through admin mode, so it is unaffected. No scope catalog change.

Test Plan

SitesCustomServerTest::testProjectUserCannotReadRules: creates a rule with the server key, signs up an end user, asserts GET /v1/proxy/rules and GET /v1/proxy/rules/{id} return 401 with that session and the key still reads the rule. testConsoleAvailabilityEndpoint keeps covering GET /v1/console/resources with a console session (409/204).

Related: appwrite-labs/cloud#6666

The users role is held by every project's end-user sessions, so rules.read on it let any signed-in user list and read the project's proxy rules, which are documented as admin/key only. The scope was only added so a console member could call GET /v1/console/resources, a console-only route; scope that route to projects.read, which the role already holds, and drop rules.read from the role.
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Move cleanupSite into a finally block (SitesCustomServerTest.php:447) — The new testProjectUserCannotReadRules calls $this->cleanupSite($siteId) only as the last statement of the test (tests/e2e/Services/Sites/SitesCustomServerTest.php:447).

The change tightens access to proxy rules: member roles lose rules.read (which stays defined for admins/API keys), and the console Resources Get endpoint's label moves to the projects.read scope that members already hold. A new e2e test verifies a project user session cannot read /proxy/rules/site.

Files Change
app/config/roles.php Removes rules.read from member roles; scope remains defined and granted to admins/API keys.
src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php Re-scopes the console resources endpoint to projects.read.
tests/e2e/Services/Sites/SitesCustomServerTest.php Adds testProjectUserCannotReadRules covering the 403 path on /proxy/rules/site.

Reviewed commit: 644c309

@ghost

ghost commented Oct 27, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

This change removes rules.read from the end-user role and uses projects.read for the console resource-availability endpoint. It adds an E2E regression test confirming project users cannot list or retrieve proxy rules while a project API key can still retrieve one.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
app/config/roles.php Removes the proxy-rule read scope from the member/end-user role.
src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php Changes the console resource endpoint's required scope to projects.read.
tests/e2e/Services/Sites/SitesCustomServerTest.php Adds E2E coverage for end-user denial and API-key access to proxy rules.

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

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 27, 2026

@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/console-resources-scope (after).

Metric Before After Change
🚀 Requests/sec 189.51 191.73 ⚪ +1.2%
⏱️ Latency P50 89.6 ms 90.96 ms ⚪ +1.5%
⏱️ Latency P95 219.32 ms 205.66 ms 🟢 -6.2%
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 90.96 205.66 12,198 191.73 -13.66
Account 171.54 298.59 642 10.65 -9.19
TablesDB 88.83 163.22 6,634 106.93 -21.49
Storage 82.06 193.89 3,210 53.08 +5.43
Functions 123.56 234.04 1,712 29.12 -10.03

Top API waits (after)

API request Max wait (ms)
account.name.update 483.45
functions.variables.update 468.58
account.prefs.update 392.2
storage.buckets.create 379.64
account.get 362.11

@ChiragAgg5k
ChiragAgg5k merged commit b22e403 into main Oct 27, 2026
69 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/console-resources-scope branch October 27, 2026 14:13
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