in reply to SQL Injection myths under DBI?
I second tilly's opinion that what you are saying is plainly wrong, and here are a few points that you shoudl consider:
-
my $sth = $dbh->prepare ("select username, password from users where sid='?';" )
That is simply wrong.
Placeholders must not be quoted. A placeholder means "leave it to the database driver to deal with any quoting business."
-
this solution will cost you a hell of a work if you like the simplicity of the do() method and have used it all over your code
What's wrong with using the do() method with placeholders?$dbh->do("INSERT INTO table (id, name) values (?, ?)", undef, $id, $na +me); -
But what I could conclude, after a lot of thinking and, most of all, after testing all the supposedly harmfull examples in my little script, is that the only problem is the single quote
That depends on the database you are using, and you should not be concerned about this matter, if you care to use the $dbh->quote method, which you should go and read in the docs.
The bottom line: I am afraid you don't know what you are talking about. Please read the docs more carefully.
In Section
Meditations