fix: Validate sort_by parameter against allowlist in repositories#1128
Merged
daveearley merged 1 commit intodevelopfrom Mar 28, 2026
Merged
fix: Validate sort_by parameter against allowlist in repositories#1128daveearley merged 1 commit intodevelopfrom
daveearley merged 1 commit intodevelopfrom
Conversation
Apply getAllowedSorts() whitelist validation to all repository orderBy() calls, preventing SQL injection via the sort_by query parameter. Reported by @tikket1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
sort_byquery parameter directly to Eloquent'sorderBy()without validation, enabling SQL injection (PostgreSQL supports stacked queries, so this is particularly spicy)validateSortColumn()andvalidateSortDirection()helpers toBaseRepositorythat check against each domain object's existinggetAllowedSorts()whitelistIsSortabletoProductCategoryDomainObject(the one domain object that was missing it)The allowlist pattern was already used correctly in the admin endpoints (
getAllEventsForAdmin,getAllOrdersForAdmin) — this just applies the same approach everywhere else.Test plan
sort_byvalues fall back to defaults instead of erroringReported by @tikket1