Jump to content

Recommended Posts

Hello,

 

I am writing a script that I am trying to protect against mysql injection.

I have installed the firefox add-on SQL Inject Me and it returns some fails.

Server Status Code: 302 Moved Temporarily

Tested value: 1' OR '1'='1

 

and many more similar items.

 

My question is: is this always a problem? I would think a 302 return code only means the script is returning a valid page. But a valid page does not necessarily mean a vulnerable page, right?

The tested values all concern checkboxes with following html:

<input type=\"checkbox\" id=\"checkboxvalue\" name=\"checkboxvalue\" value=\"1\" />

The $_POST of the checkboxes are interpreted as:

$myValue = (int)isset($_POST['checkboxvalue'])?1:0;

I would assume this completely limits the possibility for sql injection or am I missing something?

The (int) is probably not needed since I don't even store the post value in the variable.

 

My strings do not generate a warning. I use the following function to validate them, is this sufficient protection?

function validateInput($in){
if(get_magic_quotes_gpc()) {
 $in = stripslashes($in);
}
$out = mysql_real_escape_string(strip_tags($in));
if(preg_match('/^[a-zA-Z0-9 ^$.*+\[\]{,}]{1,32}$/u', $out)) {
return $out;
}
else return "";
}

Edited by vampke
Link to comment
https://forums.phpfreaks.com/topic/269615-mysql-injection-is-this-safe/
Share on other sites

ok thanks, I was expecting there wasn't but the message concerned me somehow.

I know where the 302 goes to. I don't think it is relevant however. My main concern is that this program returned a fail message which does not seem to be the correct wording. If the 302 page handles the injection attempt, there is no risk, right?

 

What about the string values: are they sufficiently protected with my function?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.