Re: Form Security



Thanks for the feedback guys. I know not to rely on HTTP_REFERER. I think the plan is to use a combination of the method I described earlier, along with filtering the input with regular expressions to ensure I'm only getting valid data.

This is for a contact form, so if you can think of any more obvious holes I need to watch for, let me know.

Thanks again!

Scott

Scott wrote:
I've been trying to come up with a way to ensure user input is coming from the form on my site, and not auto-submitted from elsewhere, and I don't want to use the "enter the code shown in the image" method. I know the $_SERVER['HTTP_REFERER'] contents can be spoofed, so I thought of doing something similar to this:

<?php
session_start();
$code = mt_rand(0,1000000);
$_SESSION['code'] = $code;
?>

Then in my form have:
<input type="hidden" name="originator" value="<?=$code?>">

On the page receiving the form:

<?php
session_start();
if(isset($_POST['originator'])) {
if($_POST['originator'] == $_SESSION['code']) {
// process the form
}
}
?>

I'm looking for feedback on this method. Do you think this is an effective way to ensure the input you're receiving is indeed from your form? Obviously, the random code key will be visible to the client, but without the matching session variable, it will be useless.

Your thoughts?

Scott
.



Relevant Pages

  • Re: Form Security
    ... Chung Leong wrote: ... On the page receiving the form: ... Obviously, the random code key will be visible to the client, but ...
    (comp.lang.php)
  • Re: Form Security
    ... Scott wrote: ... On the page receiving the form: ... Obviously, the random code key will be visible to the client, but ...
    (comp.lang.php)
  • Form Security
    ... I've been trying to come up with a way to ensure user input is coming from the form on my site, and not auto-submitted from elsewhere, and I don't want to use the "enter the code shown in the image" method. ... Do you think this is an effective way to ensure the input you're receiving is indeed from your form? ... Obviously, the random code key will be visible to the client, but without the matching session variable, it will be useless. ...
    (comp.lang.php)
  • Re: Stop begging for feedback!!!!!!
    ... You should be receiving it shortly. ... Once your item arrives in satisfactory condition, please leave feedback for us and we will do the same for you, thanks! ... If you have not received your item yet, please allow 14 business days for parcels to arrive to major cities. ... *If you have any concerns or have not received your package after 14 business days, please give us a chance to address any issues before you leave feedback. ...
    (alt.marketing.online.ebay)
  • Re: Stop begging for feedback!!!!!!
    ... You should be receiving it ... Once your item arrives in satisfactory condition, please leave feedback ... If you have not received your item yet, please allow 14 business days ...
    (alt.marketing.online.ebay)