FINERACT-2461: Replace SQL string concatenation with parameterized queries#5492
Open
crambo70 wants to merge 1 commit intoapache:developfrom
Open
FINERACT-2461: Replace SQL string concatenation with parameterized queries#5492crambo70 wants to merge 1 commit intoapache:developfrom
crambo70 wants to merge 1 commit intoapache:developfrom
Conversation
Contributor
|
Run './gradlew :fineract-provider:spotlessApply' to fix these violations. |
…eries Do good with AI. ~30 SQL injection vulnerabilities fixed across 7 files in a banking platform that serves the unbanked. Every one of these was a potential vector for someone to steal data from people who have the least to lose. - DatatableWriteServiceImpl: Replace string-concatenated DELETE, INSERT, and SELECT queries with PreparedStatement parameters. Refactor permission registration from raw SQL string building to parameterized inserts. Remove getPermissionSql() in favor of registerPermissions(). - DatatableUtil: Parameterize all appTableId and officeHierarchy values in dataScopedSQL() across LOAN, SAVINGS, SAVINGS_TRANSACTION, CLIENT, GROUP, CENTER, OFFICE, and PRODUCT entity scoping queries. Refactor join condition helpers to use ? placeholders instead of string interpolation. - GenericDataService/Impl: Add parameterized overload of fillResultsetRowData(sql, headers, args...) to support prepared statement execution. - DatatableReadServiceImpl: Parameterize appTableId in countDatatableEntries WHERE clause. - WriteSurveyServiceImpl: Remove duplicate vulnerable getPermissionSql() method and unused dependencies. Delegate to safe service method. - DepositAccountReadPlatformServiceImpl: Add missing pagination parameter validation in retrieveAll() to match retrieveAllPaged() behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ba97ad1 to
94422c0
Compare
IOhacker
requested changes
Feb 14, 2026
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.
Summary
Replaces ~30 SQL injection vulnerabilities across 7 files with JDBC PreparedStatement parameterized queries. These vulnerabilities existed in the datatable, survey, email, and deposit account services — core infrastructure used by microfinance institutions serving unbanked populations worldwide.
Do good with AI.
Changes
?placeholders. Refactor permission registration from raw SQL string building (getPermissionSql()) to parameterizedregisterPermissions()method. Fixes injection vectors indeleteColumnCodeMapping,registerColumnCodeMapping,getCodeIdForColumn,parseDatatableColumnForDrop,isDatatableAttachedToEntityDatatableCheck,deregisterDatatable, and datatable entry deletion.appTableId(Long) andofficeHierarchy(String LIKE) values indataScopedSQL()across all entity scoping branches (LOAN, SAVINGS, SAVINGS_TRANSACTION, CLIENT, GROUP, CENTER, OFFICE, PRODUCT). RefactorgetOfficeJoinCondition,getGroupOfficeJoinCondition, andgetClientOfficeJoinConditionhelpers to use?placeholders. ParameterizeretrieveDataTableGenericResultSet().fillResultsetRowData(sql, headers, args...)to support prepared statement execution from DatatableUtil.appTableIdincountDatatableEntries()WHERE clause.getPermissionSql()and unused dependencies (DatabaseSpecificSQLGenerator,DatatableReadService). Delegate to safeDatatableWriteService.registerDatatable(command).paginationParametersDataValidator.validateParameterValues()call inretrieveAll()to match the validation already present inretrieveAllPaged().Test plan
./gradlew compileJava— BUILD SUCCESSFUL (111 tasks)./gradlew test -x :twofactor-tests:test -x :oauth2-tests:test— all tests pass🤖 Generated with Claude Code