Re:Sqlmap: Automatic SQL injection and database takeover tool
by shabble on Thursday July 05, 2012 @07:12PM
(#4205493)
Other than probably historical reasons and interface definitions, is there any reason why this is the case? I can't immediately think of any sensible argument against allowing the binding of a value into a limit/order field. In fact, it should be type-checking/converting it as well, to prevent exactly mistakes like this.
Even if the DB interface doesn't directly support this, it seems like it's something all client wrappers should handle, preferably at the low level in addition to having to pull in a whole ORM + assorted bacon for the purpose.
Re:Sqlmap: Automatic SQL injection and database takeover tool
by tptacek on Thursday July 05, 2012 @08:53PM
(#4205854)
Easy: bound parameters are a performance feature, not a security feature.
Re:Sqlmap: Automatic SQL injection and database takeover tool
by aw3c2 on Friday July 06, 2012 @05:47AM
(#4207070)
Thanks!
That would not have been a "real" prepared statement in my mindset so I get why I was confused.
I don't feel super smart, but wouldn't I simply make sure that $column is a valid column (ok, that one might need extra attention) and $direction would be either ASC or DESC and that $offset and $count are integers?
So, you end up having to do something similar to this (for the love of god, don't actually do this):
Bound parameters won't save you, and the potential attack vector is there if you're not really careful. That example shows the most stupid thing you could ever do, so don't do it.