Jump to content

Recommended Posts

I'm attempting to thoroughly sanitize my PHP app to avoid common exploits, and am working on guarding from SQL injections and such.

 

I'm using mysql_real_escape_string for data that comes from the user.

 

I have a number of instances of the following:

$ip = $_SERVER['REMOTE_ADDR'];

$page = $_SERVER['PHP_SELF'];

 

And then using those values to query or update SQL.  Is it a best practice to also sanitize this sort of data? 

The IP address is safe in terms of SQL injections, however PHP_SELF is not. You can pass an injection through it very easily. As a simple example, consider they inject the URL with /index.php/' OR 1=1 .. that would be preserved within the PHP_SELF variable.

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.