Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Preventing MySQL Injection

by Anonymous Monk
on Jan 03, 2008 at 14:54 UTC ( [id://660205]=note: print w/replies, xml ) Need Help??


in reply to Re: Preventing MySQL Injection
in thread Preventing MySQL Injection

Guess i'll start using place holders instead.

should this technique be used exclusively, or only where user/untrusted input is provided?

Replies are listed 'Best First'.
Re^3: Preventing MySQL Injection
by moritz (Cardinal) on Jan 03, 2008 at 15:08 UTC
    You should use it where possible, since it greatly reduces the (error prone) task to keep track of which variables contain "trusted" data, and which doesn't.
Re^3: Preventing MySQL Injection
by jhourcle (Prior) on Jan 03, 2008 at 16:42 UTC

    You should use placeholders, but there are times when placeholders aren't a suitable replacement for escaping the string ... however, those tend to be risky security wise.

    Placeholders only work with values for fields ... if you're trying to do something like allowing the user to select an arbitrary table or field, you'll have to escape the value. I don't know if it's true for all versions, but from what I recall, even setting a LIMIT couldn't be done with a placeholder in older version. In these sorts of cases, I typically abort entirely if values aren't composed of only known good characters ([a-zA-Z0-9_] for fields/tables, [0-9] for limits, etc) ... but it's best to avoid the issues as best you can.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://660205]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-19 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found