Description
DefaultSQLExecutor.executeSQL/executeSQLStreaming compute Integer offset = (pageNo - 1) * pageSize using int arithmetic with no bounds validation. pageNo/pageSize are client-controlled Integer (only the AI/MCP tool path clamps via normalizePageSize; the main execution path does not). A large pageNo (e.g. > ~2.1M with default pageSize 1000) wraps the int to a small or negative value: setMaxRows(negative) throws SQLException (500); setMaxRows(smallPositive) silently caps the result set and generateDataList skips offset rows, returning first-page data for a huge page number with no error.
Location
chat2db-community-spi/.../DefaultSQLExecutor.java:836-838 (executeSQL), :913-915 (executeSQLStreaming); :247-249/:1001-1003/:1081-1085 (stmt.setMaxRows(offset + count)). MAX_PAGE_SIZE = 1000 is a default, not an input cap.
Impact
Large/buggy page numbers cause either a 500 or silently wrong (first-page) results with no indication.
Suggested fix
Clamp pageNo >= 1, pageSize to [1, MAX_PAGE_SIZE], and pageNo to <= Integer.MAX_VALUE / pageSize so (pageNo - 1) * pageSize (and offset + count) fit in int — preventing both the negative-setMaxRows throw and the silent wrong-page return.
Related existing
None.
Description
DefaultSQLExecutor.executeSQL/executeSQLStreamingcomputeInteger offset = (pageNo - 1) * pageSizeusingintarithmetic with no bounds validation.pageNo/pageSizeare client-controlledInteger(only the AI/MCP tool path clamps vianormalizePageSize; the main execution path does not). A largepageNo(e.g. > ~2.1M with default pageSize 1000) wraps theintto a small or negative value:setMaxRows(negative)throwsSQLException(500);setMaxRows(smallPositive)silently caps the result set andgenerateDataListskipsoffsetrows, returning first-page data for a huge page number with no error.Location
chat2db-community-spi/.../DefaultSQLExecutor.java:836-838(executeSQL),:913-915(executeSQLStreaming);:247-249/:1001-1003/:1081-1085(stmt.setMaxRows(offset + count)).MAX_PAGE_SIZE = 1000is a default, not an input cap.Impact
Large/buggy page numbers cause either a 500 or silently wrong (first-page) results with no indication.
Suggested fix
Clamp
pageNo >= 1,pageSizeto[1, MAX_PAGE_SIZE], andpageNoto<= Integer.MAX_VALUE / pageSizeso(pageNo - 1) * pageSize(andoffset + count) fit inint— preventing both the negative-setMaxRowsthrow and the silent wrong-page return.Related existing
None.