fix(org): bound limit/offset on ORGANIZATION_MEMBER_LIST - #6445
Merged
Conversation
limit and offset were plain z.number() with no bounds, unlike every other paginated tool in the repo (e.g. CollectionListInputSchema caps limit at 1-1000 and offset at >=0). A caller could pass an unbounded, negative, or fractional value straight through to Better Auth's listMembers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source: bug found while hardening
apps/api/src/tools/organization/member-list.ts(this tick's focus area).Why:
ORGANIZATION_MEMBER_LIST'slimit/offsetinput fields were a plainz.number().optional()with no bounds — every other paginated tool in the repo constrains these (e.g.CollectionListInputSchemainpackages/bindings/src/well-known/collections.tscapslimitat1-1000and requiresoffset >= 0, both as integers). A caller could pass an unbounded (limit: 1_000_000), negative, or fractional value straight through to Better Auth'slistMembers, with no validation catching it at the tool boundary.Failure scenario:
ORGANIZATION_MEMBER_LIST({ limit: 1_000_000 })or{ limit: -1 }or{ limit: 1.5 }all passed Zod validation before this fix and were forwarded verbatim toctx.boundAuth.organization.listMembers.Fix:
limit: z.number().int().min(1).max(1000).optional(),offset: z.number().int().min(0).optional()— matching the existing repo-wide pagination convention.Regression test: added a case in
member-list.test.tsasserting the schema rejects an over-cap, negative, and fractionallimit/offset, and still accepts a valid bounded value.To verify:
cd apps/api && bun test src/tools/organization/member-list.test.tsChecked locally:
bun run fmt,bunx tsc --noEmit(apps/api), the targeted test file above, andbunx oxlinton both changed files — all clean. Full CI validates the rest.Summary by cubic
Bounds pagination inputs for
ORGANIZATION_MEMBER_LISTto integers: limit 1–1000 and offset >= 0, matching repo pagination conventions. Previously any number was accepted; now invalid values fail validation, preventing unbounded, negative, or fractional inputs from reaching the auth backend.Written for commit 98d8e7a. Summary will update on new commits.