Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
register_globals on / off - I think I'm missing the point
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
+mrcakey  
View profile  
 More options Oct 24 2007, 6:57 am
Newsgroups: comp.lang.php
From: +mrcakey <mrca...@nospam.nospam>
Date: Wed, 24 Oct 2007 11:57:09 +0100
Local: Wed, Oct 24 2007 6:57 am
Subject: register_globals on / off - I think I'm missing the point
I understand that register_globals was turned off by default as, unless
you initialised it, it could be altered by a malicious coder.

What I don't understand is how the $_POST['foo'] form is any more
secure.  Surely Mr Malicious Coder can still just send his own version
of $_POST['foo']?

Obviously I'm missing something, I just can't figure out what!

+mrcakey


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
C. (http://symcbean.blogspot .com/)  
View profile  
 More options Oct 24 2007, 7:15 am
Newsgroups: comp.lang.php
From: "C. (http://symcbean.blogspot.com/)" <colin.mckin...@gmail.com>
Date: Wed, 24 Oct 2007 11:15:00 -0000
Subject: Re: register_globals on / off - I think I'm missing the point
On 24 Oct, 11:57, +mrcakey <mrca...@nospam.nospam> wrote:

> I understand that register_globals was turned off by default as, unless
> you initialised it, it could be altered by a malicious coder.

> What I don't understand is how the $_POST['foo'] form is any more
> secure.  Surely Mr Malicious Coder can still just send his own version
> of $_POST['foo']?

> Obviously I'm missing something, I just can't figure out what!

> +mrcakey

On its own, it probably isn't a big problem - its how it interacts
with the rest of the code e.g.:

<?php
require_once("array_of_admin_users.inc.php");
if (in_array($admin_users, $_SESSION['user'])) {
   $admin_user=true;

}

if ($admin_user) { ...

What happens when a non-admin users connects using
http://example.com/transfer_funds.php?admin_user=1 ?

See also http://pear.reversefold.com/dokuwiki/doku.php?id=phpfaqs#why_is_regis...

C.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve  
View profile  
 More options Oct 24 2007, 9:08 am
Newsgroups: comp.lang.php
From: "Steve" <no....@example.com>
Date: Wed, 24 Oct 2007 08:08:04 -0500
Local: Wed, Oct 24 2007 9:08 am
Subject: Re: register_globals on / off - I think I'm missing the point

"C. (http://symcbean.blogspot.com/)" <colin.mckin...@gmail.com> wrote in
message news:1193224500.133773.53850@e9g2000prf.googlegroups.com...

based on that code, nothing.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AnrDaemon  
View profile  
 More options Oct 24 2007, 10:45 am
Newsgroups: comp.lang.php
From: AnrDaemon <anrdae...@freemail.ru>
Date: Wed, 24 Oct 2007 18:45:08 +0400
Local: Wed, Oct 24 2007 10:45 am
Subject: Re: register_globals on / off - I think I'm missing the point
Greetings, +mrcakey.
In reply to Your message dated Wednesday, October 24, 2007, 14:57:09,

m> I understand that register_globals was turned off by default as, unless
m> you initialised it, it could be altered by a malicious coder.

m> What I don't understand is how the $_POST['foo'] form is any more
m> secure.

It is more secure, than $foo. For sure.

m> Surely Mr Malicious Coder can still just send his own version
m> of $_POST['foo']?

Yep, but You can't accidentally fetch it by using $foo somewhere in Your
script.
You should call $_POST['foo'] explicitly to deal with user input.

m> Obviously I'm missing something, I just can't figure out what!

Hope I've explained it enough to give You a point.

--
Sincerely Yours, AnrDaemon <anrdae...@freemail.ru>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
+mrcakey  
View profile  
 More options Oct 31 2007, 12:36 pm
Newsgroups: comp.lang.php
From: +mrcakey <mrca...@nospam.nospam>
Date: Wed, 31 Oct 2007 16:36:02 +0000
Local: Wed, Oct 31 2007 12:36 pm
Subject: Re: register_globals on / off - I think I'm missing the point

Essentially then register_globals exposes ALL your variables to attack
from outside rather than just those you're fetching explicitly from
$_GET, $_POST etc.  I understand now.  Thanks to all who replied.

+mrcakey


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
la...@portcommodore.com  
View profile  
 More options Oct 31 2007, 4:31 pm
Newsgroups: comp.lang.php
From: la...@portcommodore.com
Date: Wed, 31 Oct 2007 13:31:35 -0700
Local: Wed, Oct 31 2007 4:31 pm
Subject: Re: register_globals on / off - I think I'm missing the point
On Oct 31, 9:36 am, +mrcakey <mrca...@nospam.nospam> wrote:

> Essentially then register_globals exposes ALL your variables to attack
> from outside rather than just those you're fetching explicitly from
> $_GET, $_POST etc.  I understand now.  Thanks to all who replied.

> +mrcakey

Note: If you can't be sure your code is going to be always in a
globals off environment, it is recommended all variables used in the
script are initialized early on in the script (even the empty ones).
Also one gotcha with globals on is if you do $foo = $_POST['foo'];
don't initialize $foo until you've made sure $_POST['foo'] is empty.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
NC  
View profile  
 More options Oct 31 2007, 5:48 pm
Newsgroups: comp.lang.php
From: NC <n...@iname.com>
Date: Wed, 31 Oct 2007 14:48:22 -0700
Local: Wed, Oct 31 2007 5:48 pm
Subject: Re: register_globals on / off - I think I'm missing the point
On Oct 24, 3:57 am, +mrcakey <mrca...@nospam.nospam> wrote:

> I understand that register_globals was turned off by default
> as, unless you initialised it, it could be altered by a
> malicious coder.

> What I don't understand is how the $_POST['foo'] form is any
> more secure.  Surely Mr Malicious Coder can still just send
> his own version of $_POST['foo']?

> Obviously I'm missing something, I just can't figure out what!

What you are missing is a realization that with register_globals = On,
the malicious coder can initialize ANY variable, regardless of whether
the script expects to receive it via CGI.

Let's say, you have something like this:

// Tons of code here...
// The script processes incoming data and, depending on the
// program flow, may or may not initialize the $bar variable.
if (isset($bar)) {
  $result = mysql_query("DELETE FROM the_table WHERE bar='$bar'");

}

// Tons of code here too...

Now let's say that register_globals = On and malicious coder
submitted
$_REQUEST['bar'] = '%'.  The server receives it and initializes $bar =
'%'.  If $bar is not changed elsewhere, the script issues the
following MySQL query:

DELETE FROM the_table WHERE bar='%'

meaning, delete all records from the_table.

Granted, the above example is not a good coding practice, but with
register_globals = Off it is still safe (the malicious user cannot
initialize $bar and thus alter the program flow), while with
register_globals = On it is a security risk.

Cheers,
NC


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gordon Burditt  
View profile  
 More options Oct 31 2007, 9:44 pm
Newsgroups: comp.lang.php
From: gordonb.kw...@burditt.org (Gordon Burditt)
Date: Thu, 01 Nov 2007 01:44:50 -0000
Local: Wed, Oct 31 2007 9:44 pm
Subject: Re: register_globals on / off - I think I'm missing the point

>DELETE FROM the_table WHERE bar='%'

>meaning, delete all records from the_table.

No, that's not what it means.

DELETE FROM the_table WHERE bar LIKE '%'

means delete all records from the_table.  The first query means delete
all records where bar is of length one and contains a single percent sign.

Lesson here:  use = instead of LIKE unless you actually *need*
pattern-matching.  Also, turn off register_globals.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
NC  
View profile  
 More options Nov 1 2007, 4:15 pm
Newsgroups: comp.lang.php
From: NC <n...@iname.com>
Date: Thu, 01 Nov 2007 13:15:06 -0700
Local: Thurs, Nov 1 2007 4:15 pm
Subject: Re: register_globals on / off - I think I'm missing the point
On Oct 31, 6:44 pm, gordonb.kw...@burditt.org (Gordon Burditt) wrote:

> > DELETE FROM the_table WHERE bar='%'

> > meaning, delete all records from the_table.

> No, that's not what it means.

> DELETE FROM the_table WHERE bar LIKE '%'

> means delete all records from the_table.  The first query
> means delete all records where bar is of length one and
> contains a single percent sign.

You're right, of course.  I just wanted a simple illustration, so I
misinterpreted the meaning of the SQL query to make a point.  In the
real world, the attacker would use something like:

$_REQUEST['bar'] = "' OR bar LIKE '%"

Cheers,
NC


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »