At a glance
- Controls
- CWE-89 · A03:2021 Injection
What it is
Generated code often builds a query by pasting a value from the request into the SQL text. The database cannot tell the value apart from the query. A value with quotes or SQL words becomes part of the command.
An attacker sends a crafted value that changes what the query does. They can read other users' records, bypass a login check or alter data. AI-assisted attackers can try many payloads per field and read the error messages to adjust quickly.
Where it hides
What a reviewer can look for in the code and in the behaviour, before anyone proves it.
- Search, filter and sort parameters on list endpoints
- Report and export features that build dynamic queries
- Raw query calls inside an ORM, used for complex joins
- Admin and back-office tools that accept free-text conditions
How MATT tests it
The proof runs against the deployed product, on every release, whoever wrote the code.
- 01Read the code for queries built with string joining, formatting or template literals.
- 02Sign in with the test login and send a value with a single quote to the matching field, watching for errors or changed results.
- 03Send a harmless payload that changes only the logic of a read query, such as an always-true condition, against test data.
Queries must use parameters for every value from a user.
Executable checkas test user: GET /v1/items?search=' OR '1'='1 expect: same results as a literal search for that text expect: no database error in the body scan code: expect no query text built from request values
Every rule MATT holds →What the fix looks like
- 01
Use parameterised queries or prepared statements for every value.
- 02
Map sort and column names to a fixed allow‑list in code.
- 03
Run the application with a database role that has only the rights it needs.
- 04
Add a static check in CI that fails on query strings built from variables.
A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →