$_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

This is a discussion on $_HTTP["POST"] and $_SERVER["HTTP_REFERER"] within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, Suppose you want to make sure subitted data is comming from "your" form and not submitted (with ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-03-2005
Marco
 
Posts: n/a
Default $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Hi,

Suppose you want to make sure subitted data is comming from "your" form and
not submitted (with tools) elsewhere.
What do I need to prevent false/hacked/spoofed data?

- register globals = off;
- use $_HTTP["POST"]
- check referrer with $_SERVER["HTTP_REFERER"]

are these settings 'air tight'? or (and how?) can it be overruled /
circumvented??

Regards,
Marco


Reply With Quote
  #2 (permalink)  
Old 02-03-2005
Chris Hope
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Marco wrote:

> Suppose you want to make sure subitted data is comming from "your"
> form and not submitted (with tools) elsewhere.
> What do I need to prevent false/hacked/spoofed data?
>
> - register globals = off;
> - use $_HTTP["POST"]


$_HTTP["POST"] isn't a valid variable - you want $_POST["var_name_here"]

> - check referrer with $_SERVER["HTTP_REFERER"]


Unfortunately you cannot rely on $_SERVER["HTTP_REFERER"] as it can be
blocked/unset by browser settings and other 3rd party software such as
anti spy software, privacy software, ad blocking software etc. In some
cases this is set to be blank and in other cases the site's domain
name.

And if someone is trying to see if they can do stuff to your site/server
through a form post they'd quite easily be able to fake the referer
anyway and make it look like they were posting from your page.

> are these settings 'air tight'? or (and how?) can it be overruled /
> circumvented??


You could make the user enter the string value contained in a generated
image and the value of the image is stored in a hidden field using a
hashing algorithm like md5. When the form is submitted you compare the
hash of their string with the hidden field. There are downsides to this
as it can mean people are put off completing the form altogether and
there are accessibilty issues as well.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Reply With Quote
  #3 (permalink)  
Old 02-03-2005
Oli Filth
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Marco wrote:
> Hi,
>
> Suppose you want to make sure subitted data is comming from "your" form and
> not submitted (with tools) elsewhere.
> What do I need to prevent false/hacked/spoofed data?
>
> - register globals = off;
> - use $_HTTP["POST"]
> - check referrer with $_SERVER["HTTP_REFERER"]
>
> are these settings 'air tight'? or (and how?) can it be overruled /
> circumvented??


Anyone can make a request for your PHP page with falsified POST header
data, including falsified referer data, so there is no way of proving
where this data was really generated from. After all, the data doesn't
really come from "your form", it comes from the user's browser.

I guess the only way to avoid this is to use an HTTPS secure connection,
but I don't know anything about the ins and outs of this.

--
Oli
Reply With Quote
  #4 (permalink)  
Old 02-03-2005
Chris Hope
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Oli Filth wrote:

> Marco wrote:
>> Hi,
>>
>> Suppose you want to make sure subitted data is comming from "your"
>> form and not submitted (with tools) elsewhere.
>> What do I need to prevent false/hacked/spoofed data?
>>
>> - register globals = off;
>> - use $_HTTP["POST"]
>> - check referrer with $_SERVER["HTTP_REFERER"]
>>
>> are these settings 'air tight'? or (and how?) can it be overruled /
>> circumvented??

>
> Anyone can make a request for your PHP page with falsified POST header
> data, including falsified referer data, so there is no way of proving
> where this data was really generated from. After all, the data doesn't
> really come from "your form", it comes from the user's browser.
>
> I guess the only way to avoid this is to use an HTTPS secure
> connection, but I don't know anything about the ins and outs of this.


You could still fake the data with an HTTPS connection.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Reply With Quote
  #5 (permalink)  
Old 02-03-2005
Oli Filth
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Marco wrote:
> Hi,
>
> Suppose you want to make sure subitted data is comming from "your" form and
> not submitted (with tools) elsewhere.
> What do I need to prevent false/hacked/spoofed data?
>
> - register globals = off;
> - use $_HTTP["POST"]
> - check referrer with $_SERVER["HTTP_REFERER"]
>
> are these settings 'air tight'? or (and how?) can it be overruled /
> circumvented??
>


Why do you want to prevent falsified data? If you explain what you're
trying to do, we might be able to help further...

--
Oli
Reply With Quote
  #6 (permalink)  
Old 02-03-2005
Dave Patton
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

"Marco" <dont_send{spam}[mps]@this.address[webmind.nl].please.com> wrote
in news:4202727f$0$26225$18b6e80@news.wanadoo.nl:

> Hi,
>
> Suppose you want to make sure subitted data is comming from "your"
> form and not submitted (with tools) elsewhere.
> What do I need to prevent false/hacked/spoofed data?


Proper validation of the existance of, and values of,
variables that come from Get, Post, or Cookies.

In other words, spend your time make your validation
'bulletproof', rather than worrying about whether or
not someone may use "tools" to spoof a 'normal browser'.

--
Dave Patton
Canadian Coordinator, Degree Confluence Project
http://www.confluence.org/
My website: http://members.shaw.ca/davepatton/
Reply With Quote
  #7 (permalink)  
Old 02-04-2005
Marco
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Thanks all for your time!! It helped me :-)


Marco


"Marco" <dont_send{spam}[mps]@this.address[webmind.nl].please.com> schreef
in bericht news:4202727f$0$26225$18b6e80@news.wanadoo.nl...
> Hi,
>
> Suppose you want to make sure subitted data is comming from "your" form
> and not submitted (with tools) elsewhere.
> What do I need to prevent false/hacked/spoofed data?
>
> - register globals = off;
> - use $_HTTP["POST"]
> - check referrer with $_SERVER["HTTP_REFERER"]
>
> are these settings 'air tight'? or (and how?) can it be overruled /
> circumvented??
>
> Regards,
> Marco
>



Reply With Quote
  #8 (permalink)  
Old 02-04-2005
noSpam
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Marco wrote:
> Thanks all for your time!! It helped me :-)
>
>
> Marco
>
>
> "Marco" <dont_send{spam}[mps]@this.address[webmind.nl].please.com> schreef
> in bericht news:4202727f$0$26225$18b6e80@news.wanadoo.nl...
>
>>Hi,
>>
>>Suppose you want to make sure subitted data is comming from "your" form
>>and not submitted (with tools) elsewhere.
>>What do I need to prevent false/hacked/spoofed data?
>>
>>- register globals = off;
>>- use $_HTTP["POST"]
>>- check referrer with $_SERVER["HTTP_REFERER"]
>>
>>are these settings 'air tight'? or (and how?) can it be overruled /
>>circumvented??
>>
>>Regards,
>> Marco
>>

>
>
>

If someone is going to spoof a GET or POST request then you cannot trap
it. Essentially the problem boils down to the point at which data
validation is performed, this has to be server side of the transaction.
If a database is involved then, ideally the data constraints should be
in the database. The script should do validation but the database is
responsible for not allowing garbage onto its tables.

Always assume the worst case and code for it
Reply With Quote
  #9 (permalink)  
Old 02-04-2005
noSpam
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Marco wrote:
> Thanks all for your time!! It helped me :-)
>
>
> Marco
>
>
> "Marco" <dont_send{spam}[mps]@this.address[webmind.nl].please.com> schreef
> in bericht news:4202727f$0$26225$18b6e80@news.wanadoo.nl...
>
>>Hi,
>>
>>Suppose you want to make sure subitted data is comming from "your" form
>>and not submitted (with tools) elsewhere.
>>What do I need to prevent false/hacked/spoofed data?
>>
>>- register globals = off;
>>- use $_HTTP["POST"]
>>- check referrer with $_SERVER["HTTP_REFERER"]
>>
>>are these settings 'air tight'? or (and how?) can it be overruled /
>>circumvented??
>>
>>Regards,
>> Marco
>>

>
>
>

If someone is going to spoof a GET or POST request then you cannot trap
it. Essentially the problem boils down to the point at which data
validation is performed, this has to be server side of the transaction.
If a database is involved then, ideally the data constraints should be
in the database. The script should do validation but the database is
responsible for not allowing garbage onto its tables.

Always assume the worst case and code for it
Reply With Quote
  #10 (permalink)  
Old 02-18-2005
mossy
 
Posts: n/a
Default Re: $_HTTP["POST"] and $_SERVER["HTTP_REFERER"]

Marco wrote:
> Hi,
>
> Suppose you want to make sure subitted data is comming from "your" form and
> not submitted (with tools) elsewhere.
> What do I need to prevent false/hacked/spoofed data?
>
> - register globals = off;
> - use $_HTTP["POST"]
> - check referrer with $_SERVER["HTTP_REFERER"]
>
> are these settings 'air tight'? or (and how?) can it be overruled /
> circumvented??
>
> Regards,
> Marco
>
>

HTML forms are not entirely secure, you should check all input from
userland with functions such as the string functions in php.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:01 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0