2 ms·
After some thought, the number one reason you'll see this is the following sequence: Initially, you didn't know anything about prepared statements or encoding p
by jerf 17y ago
After some thought, the number one reason you'll see this is the following sequence: Initially, you didn't know anything about prepared statements or encoding properly. (The vast majority of programmers do not actually understand encoding; even quite a lot of people parroting "Use prepared statements!" are parroting the right thing without really, deeply understanding it.) Then somebody accidentally enters an apostrophe or something and your code breaks. You are a novice developer, so your first inclination is to strip out the apostrophe. Repeat for a few more characters. Arrive at a point where you can no longer think of a way to exploit your code, assume that therefore nobody can, call it a day.
I had some other reasons here, but that is almost certainly the dominant reason; it explains all the instances of it I've encountered.
(Understanding encoding: http://www.jerf.org/iri/post/2548 http://www.jerf.org/iri/post/2548 )
Edit: BTW, when I say a lot of people parrot "use prepared statements" without understanding, please note I am not accusing any other commenter in this thread. I am actually thinking of people I've encountered in real life who A: told me that but B: I have other reason to believe don't really understand why. In particular, I work a lot professionally in Perl, and the Perl culture has somehow managed to converge from top to bottom on prepared statements, and I will confidently be told to use prepared statements by people who will turn around and write the most trivial of XSS attacks by the bushel. (If you don't know the connection between those two things, see my link above.)