Repository navigation
test: authorization and input validation e2e coverage - #14064
Conversation
…atar Covers image, favicon and screenshots over REST and GraphQL: loopback, link-local metadata, RFC1918, IPv6 loopback and IPv4-mapped literals, internal hostnames, numeric hosts, userinfo and non-http schemes. Co-authored-by: Jake Barnby <[email protected]>
A sessions.write key gets 401 on user tokens, JWTs, password/email updates, MFA recovery codes and account-scoped routes, while a users.write key still receives token secrets and JWTs. Listing sessions does not return a secret that can be replayed as a session. Co-authored-by: Jake Barnby <[email protected]>
A foreign transaction ID cannot be used to stage create, update, upsert or delete through the record routes, users cannot stage bulk operations, and related-document permissions are enforced for staged update/upsert operations and record routes that carry a transactionId. Co-authored-by: Jake Barnby <[email protected]>
Foreign roles on any item of a one-to-many list, or on a grandchild nested under a related document, are rejected for client sessions on create, update and upsert. Unchanged permissions on an existing related document can still be sent back. Co-authored-by: Jake Barnby <[email protected]>
…lues Headers outside _APP_TRUSTED_HEADERS (x-real-ip, cf-connecting-ip, forwarded, ...) do not set the client IP, and invalid X-Forwarded-For values fall back to the connection address. Co-authored-by: Jake Barnby <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…lidation-e2e-4968
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
This PR is test-only: six files under
Reviewed commit: c6ac6aa |
🟢 Tier S · Ready to merge
Adds end-to-end authorization and input-validation coverage across Avatars, GraphQL, Users, Databases, Transactions, and Locale, including negative cases and positive controls. Shared database and transaction tests exercise supported backends, with relationship-specific cases skipped where relationships are unavailable. Latest changes: The newest commits remove literal IPv4 and IPv6 loopback targets that the e2e stack allowlists, and retarget the credentialed and gopher URL cases to private IPv4 addresses.
📂 Walkthrough · 6
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
The docker env sets _APP_ALLOWED_INTERNAL_ADDRESSES to 127.0.0.1 and ::1, so those literals are fetched (404) instead of rejected as invalid URLs. Keep hostnames, non-http schemes, and non-allowlisted IPs, and match the GraphQL coverage to the REST list.
|
Addressed the Tenki nitpick on GraphQL SSRF coverage in 97004f3: GraphQL now uses the same URL list as REST, except |
What does this PR do?
Adds e2e coverage for authorization and input-validation behaviour across several API surfaces, extending existing suites rather than adding a new framework. Tests only — no runtime changes.
Already covered on
main(unchanged here)sessions.writekey return an emptysecret:AccountCustomServerTest::testCreateTokenWithSessionsKey,MockPhonesSessionIntegrationTest::testMockPhoneSessionWithSessionsKeyTransactionPermissionsBase::testUserCannotReadAnotherUsersStagedDocuments$permissionson one-to-one create/update/upsert and oncreatestaging:DatabasesBase::testCreateRelatedPermissions,TransactionPermissionsBase::testCannotSetUnauthorizedRelatedPermissions,testCannotRecreateRelatedWithUnauthorizedPermissionsAccept,Accept-Languageonly), plus unsafe header values:AvatarsBase::testGetScreenshotAdded
AvatarsBase::testGetRemoteURLNotPublicimage,faviconandscreenshotsreturn 400general_argument_invalidfor loopback, link-local metadata, RFC1918,[::1],[::ffff:127.0.0.1], internal hostnames, numeric hosts, userinfo URLs,file://,gopher://GraphQL\AvatarsTest::testGetRemoteURLNotPublicUsersCustomServerTest::testCreateTokenWithSessionsKeysessions.writekey gets 401 onPOST /users/:id/tokens,/jwts, password/email updates, MFA recovery codes, and account-scoped routes. Positive control: ausers.writekey still receives the tokensecretand a JWTUsersCustomServerTest::testListSessionsWithoutSecretGET /users/:id/sessionswith asessions.readkey does not return the session secret, and replaying the listed value (raw or store-encoded) asx-appwrite-sessionreturns 401TransactionPermissionsBase::testUserCannotStageRecordsInAnotherUsersTransactiontransactionIdon record-route create/update/upsert/delete returns 404, the owner's transaction stays at 0 operations, and the document is unchanged. Positive control: staging into your own transaction still worksTransactionPermissionsBase::testUserCannotStageBulkOperationsbulkCreate,bulkUpdate,bulkUpsert,bulkDeletestagingTransactionPermissionsBase::testCannotStageUnauthorizedRelatedPermissionsOnUpdateupdate/upsertoperations, and for record-route create/update/upsert that carry atransactionId. Positive control: own roles stage fineDatabasesBase::testCreateRelatedListPermissionsLocaleCustomClientTest::testGetClientIp_APP_TRUSTED_HEADERS(x-real-ip,cf-connecting-ip,true-client-ip,forwarded, …) do not set the client IP; invalidX-Forwarded-Forvalues fall back to the connection address. Positive control: a valid forwarded address from the internal hop is honouredThe transaction and database tests use the shared traits, so they run for Legacy, TablesDB and DocumentsDB. The relationship cases skip on DocumentsDB, which has no relationships. Every test fits the existing CI jobs: Avatars, GraphQL, Users, Locale, Databases, TablesDB. No new
@groupis needed.Not in this PR
TrustedProxiesTest,EncryptionKeyTest,SecretTest,RequestTest). Not repeated here.testGetClientIponly uses behaviour that holds before and after that PR (loopback and RFC1918 hops stay trusted by default).main. Only first-hop URL validation is asserted here.Test Plan
Pint (
--config pint.json), the Rector dry-run (tests/tools/rector.php) and PHPStan (level 4) pass on the changed files.All new tests were run against a local
docker composestack built from this branch and pass:testGetRemoteURLNotPublicAvatarsTest::testGetRemoteURLNotPublicUsersCustomServerTest(2 new tests)testCreateRelatedListPermissionson Legacy and TablesDB, client / server / consoleLocaleCustomClientTest::testGetClientIpAs a sanity check,
validateRelatedPermissionswas temporarily short-circuited locally.testCreateRelatedListPermissionsthen failed with201instead of401. That change was reverted and is not part of this PR.Run them individually with:
Related PRs and Issues
Checklist