Repository navigation
fix: rate limit guest-writable routes and drop deployment write grants - #14405
Conversation
Three state-changing routes that guests can reach had no abuse labels, so the shared api hook applied no limit to them: - File update lost its limit (60 per 60s) when the storage controller moved into the Storage module. It now has the same key, limit and period as file delete. - Membership status update checks a membership secret. It now has the same limit and key as the other secret-checking routes, such as the recovery confirmation: 10 per user and URL. - Transaction operation create stages document writes, so it now has the document create limit. All four APIs (Databases, DocumentsDB, TablesDB, VectorsDB) get the same limit, since they serve the same operation. The new Abuse lane tests cover each route. testAbuseUpdateFile is now in the abuseEnabled group; it got 200 for every request before this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every deployment was stored with update and delete permissions for Role::any(). Its writers are the console and project keys, which run with authorization disabled. The build, delete and maintenance workers and the CLI also run with it disabled, and the VCS webhook and execution paths read inside an authorization skip. So the grants opened writes to anyone without letting any real caller in. Deployments now get read access only, from one definition, Deployments::permissions(). The template deployment routes and Compute\Base now use it instead of their own copies of the old list. New e2e tests: a template deployment can still be read, listed and deleted with a project key and from the console, and a project user cannot cancel or delete one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No blocking issues — 2 nitpicks below. 🧹 Nitpicks (2) — 🟢 2 low
This change centralizes deployment document permissions in
Reviewed commit: 0807a29 |
🟢 Tier S · Ready to mergeThis PR adds guest abuse limits to file updates, membership-status updates, and transaction-operation routes, then centralizes deployment permissions as public read-only access across compute and template-deployment paths. It refreshes the Semgrep baseline and adds e2e coverage for the limits and deployment access behavior. The console workflows also clarify the pinned GitHub App token action version. Latest changes: The membership-status abuse key now uses IP plus URL instead of the caller-supplied user ID, and its abuse test varies user IDs to verify that doing so does not reset the limit.
📂 Walkthrough · 17
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
zizmor fails Checks / Workflows because the pinned commit is tagged v3.2.0, while the comment says v3, and v3 now points to a newer commit. The comment now names v3.2.0, the release the hash is. Co-Authored-By: Claude Opus 5.5 <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…quest's user ID
The limit keyed on {param-userId}, which comes from the request. The
secret is checked before the user ID, so a caller could send a new user
ID with each guess and get a fresh limit every time. The key is now the
caller's IP and the URL, which names the team and membership, so
guesses at one membership share one limit. The abuse test now changes
the user ID on every request and still expects the eleventh to be
throttled.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re the tenki nitpicks: (1) Rate-limit tests only run in the Abuse lane by design, since every other lane runs with abuse checks disabled. That lane is selected when Account is affected or when a change isn't owned by a single service, as on this PR, where it ran and passed. (2) Each test's limit key also includes a URL with IDs unique to that test, so tests that draw the same forwarded IP never share a limit. 🤖 Addressed by Claude Code |
The findings that requested changes are resolved. See the summary comment for what is still open.
What does this PR do?
Fixes the five Semgrep warnings main reports on routes that guests can reach (flagged on #11649 because that PR touches these files).
Rate limits (
guest-write-without-abuse-limit). These routes had no abuse labels, so no limit applied:PUT /v1/storage/buckets/:bucketId/files/:fileId: its 60 requests per 60s limit was lost when storage moved into the Storage module. It now uses the same labels as file delete.PATCH /v1/teams/:teamId/memberships/:membershipId/status: this route checks a membership secret. It now allows 10 requests per caller IP and URL. The URL names the team and membership, so changing theuserIdin the request does not reset the limit.POST /v1/{databases,documentsdb,tablesdb,vectorsdb}/transactions/:transactionId/operations: these now have the document create limit. All four APIs get it, since they serve the same operation.Deployment permissions (
permissive-write-permission). Deployments were stored withupdate/deletegranted toRole::any(). Every writer runs with authorization disabled: the console, project keys, workers and the CLI. The VCS webhook and executions read inside an authorization skip. So the grants opened writes without letting any real caller in. Deployments now getread(any)only, fromDeployments::permissions(). The template routes andCompute\Basenow use that helper instead of their own copies of the old list.The Semgrep baseline is regenerated to drop the fixed entries.
Test Plan
abuseEnabledgroup): file update is now in the group (it got 200 for every request before this change), plus new tests for membership status (10 with a new user ID each time, then 429) and transaction operations for Databases and TablesDB (120, then 429).SitesCustomServerTest) and from the console (SitesConsoleClientTest). A project user gets 401 on cancel and delete, and the deployment remains (SitesCustomClientTest).Related PRs and Issues
🤖 Generated with Claude Code