Repository navigation
Security: ORDER/GROUP BY identifiers, parametrized paging plans, empty IN, request-end rollback - #5
Merged
Conversation
…plans, empty IN, open transaction rollback - orderBy()/groupBy() refuse strings that are not a column, table.column, @.column or JSON path; expressions must be a Fragment/Expression (audit M10). - limit/offset above 1/0 are statement parameters of the cached shape plan, so every page shares one plan; negative limit/offset are refused (B8). - An empty IN list compiles to 1=0 and an empty NOT IN to 1=1 instead of a syntax error (B8). - fetchPage reads the count column by position, not as the last column, so SQL Server paging without ORDER BY (ROW_NUMBER column) returns the right total (B8). - DatabaseManager::rollbackOpenTransactions() for long-lived workers to call at the end of each request, next to Heap::clean() (B9).
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.
Remaining Arcano findings from the 2026-11-20 security audit (M10, B8, B9).
Changes
orderBy()andgroupBy()accept a plain string only when it is a column,table.column,@.column, a role alias (user:credentials.id) or a JSON path (data->key[0]). Anything else (functions, spaces, quotes, comments) throwsBuilderException; raw SQL goes throughFragment/Expression.orderBy($_GET['sort'])can no longer inject SQL. Column names passed towhere()/columns()stay trusted input, documented in the README.SelectQueryand ORMSelect).INlist compiles to1=0, an emptyNOT INto1=1(was a syntax error / 500).fetchPage()reads the count column by position, so SQL Server paging without ORDER BY (which appends aROW_NUMBERcolumn) returns the right total.DatabaseManager::rollbackOpenTransactions()rolls back every transaction level left open on the drivers in use; long-lived workers call it with$orm->getHeap()->clean()at the end of each request (the Nimbus integration calls it).Behaviour change
orderBy('RAND()')(string) now throws; useorderBy(new Fragment('RAND()'), null), as the docblocks already showed.Tests
tests/Database/Unit/Query/UntrustedInputTest.php(injection strings for orderBy/array keys/groupBy, accepted forms, negative limit/offset)QueryShapeTest(all drivers): pages share plans, page total without ORDER BY, negative limit/offset, empty IN/NOT IN, injected sort keySelectQueryTest::testEmptyInListCompilesToFalseAndEmptyNotInToTrue,TransactionsTest::testOpenTransactionsAreRolledBackAtTheEndOfARequestLocally: unit 911/911; sqlite 2591 with 1 error that also happens on main (
SingleFileStrategyTest::testInit, order-dependent, passes alone).