How do I make a menu item make a database query?

17 years 9 months ago #17048 by mikko
If you take some paraemter directly from the url without checking it, it is possible that someone writes an url that has a parameter that terminates first the string, then the sql sentence, includes another sql query and comments out rest of the real sql. In this case the malicious user can execute any SQL that they wish. It does not matter what the original sql statement was.

See e.g. en.wikipedia.org/wiki/SQL_injection

I just wanted to warn people not to use your hack because it is not safe, not to argue wether this is a problem or not.

mikko

Please Log in to join the conversation.

17 years 9 months ago #17320 by eisnerj
So the WikiPedia site offers the following to secure from sql injection:

[code:1]$query_result = mysql_query
(
"select * from users where name = '"
.
mysql_real_escape_string($user_name)
.
"'"
);[/code:1]

Is that all I need to do to secure the call as far as you know?

Please Log in to join the conversation.

17 years 8 months ago #17331 by mikko

Please Log in to join the conversation.

17 years 8 months ago #18697 by jeffason
ok this needs a real explanation....

this code is SAFE because it uses

$params = urldecode(mosGetParam($_GET, "params"));

if he were to use $_GET AND register_globals was on he would have a problem

sql injection is not possible without register globals...AFAIK...especially when using mosgetparam

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.338 seconds

Facebook Twitter LinkedIn