Skip to content

chore(deps): update appwrite/appwrite to ^32.2.0 (appwrite:appwrite:alert#4729) - #28

Merged
ArnabChatterjee20k merged 1 commit into
mainfrom
fix/abuse-code-guesses-every-caller-cascade
Nov 16, 2026
Merged

ArnabChatterjee20k merged 1 commit into
mainfrom
fix/abuse-code-guesses-every-caller-cascade

Conversation

@claudear

Copy link
Copy Markdown
Contributor

What does this PR do?

Cascades appwrite/appwrite#15470 (code scanning alert #4729) into this playground.

Upstream touched only the server's route labels — Limit::attempts(...) / Limit::failures(...) gained everyone: true on the recovery and session confirmations — so the generated PHP SDK is byte-identical; no method signature here changed. What did change is the contract a server-side caller codes against:

Before After
an API key was waived from the per-user limits on the routes that confirm a short secret those limits count every caller, a key included

Concretely, for updateRecovery(), updateRecoveryOTP(), createSession(), updatePhoneSession(), updateMagicURLSession() and updateMFAChallenge(): a wrong secret is 401, and once a user's handful of attempts is spent the route answers 429 — to the correct secret too. An SSR backend that retries a mistyped code with its key now locks that user out for the rest of the window, so the playground has to show the handling rather than the happy path alone.

Dependency

appwrite/appwrite ^12.0.0 → ^32.2.0. That is a multi-major move and it carries the rest of this diff with it:

  • php >=8.0 → >=8.5, and ext-json, both required by the SDK itself.
  • Databases → TablesDB (collections and documents became tables and rows in Appwrite 1.8; the Databases service still exists but every method on it is deprecated).
  • Responses are typed readonly models now, not arrays — $response['$id'] → $response->id.
  • Runtime::PHP80() → Runtime::PHP84().
  • resources/: the function template's own SDK to ^28.0 — the PHP 8.4 function runtime cannot take 32.x, which needs 8.5 — and its archive rebuilt without the macOS ._* metadata files it was carrying.
  • Dockerfile: php:8.5-cli-alpine, and it no longer COPYs the gitignored composer.lock (that COPY fails on a clean checkout).

Playground

createSessionFromToken() is new: users->createToken() with the key, then account->createSession(), which is the route upstream stopped exempting keys from. It handles 401 and 429 instead of retrying, and its docblock says why the retry is the dangerous part.

Test Plan

tests/ is new — a stub Appwrite served by PHP's built-in web server, so there is no Appwrite instance or network access needed. composer test runs both files, and CI (.github/workflows/tests.yml) lints every file and runs it on PHP 8.5.

  • tests/smoke.php — runs the whole playground against the stub: 21 calls over 26 requests, every one succeeding and hitting the endpoint it meant to. It also fails on any request to /v1/databases (the deprecated service), on any request missing the project, and on a session exchange that did not carry the API key — so the test below cannot pass by the playground quietly dropping the key.
  • tests/code-guesses.php — this fix. Against a stub that counts wrong guesses per project, route and user without looking at the key: the correct secret still exchanges for a session; ten wrong guesses answer 401 typed user_invalid_token; the eleventh answers 429 typed general_rate_limit_exceeded; another user still has its own count; the recovery OTP confirmation behaves the same way and, once spent, refuses the correct secret too. The session exchange's limits count failures rather than requests, so the successful exchange ahead of the ten guesses does not eat into the share — the test is ordered to pin that down.

Both verified to fail against the pre-fix behaviour: exempting a key-holding caller in the stub turns the five 429 assertions into 401/201.

Local: composer test green on PHP 8.5.12, php -l clean on every file, docker build of the playground image green and its autoloader resolving Appwrite\Services\TablesDB.

Note on overlap

The ^32.2.0 bump and the TablesDB migration are shared with the other open cascades (#21, #22, #23, #24, #25, #26, #27) — whichever lands first, the rest reduce to their own playground call and test file. Only createSessionFromToken(), tests/code-guesses.php and the confirmation-route half of the README section are specific to this alert.

🤖 Generated with Claude Code

…lert#4729)

appwrite/appwrite#15470 made the abuse limits on the routes that confirm a
short secret count for every caller, an API key holder included. It touched
only the server's route labels, so the generated PHP SDK is unchanged — but
the contract a server-side caller codes against is not: a key that used to be
waived from those limits now gets 401 for a wrong secret and 429 once a user's
attempts are spent, and a spent limit refuses the correct secret too.

The manifest moves to the SDK's current major, which needs PHP 8.5 and renames
collections and documents to tables and rows, so:

- composer.json: appwrite/appwrite ^12.0.0 -> ^32.2.0, php >=8.5, ext-json,
  and a `test` script;
- playground.php: Databases -> TablesDB, array responses -> typed models,
  Runtime::PHP80 -> PHP84, and a `createSessionFromToken()` call that shows
  how to handle 401 and 429 on the session exchange rather than retry into it;
- resources: the function template's own SDK to ^28.0 (the PHP 8.4 runtime
  cannot take 32.x), and its archive rebuilt without the macOS metadata files;
- Dockerfile: php 8.5, and no COPY of the gitignored composer.lock;
- tests/: a stub Appwrite over PHP's built-in server, a smoke test that runs
  the whole playground against it, and tests/code-guesses.php for this fix —
  ten wrong guesses answer 401 and the eleventh 429 for a key-holding caller,
  per user, on both the session exchange and the recovery OTP confirmation;
- .github/workflows/tests.yml: lint and `composer test` on PHP 8.5.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@appwrite

appwrite Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The SDK migration and added route handling are consistent with the surrounding callers, and the new tests cover the changed behavior without an actionable defect found.

This PR upgrades the PHP SDK and migrates the playground's database examples to TablesDB, updating the PHP and Docker requirements along the way. It adds recovery and token-session examples, documents abuse-limit responses, and introduces stub-backed tests for the playground and confirmation routes.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 13
File Change
.github/workflows/tests.yml Adds PHP 8.5 CI lint and test steps.
Dockerfile Updates the PHP image and includes function resources in the image.
README.md Documents the TablesDB migration, abuse limits, and test suite.
composer.json Raises PHP and SDK requirements and adds the test script.
docker-compose.yml Removes the obsolete Compose version declaration.
playground.php Migrates database calls to TablesDB and adds recovery and token-session examples.
resources/code.tar.gz Rebuilds the function deployment archive.
resources/composer.json Updates the function template's PHP and SDK requirements.
tests/code-guesses.php Tests keyed session and recovery confirmation responses against the stub.
tests/prelude.php Loads the playground with test endpoint configuration.
tests/smoke.php Exercises the playground and verifies its calls and requests.
tests/stub-server.php Adds stub API routes and stateful confirmation-limit behavior.
tests/stub.php Provides shared lifecycle and request-log helpers for the stub server.

Reviewed 6722d12 · 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

@ArnabChatterjee20k
ArnabChatterjee20k merged commit 3a7b803 into main Nov 16, 2026
2 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