-
- Notifications
You must be signed in to change notification settings - Fork 110
Closed
Description
This issue is present in Nette 2.3.11.
How to reproduce the issue:
- Use Nette database
- Use MySQL
- Use table with non-numeric primary key column named 'id' - in my case varchar(50)
- Add some more columns, in my case datetime - validFrom, validTo
Use the following syntax:
$value = $context->table('table')->select('id')->fetch(); //result e.g. [id => 'not escaped'] $context->table('table')->where([ 'id' => $value, 'validFrom <= ?' => '2016-10-13', 'validTo >= ?' => '2016-10-13' ])->fetch(); The query gets executed without escaping the value in $value e.g. as:
SELECT ... FROM table WHERE (id not escaped) AND (validFrom <= '2016-10-13') AND (validTo >= '2016-10-13').
Problem obviously being the first parantheses.
Although such usage is not correct (you should not use the whole result, but its field instead), this is pretty hard to debug and has potentially fatal consequences (SQL injection).
Metadata
Metadata
Assignees
Labels
No labels