security - replaceAll quotes with backslashed quotes -- Is that enough? -


i'm using replaceall replace single quotes "\\\\'" per colleague's suggestion, i'm pretty sure that's not enough prevent sql injections.

i did googling , found this: http://wiki.postgresql.org/wiki/8.1.4_et._al._security_release_technical_info

this explains postgresql, replacing not work sql managers? (like, mysql, example?)

also, think understand how explanation linked works single backslash, extend situation i'm using 4 backslashes?

please note i'm not familiar databases , how parse input, chance learn more! insight appreciated.

edit: i've gotten helpful, useful answers. next question is, kind of input break implementation? is, if give me input , prepend single quotes 4 backslashes, kind of input give me inject sql code? while convinced approach naive , wrong, maybe examples better teach me how easy inject sql against "prevention".

no, because backslashes? instance if turn ' \' input \' become \\' unescaped single quote , "character literal" backslash. mysql there mysql_real_escape_string() should exist every platform because in mysql library bindings.

but there problem. , if have no quote marks around data segment. in php looks like: $query="select * user id=".$_get[id];

the poc exploit simple: http://localhost/vuln.php?id=sleep(10)

even if mysql_real_escape_string($_get[id]) still vulnerable sqli because attacker doesn't have break out of quote marks in order execute sql. best solution parameterized queries.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -