You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pentesting-web/sql-injection/README.md
+18-4Lines changed: 18 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -652,6 +652,23 @@ Mitigations:
652
652
- Never concatenate identifiers from user input. Map allowed column names to a fixed allow-list and quote identifiers properly.
653
653
- If dynamic table access is required, restrict to a finite set and resolve server-side from a safe mapping.
654
654
655
+
656
+
### SQLi via AST/filter-to-SQL converters (JSON_VALUE predicates)
657
+
658
+
Some frameworks **convert structured filter ASTs into raw SQL boolean fragments** (e.g., metadata filters or JSON predicates) and then**string-concatenate** those fragments into larger queries. If the converter **wraps string values as `'%s'` without escaping**, a single quote in user input terminates the literal and the rest is parsed as SQL.
JSON_VALUE(metadata, '$.department') = '' OR '1'='1'
670
+
```
671
+
655
672
### ORDER BY / identifier-based SQLi (PDO limitation)
656
673
657
674
Prepared statements **cannot bind identifiers** (column or table names). A common unsafe pattern is to take a user-controlled `sort` parameter and build `ORDER BY` using string concatenation, sometimes wrapping the input in backticks to “sanitize” it. This still enables SQLi because the identifier context is attacker-controlled.
@@ -670,10 +687,6 @@ Signals in traffic:
670
687
- Sort parameter in**POST** (often `sort=column`), not a fixed allow-list.
671
688
- Changing `sort` breaks the query or alters output ordering.
672
689
673
-
Mitigation:
674
-
675
-
- Map user input to a **fixed allow-list** of column names and only interpolate mapped identifiers.
676
-
- Never rely on backticks as “sanitization” for identifiers.
0 commit comments