Keep data separate from query instructions
SQL injection happens when an application builds a database command from untrusted input without keeping data separate from the query structure.
Use prepared statements or safe query builder methods. Do not concatenate a search term, identifier or filter directly into SQL.
Validate fields and restrict database access
Validate inputs against the expected type, size and range. Use allowlists for fields that change query structure, such as a sort column. Escaping alone is easy to apply incorrectly.
Give the application database account only the permissions it needs. Avoid using a database owner account for routine web requests.
Test query paths safely
Review search, login, reports, filters and custom endpoints. Use a test environment and non-sensitive data for active security testing.
When a finding is confirmed, fix the shared query pattern and test nearby routes. A web application assessment can validate the fix in the agreed scope.
